-
Notifications
You must be signed in to change notification settings - Fork 103
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
Feature: add support for applying/removing variable set against workspaces #375
Feature: add support for applying/removing variable set against workspaces #375
Conversation
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.
All in all, the changes look 🔥 -- There are some minor things mentioned below!
variable_set.go
Outdated
@@ -235,6 +242,72 @@ func (s *variableSets) Delete(ctx context.Context, variableSetID string) error { | |||
return s.client.do(ctx, req, nil) | |||
} | |||
|
|||
// VariableSetApplyToWorkspacesOptions represents the options for applying variable sets to workspaces. | |||
type VariableSetApplyToWorkspacesOptions struct { |
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.
We've established a convention for v1.0 that lays out the structure for any given file: 1) Interface/Struct definitions, 2) Receiver methods and 3) validate/helper methods.
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.
Just to be clear, it should be all structs at the top of the file, followed by receiver methods and so on...
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.
Cheers, happy to move these. To be clear: would you like me to move just these newly-added structs, or all previously-existing ones too? It looks like workspace.tf follows the convention you're describing as a matter of prior art.
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 if you would not mind reorganizing the file that would be great! 🚀
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.
Addressed, but this may make the diff somewhat more difficult to read. I've split the re-arrangement into its own commit, here: ba9fb5d
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.
🔥 - Ran integration test and verified the code locally
return nil, err | ||
} | ||
// If true the variable set is considered in all runs in the organization. | ||
Global *bool `jsonapi:"attr,global,omitempty"` |
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.
This appears to be an optional value (pointer, omitempty) but we make sure the value isn't nil within VariableSetCreateOptions valid method
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.
Hey! I can't speak to this particular type. It appears in the diff because I re-ordered everything in variable_set.go at Sebastian's request, but I'm not sure I have the necessary context to understand the ask here or competently resolve it. It might make for a good GH issue to handle in a separate PR.
if options != nil { | ||
if err := options.valid(); err != nil { |
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.
💅 Since nil appears to be allowed for options, you could implement this check (o == nil) within the valid() method
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.
Same as above: I suspect you're right, but I don't have any context for this, and it only appears as a diff because of this file being massively re-arranged.
wTest2, wTest2Cleanup := createWorkspace(t, client, orgTest) | ||
defer wTest2Cleanup() | ||
|
||
t.Run("with first workspace added", func(t *testing.T) { |
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.
Would love to see some test cases for invalid options
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.
Cheers, will add some more test cases!
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 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.
Fuego 🔥
Reminder to the contributor that merged this PR: if your changes have added important functionality or fixed a relevant bug, open a follow-up PR to update CHANGELOG.md with a note on your changes. |
Description
Hello! The Terraform Cloud API has a couple of Variable Set APIs which our team would like to add for the sake of the Terraform TFE Provider which
go-tfe
underpins. These APIs are:Both APIs accept a payload of the following format:
Testing plan
External links
Output from tests (HashiCorp employees only)
N/A; I have access to some live orgs which I'm sure I should not be messing around with!