Skip to content

Commit 7892937

Browse files
committed
Get Logic changes and Describe verbose suppress
1 parent df8af16 commit 7892937

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

pkg/commands/kvstoreentry/describe.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ func NewDescribeCommand(parent argparser.Registerer, g *global.Data) *DescribeCo
2525
c := DescribeCommand{
2626
Base: argparser.Base{
2727
Globals: g,
28+
// This argument suppresses the 'Fastly API' output from the global verbose command.
29+
SuppressVerbose: true,
2830
},
2931
}
3032
c.CmdClause = parent.Command("describe", "Get the associated attributes of a key")
@@ -64,11 +66,8 @@ func (c *DescribeCommand) Exec(_ io.Reader, out io.Writer) error {
6466
}
6567

6668
if c.Globals.Flags.Verbose {
67-
// Print the key attributes.
68-
fmt.Fprintf(out, "Key: %s\n", c.Input.Key)
69-
fmt.Fprintf(out, "Generation: %d\n", item.Generation)
70-
fmt.Fprintf(out, "Metadata: %s\n", item.Metadata)
71-
return nil
69+
// We won't be supporting a --verbose flag here as there wouldn't be any additional output to provide.
70+
return fmt.Errorf("the 'describe' command does not support the --verbose flag")
7271
}
7372

7473
// IMPORTANT: Don't use `text` package as binary data can be messed up.

pkg/commands/kvstoreentry/get.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ func (c *GetCommand) Exec(_ io.Reader, out io.Writer) error {
6767
// Check if the generation marker provided matches the API.
6868
if c.Generation != "" {
6969
inputGeneration, err := strconv.ParseUint(c.Generation, 10, 64)
70-
if err != nil {
71-
return fmt.Errorf("invalid generation value: %s", c.Generation)
72-
}
73-
7470
if inputGeneration != result.Generation {
7571
return fmt.Errorf("generation value does not match: expected %d, got %d", result.Generation, inputGeneration)
7672
}
73+
74+
if err != nil {
75+
return fmt.Errorf("invalid generation value: %s", c.Generation)
76+
}
7777
}
7878

7979
// Ensure we close the value reader.
@@ -93,7 +93,7 @@ func (c *GetCommand) Exec(_ io.Reader, out io.Writer) error {
9393
}
9494

9595
if c.JSONOutput.Enabled {
96-
// We are encoding the value of the key here to ensure safe
96+
// We are encoding the value of the item here to ensure safe
9797
// output for binary content along with other outputs.
9898
encodedValue := base64.StdEncoding.EncodeToString([]byte(value))
9999
text.Output(out, `{"%s": "%s"}`, c.Input.Key, encodedValue)

0 commit comments

Comments
 (0)