Skip to content

Commit 149adb7

Browse files
stacks: add options to create stack source request
1 parent bd1cdb9 commit 149adb7

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

stack_source.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type StackSources interface {
1919

2020
// CreateAndUpload packages and uploads the specified Terraform Stacks
2121
// configuration files in association with a Stack.
22-
CreateAndUpload(ctx context.Context, stackID string, path string) (*StackSource, error)
22+
CreateAndUpload(ctx context.Context, stackID string, path string, opts *CreateStackSourceOptions) (*StackSource, error)
2323

2424
// UploadTarGzip is used to upload Terraform configuration files contained a tar gzip archive.
2525
// Any stream implementing io.Reader can be passed into this method. This method is also
@@ -30,6 +30,10 @@ type StackSources interface {
3030
UploadTarGzip(ctx context.Context, uploadURL string, archive io.Reader) error
3131
}
3232

33+
type CreateStackSourceOptions struct {
34+
SelectedDeployments []string `jsonapi:"attr,selected-deployments,omitempty"`
35+
}
36+
3337
var _ StackSources = (*stackSources)(nil)
3438

3539
type stackSources struct {
@@ -63,9 +67,12 @@ func (s *stackSources) Read(ctx context.Context, stackSourceID string) (*StackSo
6367

6468
// CreateAndUpload packages and uploads the specified Terraform Stacks
6569
// configuration files in association with a Stack.
66-
func (s *stackSources) CreateAndUpload(ctx context.Context, stackID, path string) (*StackSource, error) {
70+
func (s *stackSources) CreateAndUpload(ctx context.Context, stackID, path string, opts *CreateStackSourceOptions) (*StackSource, error) {
71+
if opts == nil {
72+
opts = &CreateStackSourceOptions{}
73+
}
6774
u := fmt.Sprintf("stacks/%s/stack-sources", url.PathEscape(stackID))
68-
req, err := s.client.NewRequest("POST", u, nil)
75+
req, err := s.client.NewRequest("POST", u, opts)
6976
if err != nil {
7077
return nil, err
7178
}

stack_source_integration_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ func TestStackSourceCreateUploadAndRead(t *testing.T) {
3333
})
3434
require.NoError(t, err)
3535

36-
ss, err := client.StackSources.CreateAndUpload(ctx, stack.ID, "test-fixtures/stack-source")
36+
ss, err := client.StackSources.CreateAndUpload(ctx, stack.ID, "test-fixtures/stack-source", &CreateStackSourceOptions{
37+
SelectedDeployments: []string{"simple"},
38+
})
3739
require.NoError(t, err)
3840
require.NotNil(t, ss)
3941
require.Nil(t, ss.StackConfiguration)

0 commit comments

Comments
 (0)