Skip to content

Commit 1ae80cd

Browse files
committed
chore: remove include option from stacks endpoints
1 parent bb1661f commit 1ae80cd

File tree

4 files changed

+9
-93
lines changed

4 files changed

+9
-93
lines changed

stack.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type Stacks interface {
1818
List(ctx context.Context, organization string, options *StackListOptions) (*StackList, error)
1919

2020
// Read returns a stack by its ID.
21-
Read(ctx context.Context, stackID string, options *StackReadOptions) (*Stack, error)
21+
Read(ctx context.Context, stackID string) (*Stack, error)
2222

2323
// Create creates a new stack.
2424
Create(ctx context.Context, options StackCreateOptions) (*Stack, error)
@@ -239,8 +239,8 @@ func (s stacks) List(ctx context.Context, organization string, options *StackLis
239239
}
240240

241241
// Read returns a stack by its ID.
242-
func (s stacks) Read(ctx context.Context, stackID string, options *StackReadOptions) (*Stack, error) {
243-
req, err := s.client.NewRequest("GET", fmt.Sprintf("stacks/%s", url.PathEscape(stackID)), options)
242+
func (s stacks) Read(ctx context.Context, stackID string) (*Stack, error) {
243+
req, err := s.client.NewRequest("GET", fmt.Sprintf("stacks/%s", url.PathEscape(stackID)), nil)
244244
if err != nil {
245245
return nil, err
246246
}

stack_deployment_runs.go

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ type StackDeploymentRuns interface {
1515
// List returns a list of stack deployment runs for a given deployment group.
1616
List(ctx context.Context, deploymentGroupID string, options *StackDeploymentRunListOptions) (*StackDeploymentRunList, error)
1717
Read(ctx context.Context, stackDeploymentRunID string) (*StackDeploymentRun, error)
18-
ReadWithOptions(ctx context.Context, stackDeploymentRunID string, options *StackDeploymentRunReadOptions) (*StackDeploymentRun, error)
1918
ApproveAllPlans(ctx context.Context, deploymentRunID string) error
2019
Cancel(ctx context.Context, stackDeploymentRunID string) error
2120
}
@@ -38,28 +37,15 @@ type StackDeploymentRun struct {
3837
StackDeploymentGroup *StackDeploymentGroup `jsonapi:"relation,stack-deployment-group"`
3938
}
4039

41-
type SDRIncludeOpt string
42-
43-
const (
44-
SDRDeploymentGroup SDRIncludeOpt = "stack-deployment-group"
45-
)
46-
4740
// StackDeploymentRunList represents a list of stack deployment runs.
4841
type StackDeploymentRunList struct {
4942
*Pagination
5043
Items []*StackDeploymentRun
5144
}
5245

53-
type StackDeploymentRunReadOptions struct {
54-
// Optional: A list of relations to include.
55-
Include []SDRIncludeOpt `url:"include,omitempty"`
56-
}
57-
5846
// StackDeploymentRunListOptions represents the options for listing stack deployment runs.
5947
type StackDeploymentRunListOptions struct {
6048
ListOptions
61-
// Optional: A list of relations to include.
62-
Include []SDRIncludeOpt `url:"include,omitempty"`
6349
}
6450

6551
// List returns a list of stack deployment runs for a given deployment group.
@@ -92,26 +78,6 @@ func (s stackDeploymentRuns) Read(ctx context.Context, stackDeploymentRunID stri
9278

9379
return &run, nil
9480
}
95-
96-
func (s stackDeploymentRuns) ReadWithOptions(ctx context.Context, stackDeploymentRunID string, options *StackDeploymentRunReadOptions) (*StackDeploymentRun, error) {
97-
if err := options.valid(); err != nil {
98-
return nil, err
99-
}
100-
101-
req, err := s.client.NewRequest("GET", fmt.Sprintf("stack-deployment-runs/%s", url.PathEscape(stackDeploymentRunID)), options)
102-
if err != nil {
103-
return nil, err
104-
}
105-
106-
run := StackDeploymentRun{}
107-
err = req.Do(ctx, &run)
108-
if err != nil {
109-
return nil, err
110-
}
111-
112-
return &run, nil
113-
}
114-
11581
func (s stackDeploymentRuns) ApproveAllPlans(ctx context.Context, stackDeploymentRunID string) error {
11682
req, err := s.client.NewRequest("POST", fmt.Sprintf("stack-deployment-runs/%s/approve-all-plans", url.PathEscape(stackDeploymentRunID)), nil)
11783
if err != nil {
@@ -129,15 +95,3 @@ func (s stackDeploymentRuns) Cancel(ctx context.Context, stackDeploymentRunID st
12995

13096
return req.Do(ctx, nil)
13197
}
132-
133-
func (o *StackDeploymentRunReadOptions) valid() error {
134-
for _, include := range o.Include {
135-
switch include {
136-
case SDRDeploymentGroup:
137-
// Valid option, do nothing.
138-
default:
139-
return fmt.Errorf("invalid include option: %s", include)
140-
}
141-
}
142-
return nil
143-
}

stack_deployment_runs_integration_test.go

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -72,28 +72,6 @@ func TestStackDeploymentRunsList(t *testing.T) {
7272
require.NoError(t, err)
7373
assert.NotNil(t, runList)
7474
})
75-
76-
t.Run("With include option", func(t *testing.T) {
77-
t.Parallel()
78-
79-
runList, err := client.StackDeploymentRuns.List(ctx, deploymentGroupID, &StackDeploymentRunListOptions{
80-
Include: []SDRIncludeOpt{"stack-deployment-group"},
81-
})
82-
assert.NoError(t, err)
83-
assert.NotNil(t, runList)
84-
for _, run := range runList.Items {
85-
assert.NotNil(t, run.StackDeploymentGroup.ID)
86-
}
87-
})
88-
89-
t.Run("With invalid include option", func(t *testing.T) {
90-
t.Parallel()
91-
92-
_, err := client.StackDeploymentRuns.List(ctx, deploymentGroupID, &StackDeploymentRunListOptions{
93-
Include: []SDRIncludeOpt{"invalid-option"},
94-
})
95-
assert.Error(t, err)
96-
})
9775
}
9876

9977
func TestStackDeploymentRunsRead(t *testing.T) {
@@ -149,20 +127,6 @@ func TestStackDeploymentRunsRead(t *testing.T) {
149127
_, err := client.StackDeploymentRuns.Read(ctx, "")
150128
assert.Error(t, err)
151129
})
152-
t.Run("Read with options", func(t *testing.T) {
153-
run, err := client.StackDeploymentRuns.ReadWithOptions(ctx, sdr.ID, &StackDeploymentRunReadOptions{
154-
Include: []SDRIncludeOpt{"stack-deployment-group"},
155-
})
156-
assert.NoError(t, err)
157-
assert.NotNil(t, run)
158-
assert.NotNil(t, run.StackDeploymentGroup.ID)
159-
})
160-
t.Run("Read with invalid options", func(t *testing.T) {
161-
_, err := client.StackDeploymentRuns.ReadWithOptions(ctx, sdr.ID, &StackDeploymentRunReadOptions{
162-
Include: []SDRIncludeOpt{"invalid-option"},
163-
})
164-
assert.Error(t, err)
165-
})
166130
}
167131

168132
func TestStackDeploymentRunsApproveAllPlans(t *testing.T) {

stack_integration_test.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ func TestStackReadUpdateDelete(t *testing.T) {
165165
require.NotEmpty(t, stack.VCSRepo.OAuthTokenID)
166166
require.NotEmpty(t, stack.VCSRepo.Branch)
167167

168-
stackRead, err := client.Stacks.Read(ctx, stack.ID, nil)
168+
stackRead, err := client.Stacks.Read(ctx, stack.ID)
169169
require.NoError(t, err)
170170
require.Equal(t, stack.VCSRepo.Identifier, stackRead.VCSRepo.Identifier)
171171
require.Equal(t, stack.VCSRepo.OAuthTokenID, stackRead.VCSRepo.OAuthTokenID)
@@ -199,7 +199,7 @@ func TestStackReadUpdateDelete(t *testing.T) {
199199
err = client.Stacks.Delete(ctx, stack.ID)
200200
require.NoError(t, err)
201201

202-
stackReadAfterDelete, err := client.Stacks.Read(ctx, stack.ID, nil)
202+
stackReadAfterDelete, err := client.Stacks.Read(ctx, stack.ID)
203203
require.ErrorIs(t, err, ErrResourceNotFound)
204204
require.Nil(t, stackReadAfterDelete)
205205
}
@@ -234,7 +234,7 @@ func TestStackRemoveVCSBacking(t *testing.T) {
234234
require.NotEmpty(t, stack.VCSRepo.OAuthTokenID)
235235
require.NotEmpty(t, stack.VCSRepo.Branch)
236236

237-
stackRead, err := client.Stacks.Read(ctx, stack.ID, nil)
237+
stackRead, err := client.Stacks.Read(ctx, stack.ID)
238238
require.NoError(t, err)
239239
require.Equal(t, stack.VCSRepo.Identifier, stackRead.VCSRepo.Identifier)
240240
require.Equal(t, stack.VCSRepo.OAuthTokenID, stackRead.VCSRepo.OAuthTokenID)
@@ -280,7 +280,7 @@ func TestStackReadUpdateForceDelete(t *testing.T) {
280280
require.NotEmpty(t, stack.VCSRepo.OAuthTokenID)
281281
require.NotEmpty(t, stack.VCSRepo.Branch)
282282

283-
stackRead, err := client.Stacks.Read(ctx, stack.ID, nil)
283+
stackRead, err := client.Stacks.Read(ctx, stack.ID)
284284
require.NoError(t, err)
285285
require.Equal(t, stack.VCSRepo.Identifier, stackRead.VCSRepo.Identifier)
286286
require.Equal(t, stack.VCSRepo.OAuthTokenID, stackRead.VCSRepo.OAuthTokenID)
@@ -307,7 +307,7 @@ func TestStackReadUpdateForceDelete(t *testing.T) {
307307
err = client.Stacks.ForceDelete(ctx, stack.ID)
308308
require.NoError(t, err)
309309

310-
stackReadAfterDelete, err := client.Stacks.Read(ctx, stack.ID, nil)
310+
stackReadAfterDelete, err := client.Stacks.Read(ctx, stack.ID)
311311
require.ErrorIs(t, err, ErrResourceNotFound)
312312
require.Nil(t, stackReadAfterDelete)
313313
}
@@ -332,9 +332,7 @@ func pollStackDeployments(t *testing.T, ctx context.Context, client *Client, sta
332332
t.Fatalf("Stack %q had no deployment groups at deadline", stackID)
333333
case <-ticker.C:
334334
var err error
335-
stack, err = client.Stacks.Read(ctx, stackID, &StackReadOptions{
336-
Include: []StackIncludeOpt{StackIncludeLatestStackConfiguration},
337-
})
335+
stack, err = client.Stacks.Read(ctx, stackID)
338336
if err != nil {
339337
t.Fatalf("Failed to read stack %q: %s", stackID, err)
340338
}

0 commit comments

Comments
 (0)