Skip to content

Commit

Permalink
Support retrieving a secret store by name
Browse files Browse the repository at this point in the history
  • Loading branch information
fgsch committed Nov 15, 2023
1 parent 02b60d7 commit 25555c8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fastly/secret_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ type ListSecretStoresInput struct {
Cursor string
// Limit is the desired number of Secret Stores (optional).
Limit int
// Name is the name of the secret store (optional).
Name string
}

// ListSecretStores retrieves all resources.
Expand All @@ -108,6 +110,9 @@ func (c *Client) ListSecretStores(i *ListSecretStoresInput) (*SecretStores, erro
if i.Cursor != "" {
params["cursor"] = i.Cursor
}
if i.Name != "" {
params["name"] = i.Name
}

resp, err := c.Get(p, &RequestOptions{
Params: params,
Expand Down
11 changes: 11 additions & 0 deletions fastly/secret_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@ func TestClient_ListSecretStores(t *testing.T) {
if got, want := list.Meta.NextCursor, ""; got != want {
t.Errorf("Meta.NextCursor: got %q, want %q", got, want)
}

record(t, fmt.Sprintf("secret_store/%s/list-with-name", t.Name()), func(c *Client) {
list, err = c.ListSecretStores(&ListSecretStoresInput{Name: stores[0].Name})
})
if err != nil {
t.Fatalf("error listing secret store by name: %v", err)
}

if got, want := len(list.Data), 1; got != want {
t.Fatalf("Data: got length %d, want %d", got, want)
}
}

func TestClient_GetSecretStore(t *testing.T) {
Expand Down

0 comments on commit 25555c8

Please sign in to comment.