Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tftypes: Change (AttributePath).WithElementKeyInt() method parameter to int #101

Merged
merged 5 commits into from
Aug 16, 2021

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Aug 11, 2021

Closes #59

…hElementKeyInt() method parameter to int

Reference: #59
@bflad bflad added the enhancement New feature or request label Aug 11, 2021
@bflad bflad requested a review from a team August 11, 2021 16:13

// WithElementKeyInt64 adds an ElementKeyInt step to `a`, using `key` as the
// element's key. `a` is copied, not modified.
func (a *AttributePath) WithElementKeyInt64(key int64) *AttributePath {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My controversial hot take is we should leave this out for now, and wait for someone to need it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also completely fine with that. Wasn't sure the boundaries of fully offering "protocol support" (64 bit), but seems pragmatic to drop this here for practical reasons.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm generally in the "let's make sure we can support everything the protocol can" camp for this, but I imagine if we have 2 billion elements in a list, something else is going to break first. cty also uses an int, so it would have problems too. So I'm grudgingly willing to bend to pragmatism on this one. (I also think Go will have some trouble with those values, because I don't know that slices can have more values than ints can hold.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the Go spec doesn't support Array or Slice types above int: https://golang.org/ref/spec#Array_types

The length is part of the array's type; it must evaluate to a non-negative constant representable by a value of type int.

It would require a different implementation to always support 64 bit "slices" on non 64 bit systems.

@bflad bflad self-assigned this Aug 16, 2021
@bflad bflad requested a review from paddycarver August 16, 2021 15:12
tftypes: `(AttributePath).WithElementKeyInt()` now has an `int` parameter instead of `int64`.
```

```release-note:note
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a second note for this, in addition to the breaking change entry?

Copy link
Contributor Author

@bflad bflad Aug 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought it might be nice to explain why the change was made in the changelog, but can remove or just include in the breaking change entry.

@bflad bflad changed the title tftypes: Add (AttributePath).WithElementKeyInt64() method, change WithElementKeyInt() method parameter to int tftypes: Change (AttributePath).WithElementKeyInt() method parameter to int Aug 16, 2021
@bflad bflad requested a review from paddycarver August 16, 2021 15:30
@bflad bflad added this to the v0.4.0 milestone Aug 16, 2021
@bflad bflad merged commit 995ed8b into main Aug 16, 2021
@bflad bflad deleted the f-WithElementKeyInt64 branch August 16, 2021 15:36
ewbankkit added a commit to hashicorp/terraform-provider-awscc that referenced this pull request Sep 29, 2021
ewbankkit added a commit to hashicorp/terraform-provider-awscc that referenced this pull request Sep 29, 2021
ewbankkit added a commit to hashicorp/terraform-provider-awscc that referenced this pull request Sep 29, 2021
ewbankkit added a commit to hashicorp/terraform-provider-awscc that referenced this pull request Sep 29, 2021
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

QoL: Make argument to AttributePath.WithElementKeyInt an int (not int64)
2 participants