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

Reimplement a common delete tink-cli command #425

Closed
gianarb opened this issue Jan 27, 2021 · 0 comments · Fixed by #433
Closed

Reimplement a common delete tink-cli command #425

gianarb opened this issue Jan 27, 2021 · 0 comments · Fixed by #433
Assignees

Comments

@gianarb
Copy link
Contributor

gianarb commented Jan 27, 2021

Same as we did for the get command #406 another one that we can migrate is the delete one.

Requirements:

  1. Deprecate the current one with the right Cobra.Command flag as we did for the get command and use the same environment variable (if I remember well TINK_CLI_VERSION=0.0.0 to fall back to the old command)
  2. The Delete command should be only one inside a new cmd/tink-cli/command/delete package and it should follow the same structure we have for get, and I mean Options if necessary for example
  3. Tests, tests, tests
  4. UX: tink hardware|template|... delete <id1> <id2> <id3>
  5. output: we do not need --format, let's print a line for every deleted ID, if an ID fails or does not exists print:
Error\t<id>\tnot found

In this way, the output can be parsed with awk for example.
6. The exit code is different than 0 (success) only if the client is not able to connect to the server otherwise it is a success (even if 2 out of 2 IDs do not exists or can't be deleted (like docker does))


Example:

template in the database:
* ID=1
* ID=23

# this should fail with exist code != 0 because at least 1 argument is required
$ tink template delete 
# this succeed with exit code 0 if the server is up, even if the specified ID do not exists
$ tink template delete 1243 34 12
Error    1234    not found
Error    34    not found
Error    12 not found
# this succeed with exit code 0 if the server is up and it prints the id of the deleted resource
$ tink template delete 1 12
1
Error    12 not found

Yayyy

@mergify mergify bot closed this as completed in #433 Feb 9, 2021
mergify bot added a commit that referenced this issue Feb 9, 2021
## Description

```
# Delete template resource (success)
tink template delete 8ae1cc24-6a9c-11eb-a0fc-0242ac120005
Deleted 8ae1cc24-6a9c-11eb-a0fc-0242ac120005
                                                                            
# Delete template resource (not found)                                     
tink template delete 8ae1cc24-6a9c-11eb-a0fc-0242ac120005
Error   8ae1cc24-6a9c-11eb-a0fc-0242ac120005    not found
                                                                     
# Delete template resources (one not found)                                 
tink template delete 8ae1cc24-6a9c-11eb-a0fc-0242ac120005 e4115856-4358-429d-a8f6-9e1b7d794b72
Deleted 8ae1cc24-6a9c-11eb-a0fc-0242ac120005                                               
Error   e4115856-4358-429d-a8f6-9e1b7d794b72    not found                                  
                                                                                            
# Delete resources and exract resource ID with awk                                         
tink template delete 8ae1cc24-6a9c-11eb-a0fc-0242ac120005 e4115856-4358-429d-a8f6-9e1b7d794b72 | awk {print $2} > result
cat result                                                                                                           
8ae1cc24-6a9c-11eb-a0fc-0242ac120005                                                                                 
e4115856-4358-429d-a8f6-9e1b7d794b72         
```

## Why is this needed

Fixes: #425 

## How Has This Been Tested?

- Manual testing
- Unit tests

## Checklist:

I have:

- [x] updated the documentation and/or roadmap (if required)
- [x] added unit or e2e tests
- [ ] provided instructions on how to upgrade
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants