Skip to content

Commit bdc7d8c

Browse files
authored
Upgrade go-tfe dependency to use 1.0 version. It contains breaking changes, so we are updating method signatures, method names and the type of optional parameters, as needed. (hashicorp#30626)
1 parent 86261f0 commit bdc7d8c

21 files changed

Lines changed: 96 additions & 87 deletions

‎go.mod‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ require (
4141
github.com/hashicorp/go-multierror v1.1.1
4242
github.com/hashicorp/go-plugin v1.4.3
4343
github.com/hashicorp/go-retryablehttp v0.7.0
44-
github.com/hashicorp/go-tfe v0.26.0
44+
github.com/hashicorp/go-tfe v1.0.0
4545
github.com/hashicorp/go-uuid v1.0.2
4646
github.com/hashicorp/go-version v1.3.0
4747
github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f

‎go.sum‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,14 +410,13 @@ github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5O
410410
github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8=
411411
github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo=
412412
github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I=
413-
github.com/hashicorp/go-slug v0.7.0/go.mod h1:Ib+IWBYfEfJGI1ZyXMGNbu2BU+aa3Dzu41RKLH301v4=
414413
github.com/hashicorp/go-slug v0.8.0 h1:h7AGtXVAI/cJ/Wwa/JQQaftQnWQmZbAzkzgZeZVVmLw=
415414
github.com/hashicorp/go-slug v0.8.0/go.mod h1:Ib+IWBYfEfJGI1ZyXMGNbu2BU+aa3Dzu41RKLH301v4=
416415
github.com/hashicorp/go-sockaddr v1.0.0 h1:GeH6tui99pF4NJgfnhp+L6+FfobzVW3Ah46sLo0ICXs=
417416
github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
418417
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
419-
github.com/hashicorp/go-tfe v0.26.0 h1:6vQshg2NW5CkN4fkM64qhX+Z5Ua7ip74n8nAJRlhKKg=
420-
github.com/hashicorp/go-tfe v0.26.0/go.mod h1:gyXLXbpBVxA2F/6opah8XBsOkZJxHYQmghl0OWi8keI=
418+
github.com/hashicorp/go-tfe v1.0.0 h1:CmwoHrOs7WJfD/yEmVjJ65+dyKeVRrgvRHBLVSQQ6Ks=
419+
github.com/hashicorp/go-tfe v1.0.0/go.mod h1:tJF/OlAXzVbmjiimAPLplSLgwg6kZDUOy0MzHuMwvF4=
421420
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
422421
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
423422
github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE=

‎internal/backend/remote/backend.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ func (b *Remote) Configure(obj cty.Value) tfdiags.Diagnostics {
321321
}
322322

323323
// Check if the organization exists by reading its entitlements.
324-
entitlements, err := b.client.Organizations.Entitlements(context.Background(), b.organization)
324+
entitlements, err := b.client.Organizations.ReadEntitlements(context.Background(), b.organization)
325325
if err != nil {
326326
if err == tfe.ErrResourceNotFound {
327327
err = fmt.Errorf("organization %q at host %s not found.\n\n"+
@@ -527,12 +527,12 @@ func (b *Remote) Workspaces() ([]string, error) {
527527

528528
// workspaces returns a filtered list of remote workspace names.
529529
func (b *Remote) workspaces() ([]string, error) {
530-
options := tfe.WorkspaceListOptions{}
530+
options := &tfe.WorkspaceListOptions{}
531531
switch {
532532
case b.workspace != "":
533-
options.Search = tfe.String(b.workspace)
533+
options.Search = b.workspace
534534
case b.prefix != "":
535-
options.Search = tfe.String(b.prefix)
535+
options.Search = b.prefix
536536
}
537537

538538
// Create a slice to contain all the names.

‎internal/backend/remote/backend_apply_test.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ func TestRemote_applyApprovedExternally(t *testing.T) {
777777
wl, err := b.client.Workspaces.List(
778778
ctx,
779779
b.organization,
780-
tfe.WorkspaceListOptions{},
780+
nil,
781781
)
782782
if err != nil {
783783
t.Fatalf("unexpected error listing workspaces: %v", err)
@@ -786,7 +786,7 @@ func TestRemote_applyApprovedExternally(t *testing.T) {
786786
t.Fatalf("expected 1 workspace, got %d workspaces", len(wl.Items))
787787
}
788788

789-
rl, err := b.client.Runs.List(ctx, wl.Items[0].ID, tfe.RunListOptions{})
789+
rl, err := b.client.Runs.List(ctx, wl.Items[0].ID, nil)
790790
if err != nil {
791791
t.Fatalf("unexpected error listing runs: %v", err)
792792
}
@@ -851,7 +851,7 @@ func TestRemote_applyDiscardedExternally(t *testing.T) {
851851
wl, err := b.client.Workspaces.List(
852852
ctx,
853853
b.organization,
854-
tfe.WorkspaceListOptions{},
854+
nil,
855855
)
856856
if err != nil {
857857
t.Fatalf("unexpected error listing workspaces: %v", err)
@@ -860,7 +860,7 @@ func TestRemote_applyDiscardedExternally(t *testing.T) {
860860
t.Fatalf("expected 1 workspace, got %d workspaces", len(wl.Items))
861861
}
862862

863-
rl, err := b.client.Runs.List(ctx, wl.Items[0].ID, tfe.RunListOptions{})
863+
rl, err := b.client.Runs.List(ctx, wl.Items[0].ID, nil)
864864
if err != nil {
865865
t.Fatalf("unexpected error listing runs: %v", err)
866866
}

‎internal/backend/remote/backend_common.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func (b *Remote) waitForRun(stopCtx, cancelCtx context.Context, op *backend.Oper
110110
// Skip checking the workspace queue when we are the current run.
111111
if w.CurrentRun == nil || w.CurrentRun.ID != r.ID {
112112
found := false
113-
options := tfe.RunListOptions{}
113+
options := &tfe.RunListOptions{}
114114
runlist:
115115
for {
116116
rl, err := b.client.Runs.List(stopCtx, w.ID, options)
@@ -165,10 +165,10 @@ func (b *Remote) waitForRun(stopCtx, cancelCtx context.Context, op *backend.Oper
165165
}
166166
}
167167

168-
options := tfe.RunQueueOptions{}
168+
options := tfe.ReadRunQueueOptions{}
169169
search:
170170
for {
171-
rq, err := b.client.Organizations.RunQueue(stopCtx, b.organization, options)
171+
rq, err := b.client.Organizations.ReadRunQueue(stopCtx, b.organization, options)
172172
if err != nil {
173173
return r, generalError("Failed to retrieve queue", err)
174174
}
@@ -191,7 +191,7 @@ func (b *Remote) waitForRun(stopCtx, cancelCtx context.Context, op *backend.Oper
191191
}
192192

193193
if position > 0 {
194-
c, err := b.client.Organizations.Capacity(stopCtx, b.organization)
194+
c, err := b.client.Organizations.ReadCapacity(stopCtx, b.organization)
195195
if err != nil {
196196
return r, generalError("Failed to retrieve capacity", err)
197197
}

‎internal/backend/remote/backend_context.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func (b *Remote) LocalRun(op *backend.Operation) (*backend.LocalRun, statemgr.Fu
108108
log.Printf("[TRACE] skipping retrieving variables from workspace %s/%s (%s), workspace is in Local Execution mode", remoteWorkspaceName, b.organization, remoteWorkspaceID)
109109
} else {
110110
log.Printf("[TRACE] backend/remote: retrieving variables from workspace %s/%s (%s)", remoteWorkspaceName, b.organization, remoteWorkspaceID)
111-
tfeVariables, err := b.client.Variables.List(context.Background(), remoteWorkspaceID, tfe.VariableListOptions{})
111+
tfeVariables, err := b.client.Variables.List(context.Background(), remoteWorkspaceID, nil)
112112
if err != nil && err != tfe.ErrResourceNotFound {
113113
diags = diags.Append(fmt.Errorf("error loading variables: %w", err))
114114
return nil, nil, diags

‎internal/backend/remote/backend_state.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type remoteClient struct {
2727
func (r *remoteClient) Get() (*remote.Payload, error) {
2828
ctx := context.Background()
2929

30-
sv, err := r.client.StateVersions.Current(ctx, r.workspace.ID)
30+
sv, err := r.client.StateVersions.ReadCurrent(ctx, r.workspace.ID)
3131
if err != nil {
3232
if err == tfe.ErrResourceNotFound {
3333
// If no state exists, then return nil.

‎internal/cloud/backend.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ func (b *Cloud) Configure(obj cty.Value) tfdiags.Diagnostics {
273273
}
274274

275275
// Check if the organization exists by reading its entitlements.
276-
entitlements, err := b.client.Organizations.Entitlements(context.Background(), b.organization)
276+
entitlements, err := b.client.Organizations.ReadEntitlements(context.Background(), b.organization)
277277
if err != nil {
278278
if err == tfe.ErrResourceNotFound {
279279
err = fmt.Errorf("organization %q at host %s not found.\n\n"+
@@ -452,10 +452,10 @@ func (b *Cloud) Workspaces() ([]string, error) {
452452

453453
// Otherwise, multiple workspaces are being mapped. Query Terraform Cloud for all the remote
454454
// workspaces by the provided mapping strategy.
455-
options := tfe.WorkspaceListOptions{}
455+
options := &tfe.WorkspaceListOptions{}
456456
if b.WorkspaceMapping.Strategy() == WorkspaceTagsStrategy {
457457
taglist := strings.Join(b.WorkspaceMapping.Tags, ",")
458-
options.Tags = &taglist
458+
options.Tags = taglist
459459
}
460460

461461
for {

‎internal/cloud/backend_apply_test.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ func TestCloud_applyApprovedExternally(t *testing.T) {
655655
wl, err := b.client.Workspaces.List(
656656
ctx,
657657
b.organization,
658-
tfe.WorkspaceListOptions{},
658+
nil,
659659
)
660660
if err != nil {
661661
t.Fatalf("unexpected error listing workspaces: %v", err)
@@ -664,7 +664,7 @@ func TestCloud_applyApprovedExternally(t *testing.T) {
664664
t.Fatalf("expected 1 workspace, got %d workspaces", len(wl.Items))
665665
}
666666

667-
rl, err := b.client.Runs.List(ctx, wl.Items[0].ID, tfe.RunListOptions{})
667+
rl, err := b.client.Runs.List(ctx, wl.Items[0].ID, nil)
668668
if err != nil {
669669
t.Fatalf("unexpected error listing runs: %v", err)
670670
}
@@ -729,7 +729,7 @@ func TestCloud_applyDiscardedExternally(t *testing.T) {
729729
wl, err := b.client.Workspaces.List(
730730
ctx,
731731
b.organization,
732-
tfe.WorkspaceListOptions{},
732+
nil,
733733
)
734734
if err != nil {
735735
t.Fatalf("unexpected error listing workspaces: %v", err)
@@ -738,7 +738,7 @@ func TestCloud_applyDiscardedExternally(t *testing.T) {
738738
t.Fatalf("expected 1 workspace, got %d workspaces", len(wl.Items))
739739
}
740740

741-
rl, err := b.client.Runs.List(ctx, wl.Items[0].ID, tfe.RunListOptions{})
741+
rl, err := b.client.Runs.List(ctx, wl.Items[0].ID, nil)
742742
if err != nil {
743743
t.Fatalf("unexpected error listing runs: %v", err)
744744
}

‎internal/cloud/backend_common.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func (b *Cloud) waitForRun(stopCtx, cancelCtx context.Context, op *backend.Opera
109109
// Skip checking the workspace queue when we are the current run.
110110
if w.CurrentRun == nil || w.CurrentRun.ID != r.ID {
111111
found := false
112-
options := tfe.RunListOptions{}
112+
options := &tfe.RunListOptions{}
113113
runlist:
114114
for {
115115
rl, err := b.client.Runs.List(stopCtx, w.ID, options)
@@ -164,10 +164,10 @@ func (b *Cloud) waitForRun(stopCtx, cancelCtx context.Context, op *backend.Opera
164164
}
165165
}
166166

167-
options := tfe.RunQueueOptions{}
167+
options := tfe.ReadRunQueueOptions{}
168168
search:
169169
for {
170-
rq, err := b.client.Organizations.RunQueue(stopCtx, b.organization, options)
170+
rq, err := b.client.Organizations.ReadRunQueue(stopCtx, b.organization, options)
171171
if err != nil {
172172
return r, generalError("Failed to retrieve queue", err)
173173
}
@@ -190,7 +190,7 @@ func (b *Cloud) waitForRun(stopCtx, cancelCtx context.Context, op *backend.Opera
190190
}
191191

192192
if position > 0 {
193-
c, err := b.client.Organizations.Capacity(stopCtx, b.organization)
193+
c, err := b.client.Organizations.ReadCapacity(stopCtx, b.organization)
194194
if err != nil {
195195
return r, generalError("Failed to retrieve capacity", err)
196196
}

0 commit comments

Comments
 (0)