Skip to content

Commit

Permalink
Merge branch 'main' into brandonc/v1.73.1
Browse files Browse the repository at this point in the history
  • Loading branch information
uturunku1 authored Jan 10, 2025
2 parents 9549e3e + 220fbfa commit 0f0132c
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 29 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

## Bug fixes

* Includes a critical security update in an upstream depdendency `hashicorp/go-slug`
* Includes a critical security update in an upstream depdendency `hashicorp/go-slug` @NodyHub [#1025](https://github.com/hashicorp/go-tfe/pull/1025)
* Fix bug in BETA support for Linux arm64 agents, which is EXPERIMENTAL, SUBJECT TO CHANGE, and may not be available to all users @natalie-todd [#1022](https://github.com/hashicorp/go-tfe/pull/1022)

# v1.73.0

Expand Down
31 changes: 15 additions & 16 deletions admin_terraform_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ 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"`
type ToolVersionArchitectureOptions struct {
URL string `json:"url"`
Sha string `json:"sha"`
OS string `json:"os"`
Arch string `json:"arch"`
}

// AdminTerraformVersionsListOptions represents the options for listing
Expand All @@ -84,16 +84,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"`
Archs []*ToolVersionArchitecture `jsonapi:"attr,archs,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 []*ToolVersionArchitectureOptions `jsonapi:"attr,archs,omitempty"`
}

// AdminTerraformVersionUpdateOptions for updating terraform version.
Expand Down Expand Up @@ -168,7 +168,6 @@ func (a *adminTerraformVersions) Create(ctx context.Context, options AdminTerraf
if err != nil {
return nil, err
}

return tfv, nil
}

Expand Down
56 changes: 44 additions & 12 deletions admin_terraform_version_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,25 +100,57 @@ func TestAdminTerraformVersions_CreateDelete(t *testing.T) {

client := testClient(t)
ctx := context.Background()
version := genSafeRandomTerraformVersion()

t.Run("with valid options", func(t *testing.T) {
sha := String(genSha(t))
t.Run("with valid options and archs", func(t *testing.T) {
opts := AdminTerraformVersionCreateOptions{
Version: String(version),
Version: String(genSafeRandomTerraformVersion()),
Deprecated: Bool(true),
DeprecatedReason: String("Test Reason"),
Official: Bool(false),
Enabled: Bool(false),
Beta: Bool(false),
Archs: []*ToolVersionArchitectureOptions{
{
URL: "https://www.hashicorp.com",
Sha: *String(genSha(t)),
OS: linux,
Arch: amd64,
},
{
URL: "https://www.hashicorp.com",
Sha: *String(genSha(t)),
OS: linux,
Arch: arm64,
}},
}
tfv, err := client.Admin.TerraformVersions.Create(ctx, opts)
require.NoError(t, err)

defer func() {
deleteErr := client.Admin.TerraformVersions.Delete(ctx, tfv.ID)
require.NoError(t, deleteErr)
}()

assert.Equal(t, *opts.Version, tfv.Version)
assert.Equal(t, *opts.URL, tfv.URL)
assert.Equal(t, *opts.Sha, tfv.Sha)
assert.Equal(t, *opts.Official, tfv.Official)
assert.Equal(t, *opts.Deprecated, tfv.Deprecated)
assert.Equal(t, *opts.DeprecatedReason, *tfv.DeprecatedReason)
assert.Equal(t, *opts.Enabled, tfv.Enabled)
assert.Equal(t, *opts.Beta, tfv.Beta)
})

t.Run("with valid options, url, and sha", func(t *testing.T) {
opts := AdminTerraformVersionCreateOptions{
Version: String(genSafeRandomTerraformVersion()),
URL: String("https://www.hashicorp.com"),
Sha: sha,
Sha: String(genSha(t)),
Deprecated: Bool(true),
DeprecatedReason: String("Test Reason"),
Official: Bool(false),
Enabled: Bool(false),
Beta: Bool(false),
Archs: []*ToolVersionArchitecture{{
URL: "https://www.hashicorp.com",
Sha: *sha,
OS: linux,
Arch: amd64,
}},
}
tfv, err := client.Admin.TerraformVersions.Create(ctx, opts)
require.NoError(t, err)
Expand Down Expand Up @@ -187,7 +219,7 @@ func TestAdminTerraformVersions_ReadUpdate(t *testing.T) {
DeprecatedReason: String("Test Reason"),
Enabled: Bool(false),
Beta: Bool(false),
Archs: []*ToolVersionArchitecture{{
Archs: []*ToolVersionArchitectureOptions{{
URL: "https://www.hashicorp.com",
Sha: *sha,
OS: linux,
Expand Down

0 comments on commit 0f0132c

Please sign in to comment.