Skip to content

Commit b1acc9b

Browse files
fixed unmarshalling and added options
1 parent f9254b8 commit b1acc9b

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

stack_configuration_summary.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
type StackConfigurationSummaries interface {
1010
// List lists all the stack configuration summaries for a stack.
11-
List(ctx context.Context, stackID string) (*StackConfigurationSummaryList, error)
11+
List(ctx context.Context, stackID string, options *StackConfigurationSummaryListOptions) (*StackConfigurationSummaryList, error)
1212
}
1313

1414
type stackConfigurationSummaries struct {
@@ -22,19 +22,27 @@ type StackConfigurationSummaryList struct {
2222
Items []*StackConfigurationSummary
2323
}
2424

25+
type StackConfigurationSummaryListOptions struct {
26+
ListOptions
27+
}
28+
2529
type StackConfigurationSummary struct {
26-
ID string
27-
Type string
28-
Status string
29-
SequenceNumber int
30+
ID string `jsonapi:"primary,stack-configuration-summaries"`
31+
Type string `jsonapi:"attr,type"`
32+
Status string `jsonapi:"attr,status"`
33+
SequenceNumber int `jsonapi:"attr,sequence-number"`
3034
}
3135

32-
func (s stackConfigurationSummaries) List(ctx context.Context, stackID string) (*StackConfigurationSummaryList, error) {
36+
func (s stackConfigurationSummaries) List(ctx context.Context, stackID string, options *StackConfigurationSummaryListOptions) (*StackConfigurationSummaryList, error) {
3337
if !validStringID(&stackID) {
3438
return nil, fmt.Errorf("invalid stack ID: %s", stackID)
3539
}
3640

37-
req, err := s.client.NewRequest("GET", fmt.Sprintf("stacks/%s/stack-configuration-summaries", url.PathEscape(stackID)), nil)
41+
if options == nil {
42+
options = &StackConfigurationSummaryListOptions{}
43+
}
44+
45+
req, err := s.client.NewRequest("GET", fmt.Sprintf("stacks/%s/stack-configuration-summaries", url.PathEscape(stackID)), options)
3846
if err != nil {
3947
return nil, err
4048
}

stack_configuration_summary_integration_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func TestStackConfigurationSummaryList(t *testing.T) {
2727
stack, err := client.Stacks.Create(ctx, StackCreateOptions{
2828
Name: "aa-test-stack",
2929
VCSRepo: &StackVCSRepoOptions{
30-
Identifier: "hwatkins05-hashicorp/pet-nulls-stack",
30+
Identifier: "hashicorp-guides/pet-nulls-stack",
3131
OAuthTokenID: oauthClient.OAuthTokens[0].ID,
3232
},
3333
Project: &Project{
@@ -39,7 +39,7 @@ func TestStackConfigurationSummaryList(t *testing.T) {
3939
stack2, err := client.Stacks.Create(ctx, StackCreateOptions{
4040
Name: "bb-test-stack",
4141
VCSRepo: &StackVCSRepoOptions{
42-
Identifier: "hwatkins05-hashicorp/pet-nulls-stack",
42+
Identifier: "hashicorp-guides/pet-nulls-stack",
4343
OAuthTokenID: oauthClient.OAuthTokens[0].ID,
4444
},
4545
Project: &Project{
@@ -59,21 +59,21 @@ func TestStackConfigurationSummaryList(t *testing.T) {
5959
require.NoError(t, err)
6060

6161
t.Run("Successful empty list", func(t *testing.T) {
62-
stackConfigSummaryList, err := client.StackConfigurationSummaries.List(ctx, stack.ID)
62+
stackConfigSummaryList, err := client.StackConfigurationSummaries.List(ctx, stack.ID, nil)
6363
require.NoError(t, err)
6464

6565
assert.Len(t, stackConfigSummaryList.Items, 0)
6666
})
6767

6868
t.Run("Successful multiple config summary list", func(t *testing.T) {
69-
stackConfigSummaryList, err := client.StackConfigurationSummaries.List(ctx, stack2.ID)
69+
stackConfigSummaryList, err := client.StackConfigurationSummaries.List(ctx, stack2.ID, nil)
7070
require.NoError(t, err)
7171

7272
assert.Len(t, stackConfigSummaryList.Items, 2)
7373
})
7474

7575
t.Run("Unsuccessful list", func(t *testing.T) {
76-
_, err := client.StackConfigurationSummaries.List(ctx, "")
76+
_, err := client.StackConfigurationSummaries.List(ctx, "", nil)
7777
require.Error(t, err)
7878
})
7979
}

0 commit comments

Comments
 (0)