Skip to content

Commit ff33a69

Browse files
Kelsi HoyleKelsi Hoyle
authored andcommitted
add arch to update, add arch fields to responses
1 parent f432406 commit ff33a69

File tree

3 files changed

+52
-15
lines changed

3 files changed

+52
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
## Enhancements
66

77
* Adds `EffectiveTagBindings` relation to projects and workspaces, allowing the relation to be included when listing projects or workspaces by @sebasslash [#1043](https://github.com/hashicorp/go-tfe/pull/1043)
8-
9-
# v1.74.1
8+
* Adds `Archs` field to update ToolVersions and includes architecture fields in responses. This provides BETA support, which is EXPERIMENTAL, SUBJECT TO CHANGE, and may not be available to all users by @kelsi-hoyle [#1047](https://github.com/hashicorp/go-tfe/pull/1047)
109

1110
## Enhancements
1211

admin_terraform_version.go

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,25 @@ type adminTerraformVersions struct {
4949

5050
// AdminTerraformVersion represents a Terraform Version
5151
type AdminTerraformVersion struct {
52-
ID string `jsonapi:"primary,terraform-versions"`
53-
Version string `jsonapi:"attr,version"`
54-
URL string `jsonapi:"attr,url"`
55-
Sha string `jsonapi:"attr,sha"`
56-
Deprecated bool `jsonapi:"attr,deprecated"`
57-
DeprecatedReason *string `jsonapi:"attr,deprecated-reason,omitempty"`
58-
Official bool `jsonapi:"attr,official"`
59-
Enabled bool `jsonapi:"attr,enabled"`
60-
Beta bool `jsonapi:"attr,beta"`
61-
Usage int `jsonapi:"attr,usage"`
62-
CreatedAt time.Time `jsonapi:"attr,created-at,iso8601"`
52+
ID string `jsonapi:"primary,terraform-versions"`
53+
Version string `jsonapi:"attr,version"`
54+
URL string `jsonapi:"attr,url,omitempty"`
55+
Sha string `jsonapi:"attr,sha,omitempty"`
56+
Deprecated bool `jsonapi:"attr,deprecated"`
57+
DeprecatedReason *string `jsonapi:"attr,deprecated-reason,omitempty"`
58+
Official bool `jsonapi:"attr,official"`
59+
Enabled bool `jsonapi:"attr,enabled"`
60+
Beta bool `jsonapi:"attr,beta"`
61+
Usage int `jsonapi:"attr,usage"`
62+
CreatedAt time.Time `jsonapi:"attr,created-at,iso8601"`
63+
Archs []*ToolVersionArchitecture `jsonapi:"attr,archs,omitempty"`
64+
}
65+
66+
type ToolVersionArchitecture struct {
67+
URL string `jsonapi:"attr,url"`
68+
Sha string `jsonapi:"attr,sha"`
69+
OS string `jsonapi:"attr,os"`
70+
Arch string `jsonapi:"attr,arch"`
6371
}
6472

6573
type ToolVersionArchitectureOptions struct {
@@ -86,8 +94,8 @@ type AdminTerraformVersionsListOptions struct {
8694
type AdminTerraformVersionCreateOptions struct {
8795
Type string `jsonapi:"primary,terraform-versions"`
8896
Version *string `jsonapi:"attr,version"` // Required
89-
URL *string `jsonapi:"attr,url"` // Required
90-
Sha *string `jsonapi:"attr,sha"` // Required
97+
URL *string `jsonapi:"attr,url,omitempty"`
98+
Sha *string `jsonapi:"attr,sha,omitempty"`
9199
Official *bool `jsonapi:"attr,official,omitempty"`
92100
Deprecated *bool `jsonapi:"attr,deprecated,omitempty"`
93101
DeprecatedReason *string `jsonapi:"attr,deprecated-reason,omitempty"`

admin_terraform_version_integration_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ func TestAdminTerraformVersions_CreateDelete(t *testing.T) {
137137
assert.Equal(t, *opts.DeprecatedReason, *tfv.DeprecatedReason)
138138
assert.Equal(t, *opts.Enabled, tfv.Enabled)
139139
assert.Equal(t, *opts.Beta, tfv.Beta)
140+
assert.Equal(t, len(opts.Archs), len(tfv.Archs))
141+
for i, arch := range opts.Archs {
142+
assert.Equal(t, arch.URL, tfv.Archs[i].URL)
143+
assert.Equal(t, arch.Sha, tfv.Archs[i].Sha)
144+
assert.Equal(t, arch.OS, tfv.Archs[i].OS)
145+
assert.Equal(t, arch.Arch, tfv.Archs[i].Arch)
146+
}
140147
})
141148

142149
t.Run("with valid options, url, and sha", func(t *testing.T) {
@@ -263,6 +270,29 @@ func TestAdminTerraformVersions_ReadUpdate(t *testing.T) {
263270
assert.Equal(t, *updateOpts.Deprecated, tfv.Deprecated)
264271
assert.Equal(t, *opts.Enabled, tfv.Enabled)
265272
assert.Equal(t, *opts.Beta, tfv.Beta)
273+
274+
// Update using Archs
275+
anotherUpdateVersion := genSafeRandomTerraformVersion()
276+
updateArchOpts := AdminTerraformVersionUpdateOptions{
277+
Version: String(anotherUpdateVersion),
278+
Deprecated: Bool(false),
279+
Archs: []*ToolVersionArchitectureOptions{{
280+
URL: "https://www.hashicorp.com",
281+
Sha: *sha,
282+
OS: linux,
283+
Arch: amd64,
284+
}},
285+
}
286+
287+
tfv, err = client.Admin.TerraformVersions.Update(ctx, id, updateArchOpts)
288+
require.NoError(t, err)
289+
290+
assert.Equal(t, len(tfv.Archs), 1)
291+
assert.Equal(t, updateArchOpts.Archs[0].URL, tfv.Archs[0].URL)
292+
assert.Equal(t, updateArchOpts.Archs[0].Sha, tfv.Archs[0].Sha)
293+
assert.Equal(t, updateArchOpts.Archs[0].OS, tfv.Archs[0].OS)
294+
assert.Equal(t, updateArchOpts.Archs[0].Arch, tfv.Archs[0].Arch)
295+
assert.Equal(t, anotherUpdateVersion, tfv.Version)
266296
})
267297

268298
t.Run("with non-existent terraform version", func(t *testing.T) {

0 commit comments

Comments
 (0)