Skip to content

Commit ed9a086

Browse files
joeshawkpfleming
andauthored
feat(object-storage): improve access-keys list output (#1513)
First, rename the `list-access-keys` command to just `list` (while maintaining an alias for compatibility) to match convention and eliminate stuttering. If there are no bucket limitations, print "all" instead of "[]", which could be misleading. All Submissions: * [x] Have you followed the guidelines in our Contributing document? * [x] Have you checked to ensure there aren't other open [Pull Requests](https://github.com/fastly/cli/pulls) for the same update/change? <!-- You can erase any parts of this template not applicable to your Pull Request. --> ### New Feature Submissions: * [x] Does your submission pass tests? --------- Co-authored-by: Kevin P. Fleming <kpfleming@users.noreply.github.com>
1 parent 42514e3 commit ed9a086

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
### Enhancements:
88
- feat(vcl): Allow showing of generated VCL for a service version [#1498](https://github.com/fastly/cli/pull/1498)
99
- Add experimental "enable Pushpin" mode ([#1509](https://github.com/fastly/cli/pull/1509))
10+
- feat(object-storage): improve access-keys list output ([#1513](https://github.com/fastly/cli/pull/1513))
1011

1112
### Bug fixes:
1213

pkg/commands/objectstorage/accesskeys/accesskeys_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ func TestAccessKeysList(t *testing.T) {
223223
SecretKey: "baz",
224224
Description: "bizz",
225225
Permission: akPermission,
226+
Buckets: []string{"b1", "b2"},
226227
},
227228
},
228229
Meta: accesskeys.MetaAccessKeys{},
@@ -303,8 +304,8 @@ Created (UTC): 2021-06-15 23:00
303304

304305
var listAccessKeysString = strings.TrimSpace(`
305306
ID Secret Description Permssion Buckets Created At
306-
foo bar bat read-only-objects [] 0001-01-01 00:00:00 +0000 UTC
307-
foobar baz bizz read-only-objects [] 0001-01-01 00:00:00 +0000 UTC
307+
foo bar bat read-only-objects all 0001-01-01 00:00:00 +0000 UTC
308+
foobar baz bizz read-only-objects [b1 b2] 0001-01-01 00:00:00 +0000 UTC
308309
`) + "\n"
309310

310311
var zeroListAccessKeysString = strings.TrimSpace(`

pkg/commands/objectstorage/accesskeys/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func NewListCommand(parent argparser.Registerer, g *global.Data) *ListCommand {
2828
},
2929
}
3030

31-
c.CmdClause = parent.Command("list-access-keys", "List all access keys")
31+
c.CmdClause = parent.Command("list", "List all access keys").Alias("list-access-keys")
3232

3333
// Optional.
3434
c.RegisterFlagBool(c.JSONFlag())

pkg/text/accesskey.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,15 @@ func PrintAccessKeyTbl(out io.Writer, accessKeys []accesskeys.AccessKey) {
3131
for _, accessKey := range accessKeys {
3232
// avoid gosec loop aliasing check :/
3333
accessKey := accessKey
34-
tbl.AddLine(accessKey.AccessKeyID, accessKey.SecretKey, accessKey.Description, accessKey.Permission, accessKey.Buckets, accessKey.CreatedAt)
34+
var buckets string
35+
if len(accessKey.Buckets) == 0 {
36+
// No limitations on buckets
37+
buckets = "all"
38+
} else {
39+
buckets = fmt.Sprintf("%v", accessKey.Buckets)
40+
}
41+
42+
tbl.AddLine(accessKey.AccessKeyID, accessKey.SecretKey, accessKey.Description, accessKey.Permission, buckets, accessKey.CreatedAt)
3543
}
3644
tbl.Print()
3745
}

0 commit comments

Comments
 (0)