Skip to content

Commit

Permalink
tink-cli: Ensure opt.RetrieveData is non-nil before invoking
Browse files Browse the repository at this point in the history
Otherwise we get a nice panic.

Signed-off-by: Manuel Mendez <github@i.m.mmlb.dev>
  • Loading branch information
mmlb committed May 4, 2022
1 parent a6e76fb commit 15fb537
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/tink-cli/cmd/get/get.go
Expand Up @@ -67,6 +67,9 @@ func NewGetCommand(opt Options) *cobra.Command {
if len(args) != 0 {
data, err = retrieveMulti(cmd.Context(), opt, client, args)
} else {
if opt.RetrieveData == nil {
return errors.New("get-all-data is not implemented for this resource yet, please have a look at the issue in GitHub or open a new one")
}
data, err = opt.RetrieveData(cmd.Context(), client)
}
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions cmd/tink-cli/cmd/get/get_test.go
Expand Up @@ -214,6 +214,10 @@ func TestNewGetCommand(t *testing.T) {
},
},
},
{
Name: "no opts",
ExpectError: errors.New("get-all-data is not implemented for this resource yet, please have a look at the issue in GitHub or open a new one"),
},
}

for _, s := range tests {
Expand Down

0 comments on commit 15fb537

Please sign in to comment.