-
Notifications
You must be signed in to change notification settings - Fork 102
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
[TF-18527] Add Archs to AdminTerraformVersionCreateOptions #1022
Changes from 4 commits
8724bc7
b3dc95d
62b5fa7
b850462
56eeb74
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import ( | |
"context" | ||
"fmt" | ||
"net/url" | ||
"reflect" | ||
"time" | ||
) | ||
|
||
|
@@ -55,6 +56,13 @@ type AdminTerraformVersion struct { | |
CreatedAt time.Time `jsonapi:"attr,created-at,iso8601"` | ||
} | ||
|
||
type ToolVersionArchitecture struct { | ||
URL string `jsonapi:"attr,url"` | ||
Sha string `jsonapi:"attr,sha"` | ||
OS string `jsonapi:"attr,os"` | ||
Arch string `jsonapi:"attr,arch"` | ||
} | ||
|
||
// AdminTerraformVersionsListOptions represents the options for listing | ||
// terraform versions. | ||
type AdminTerraformVersionsListOptions struct { | ||
|
@@ -70,15 +78,16 @@ type AdminTerraformVersionsListOptions struct { | |
// AdminTerraformVersionCreateOptions for creating a terraform version. | ||
// https://developer.hashicorp.com/terraform/enterprise/api-docs/admin/terraform-versions#request-body | ||
type AdminTerraformVersionCreateOptions struct { | ||
Type string `jsonapi:"primary,terraform-versions"` | ||
Version *string `jsonapi:"attr,version"` // Required | ||
URL *string `jsonapi:"attr,url"` // Required | ||
Sha *string `jsonapi:"attr,sha"` // Required | ||
Official *bool `jsonapi:"attr,official,omitempty"` | ||
Deprecated *bool `jsonapi:"attr,deprecated,omitempty"` | ||
DeprecatedReason *string `jsonapi:"attr,deprecated-reason,omitempty"` | ||
Enabled *bool `jsonapi:"attr,enabled,omitempty"` | ||
Beta *bool `jsonapi:"attr,beta,omitempty"` | ||
Type string `jsonapi:"primary,terraform-versions"` | ||
Version *string `jsonapi:"attr,version"` // Required | ||
URL *string `jsonapi:"attr,url"` // Required | ||
Sha *string `jsonapi:"attr,sha"` // Required | ||
Official *bool `jsonapi:"attr,official,omitempty"` | ||
Deprecated *bool `jsonapi:"attr,deprecated,omitempty"` | ||
DeprecatedReason *string `jsonapi:"attr,deprecated-reason,omitempty"` | ||
Enabled *bool `jsonapi:"attr,enabled,omitempty"` | ||
Beta *bool `jsonapi:"attr,beta,omitempty"` | ||
Archs []*ToolVersionArchitecture `jsonapi:"attr,archs,omitempty"` | ||
} | ||
|
||
// AdminTerraformVersionUpdateOptions for updating terraform version. | ||
|
@@ -194,7 +203,7 @@ func (a *adminTerraformVersions) Delete(ctx context.Context, id string) error { | |
} | ||
|
||
func (o AdminTerraformVersionCreateOptions) valid() error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to add a validation that checks all fields are provided for architectures, if present? I could also make a case for waiting to add that handling along with update support once the feature is released and the API is fully stable! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just added a validation to check whether at least one valid arch was provided or a valid URL and SHA. Let me know if this seems good or if you were thinking of something else. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's perfect! Just a little nicer to skip making the request if we already know it's going to fail. |
||
if (o == AdminTerraformVersionCreateOptions{}) { | ||
if (reflect.DeepEqual(o, AdminTerraformVersionCreateOptions{})) { | ||
return ErrRequiredTFVerCreateOps | ||
} | ||
if !validString(o.Version) { | ||
|
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.
Question for core cloud folks: do we need to note that this is in beta to give any TFE users a heads up that they won't be able to use that field yet?
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.
Thank you, yes! In the past we have used words like: Adds BETA support for [such and such feature], which is EXPERIMENTAL, SUBJECT TO CHANGE, and may not be available to all users.
Those words could be applied here.