Skip to content

Commit

Permalink
[TF-18527] Add Archs to AdminTerraformVersionCreateOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
natalie-todd committed Dec 20, 2024
1 parent f9d7888 commit 8724bc7
Showing 1 changed file with 41 additions and 30 deletions.
71 changes: 41 additions & 30 deletions admin_terraform_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"context"
"fmt"
"net/url"
"reflect"
"time"
)

Expand Down Expand Up @@ -42,17 +43,25 @@ type adminTerraformVersions struct {

// AdminTerraformVersion represents a Terraform Version
type AdminTerraformVersion struct {
ID string `jsonapi:"primary,terraform-versions"`
Version string `jsonapi:"attr,version"`
URL string `jsonapi:"attr,url"`
Sha string `jsonapi:"attr,sha"`
Deprecated bool `jsonapi:"attr,deprecated"`
DeprecatedReason *string `jsonapi:"attr,deprecated-reason,omitempty"`
Official bool `jsonapi:"attr,official"`
Enabled bool `jsonapi:"attr,enabled"`
Beta bool `jsonapi:"attr,beta"`
Usage int `jsonapi:"attr,usage"`
CreatedAt time.Time `jsonapi:"attr,created-at,iso8601"`
ID string `jsonapi:"primary,terraform-versions"`
Version string `jsonapi:"attr,version"`
URL string `jsonapi:"attr,url"`
Sha string `jsonapi:"attr,sha"`
Deprecated bool `jsonapi:"attr,deprecated"`
DeprecatedReason *string `jsonapi:"attr,deprecated-reason,omitempty"`
Official bool `jsonapi:"attr,official"`
Enabled bool `jsonapi:"attr,enabled"`
Beta bool `jsonapi:"attr,beta"`
Usage int `jsonapi:"attr,usage"`
CreatedAt time.Time `jsonapi:"attr,created-at,iso8601"`
Archs []*ToolVersionArchitecture `jsonapi:"attr,archs"`
}

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
Expand All @@ -70,29 +79,31 @@ 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"`
}

// AdminTerraformVersionUpdateOptions for updating terraform version.
// https://developer.hashicorp.com/terraform/enterprise/api-docs/admin/terraform-versions#request-body
type AdminTerraformVersionUpdateOptions struct {
Type string `jsonapi:"primary,terraform-versions"`
Version *string `jsonapi:"attr,version,omitempty"`
URL *string `jsonapi:"attr,url,omitempty"`
Sha *string `jsonapi:"attr,sha,omitempty"`
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,omitempty"`
URL *string `jsonapi:"attr,url,omitempty"`
Sha *string `jsonapi:"attr,sha,omitempty"`
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"`
}

// AdminTerraformVersionsList represents a list of terraform versions.
Expand Down Expand Up @@ -194,7 +205,7 @@ func (a *adminTerraformVersions) Delete(ctx context.Context, id string) error {
}

func (o AdminTerraformVersionCreateOptions) valid() error {
if (o == AdminTerraformVersionCreateOptions{}) {
if (reflect.DeepEqual(o, AdminTerraformVersionCreateOptions{})) {
return ErrRequiredTFVerCreateOps
}
if !validString(o.Version) {
Expand Down

0 comments on commit 8724bc7

Please sign in to comment.