-
Notifications
You must be signed in to change notification settings - Fork 269
Convert k6 resource IDs to string #2204
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
Conversation
In order to lower resource usage and have a faster runtime, PRs will not run Cloud tests automatically. |
2f400f3
to
d1a01f7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fornfrey, thanks for this 🙌
I don't see anything obviously off (within my limited knowledge of this code base), except for Read method in project limits resource: please see my comment.
type loadTestResourceModelV0 struct { | ||
ID types.Int32 `tfsdk:"id"` | ||
ProjectID types.Int32 `tfsdk:"project_id"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 models are basically needed for backwards compatibility, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this approach is suggested in the Terraform docs https://developer.hashicorp.com/terraform/plugin/framework/resources/state-upgrade#stateupgrader-with-priorschema
@@ -151,15 +228,25 @@ func (r *projectLimitsResource) Read(ctx context.Context, req resource.ReadReque | |||
// Set the ID to match the project_id | |||
state.ID = state.ProjectID | |||
|
|||
intID, err := strconv.ParseInt(state.ID.ValueString(), 10, 32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no "crossplane check" for ID being empty in this resource, it seems. Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
project_limits
does not have its own ID. Instead, we use the supplied ProjectID
, which is expected to be set by the practitioner explicitly in the resource.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 so it's a characteristic of the API; I didn't realize that. OK then, thanks for clarifying.
Is there any chance to test these changes with Crossplane before merging and releasing it (maybe locally, pointing to the "dev" provider)? 🤔 Regarding existing states, I guess the upgrader solution should be fine - thanks for adding the according tests 👌🏻 🙇🏻 |
@joanlopez, AFAIS it's possible to test Crossplane provider's runtime with the branch (commit hash) of the Terraform provider. But generation of Crossplane provider requires a Terraform release. Looking here, I think it might be possible to also test Crossplane provider's generation with the local "binary" of the Terraform provider but it must be built first, from the branch. Is it possible to quickly build that binary? I'll be happy to try that, if there's a known command for that. (just in case though, there's no guarantee that it'd work...) |
Just to clarify: since we're changing types of fields in this PR, so changing structure of the objects, Crossplane's generation is also needed for a full test. |
@Yoruga the binary can be built with just |
OK, running So simple testing with Crossplane provider was done; some notable observations:
I hope all of the above are expected at the moment. I'll run some more tests. And there is one more thing I'd like to look into for crossplane-provider (the way to reference projects without an ID) but that one shouldn't require changes in Terraform provider. So preliminary I believe this PR did the main fix: generated Crossplane objects can be created and manipulated at a basic level 🙌 |
@yorugac Thank you for testing this! All your observations are the expected behavior of the API. |
UpgradeState
methods to migrate the existing states. This makes the change backward compatible.Read
methods to prevent errors when called from crossplaneObserve()
method for the first time before the resource is created.