Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add --consistency flag to kv-store-entry list command #1058

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ require (
)

require (
github.com/fastly/go-fastly/v8 v8.6.3
github.com/fastly/go-fastly/v8 v8.6.4
github.com/kennygrant/sanitize v1.2.4
github.com/mholt/archiver v3.1.1+incompatible
github.com/otiai10/copy v1.14.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5/go.mod h1:qssHWj6
github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY=
github.com/dustinkirkland/golang-petname v0.0.0-20191129215211-8e5a1ed0cff0 h1:90Ly+6UfUypEF6vvvW5rQIv9opIL8CbmW9FT20LDQoY=
github.com/dustinkirkland/golang-petname v0.0.0-20191129215211-8e5a1ed0cff0/go.mod h1:V+Qd57rJe8gd4eiGzZyg4h54VLHmYVVw54iMnlAMrF8=
github.com/fastly/go-fastly/v8 v8.6.3 h1:tzi0fbV63TjCcvx0kzr30NX4ZyuURj5LE7BB5+NDOXU=
github.com/fastly/go-fastly/v8 v8.6.3/go.mod h1:sC3WMOjQxwXk+gRI68ooTJJsI+/6AMA/4JLvrhNgpVk=
github.com/fastly/go-fastly/v8 v8.6.4 h1:/jf1j8VwpXDR+b7PA6RBhBcRo3OoEWFwFHFeOba7pk8=
github.com/fastly/go-fastly/v8 v8.6.4/go.mod h1:sC3WMOjQxwXk+gRI68ooTJJsI+/6AMA/4JLvrhNgpVk=
github.com/fastly/kingpin v2.1.12-0.20191105091915-95d230a53780+incompatible h1:FhrXlfhgGCS+uc6YwyiFUt04alnjpoX7vgDKJxS6Qbk=
github.com/fastly/kingpin v2.1.12-0.20191105091915-95d230a53780+incompatible/go.mod h1:U8UynVoU1SQaqD2I4ZqgYd5lx3A1ipQYn4aSt2Y5h6c=
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
Expand Down
1 change: 1 addition & 0 deletions pkg/app/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ var UsageTemplateFuncs = template.FuncMap{
var globalFlags = map[string]bool{
"accept-defaults": true,
"auto-yes": true,
"debug-mode": true,
"help": true,
"non-interactive": true,
"profile": true,
Expand Down
19 changes: 17 additions & 2 deletions pkg/commands/kvstoreentry/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@ type ListCommand struct {
cmd.Base
cmd.JSONOutput

manifest manifest.Data
Input fastly.ListKVStoreKeysInput
consistency string
manifest manifest.Data
Input fastly.ListKVStoreKeysInput
}

// ConsistencyOptions is a list of allowed consistency values.
var ConsistencyOptions = []string{
"eventual",
"strong",
}

// NewListCommand returns a usable command registered under the parent.
Expand All @@ -37,6 +44,7 @@ func NewListCommand(parent cmd.Registerer, g *global.Data, m manifest.Data) *Lis
c.CmdClause.Flag("store-id", "Store ID").Short('s').Required().StringVar(&c.Input.ID)

// Optional.
c.CmdClause.Flag("consistency", "Determines accuracy of results. i.e. 'eventual' uses caching to improve performance").Default("strong").HintOptions(ConsistencyOptions...).EnumVar(&c.consistency, ConsistencyOptions...)
c.RegisterFlagBool(c.JSONFlag()) // --json
return &c
}
Expand Down Expand Up @@ -70,6 +78,13 @@ func (c *ListCommand) Exec(_ io.Reader, out io.Writer) error {
spinner.Message(msg + "... (this can take a few minutes depending on the number of entries)")
}

switch c.consistency {
case "eventual":
c.Input.Consistency = fastly.ConsistencyEventual
case "strong":
c.Input.Consistency = fastly.ConsistencyStrong
}

for {
o, err := c.Globals.APIClient.ListKVStoreKeys(&c.Input)
if err != nil {
Expand Down