diff --git a/stack.go b/stack.go index d45956450..7cb95bd8b 100644 --- a/stack.go +++ b/stack.go @@ -75,6 +75,14 @@ type StackVCSRepo struct { OAuthTokenID string `jsonapi:"attr,oauth-token-id,omitempty"` } +// StackVCSRepoOptions +type StackVCSRepoOptions struct { + Identifier string `json:"identifier"` + Branch string `json:"branch,omitempty"` + GHAInstallationID string `json:"github-app-installation-id,omitempty"` + OAuthTokenID string `json:"oauth-token-id,omitempty"` +} + // Stack represents a stack. type Stack struct { ID string `jsonapi:"primary,stacks"` @@ -172,11 +180,11 @@ type StackReadOptions struct { // StackCreateOptions represents the options for creating a stack. The project // relation is required. type StackCreateOptions struct { - Type string `jsonapi:"primary,stacks"` - Name string `jsonapi:"attr,name"` - Description *string `jsonapi:"attr,description,omitempty"` - VCSRepo *StackVCSRepo `jsonapi:"attr,vcs-repo"` - Project *Project `jsonapi:"relation,project"` + Type string `jsonapi:"primary,stacks"` + Name string `jsonapi:"attr,name"` + Description *string `jsonapi:"attr,description,omitempty"` + VCSRepo *StackVCSRepoOptions `jsonapi:"attr,vcs-repo"` + Project *Project `jsonapi:"relation,project"` } // StackUpdateOptions represents the options for updating a stack. @@ -326,7 +334,7 @@ func (s StackCreateOptions) valid() error { return s.VCSRepo.valid() } -func (s StackVCSRepo) valid() error { +func (s StackVCSRepoOptions) valid() error { if s.Identifier == "" { return ErrRequiredVCSRepo } diff --git a/stack_integration_test.go b/stack_integration_test.go index 437120103..d8d82b554 100644 --- a/stack_integration_test.go +++ b/stack_integration_test.go @@ -31,7 +31,7 @@ func TestStackCreateAndList(t *testing.T) { stack1, err := client.Stacks.Create(ctx, StackCreateOptions{ Name: "aa-test-stack", - VCSRepo: &StackVCSRepo{ + VCSRepo: &StackVCSRepoOptions{ Identifier: "hashicorp-guides/pet-nulls-stack", OAuthTokenID: oauthClient.OAuthTokens[0].ID, }, @@ -45,7 +45,7 @@ func TestStackCreateAndList(t *testing.T) { stack2, err := client.Stacks.Create(ctx, StackCreateOptions{ Name: "zz-test-stack", - VCSRepo: &StackVCSRepo{ + VCSRepo: &StackVCSRepoOptions{ Identifier: "hashicorp-guides/pet-nulls-stack", OAuthTokenID: oauthClient.OAuthTokens[0].ID, }, @@ -143,7 +143,7 @@ func TestStackReadUpdateDelete(t *testing.T) { stack, err := client.Stacks.Create(ctx, StackCreateOptions{ Name: "test-stack", - VCSRepo: &StackVCSRepo{ + VCSRepo: &StackVCSRepoOptions{ Identifier: "brandonc/pet-nulls-stack", OAuthTokenID: oauthClient.OAuthTokens[0].ID, Branch: "main", @@ -200,7 +200,7 @@ func TestStackReadUpdateForceDelete(t *testing.T) { stack, err := client.Stacks.Create(ctx, StackCreateOptions{ Name: "test-stack", - VCSRepo: &StackVCSRepo{ + VCSRepo: &StackVCSRepoOptions{ Identifier: "brandonc/pet-nulls-stack", OAuthTokenID: oauthClient.OAuthTokens[0].ID, Branch: "main", @@ -356,7 +356,7 @@ func TestStackConverged(t *testing.T) { stack, err := client.Stacks.Create(ctx, StackCreateOptions{ Name: "test-stack", - VCSRepo: &StackVCSRepo{ + VCSRepo: &StackVCSRepoOptions{ Identifier: "brandonc/pet-nulls-stack", OAuthTokenID: oauthClient.OAuthTokens[0].ID, }, diff --git a/stack_plan_integration_test.go b/stack_plan_integration_test.go index ea5bbe834..29ae34a8a 100644 --- a/stack_plan_integration_test.go +++ b/stack_plan_integration_test.go @@ -29,7 +29,7 @@ func TestStackPlanList(t *testing.T) { stack, err := client.Stacks.Create(ctx, StackCreateOptions{ Name: "aa-test-stack", - VCSRepo: &StackVCSRepo{ + VCSRepo: &StackVCSRepoOptions{ Identifier: "brandonc/pet-nulls-stack", OAuthTokenID: oauthClient.OAuthTokens[0].ID, }, diff --git a/stack_source_integration_test.go b/stack_source_integration_test.go index fafaaa617..ab00fc8f2 100644 --- a/stack_source_integration_test.go +++ b/stack_source_integration_test.go @@ -26,7 +26,7 @@ func TestStackSourceCreateUploadAndRead(t *testing.T) { stack, err := client.Stacks.Create(ctx, StackCreateOptions{ Project: orgTest.DefaultProject, Name: "test-stack", - VCSRepo: &StackVCSRepo{ + VCSRepo: &StackVCSRepoOptions{ Identifier: "hashicorp-guides/pet-nulls-stack", OAuthTokenID: oauthClient.OAuthTokens[0].ID, },