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

CLI: implement delete cmd #330

Merged
merged 4 commits into from
Mar 23, 2022
Merged

CLI: implement delete cmd #330

merged 4 commits into from
Mar 23, 2022

Conversation

Nexucis
Copy link
Member

@Nexucis Nexucis commented Mar 8, 2022

This PR is proposing a way to delete resources with the CLI. I'm printing here the help from the command, hoping it will help to understand how it is supposed to work and to describe this PR :).

This PR should be merged after #326 because it contains the code to manage file and stdin required for this command.

./bin/percli delete --help

JSON and YAML formats are accepted.

If both a filename and command line arguments are passed, the command line arguments are used and the filename is
ignored.

Note that the delete command does NOT do resource version checks, so if someone submits an update to a resource right
when you submit a delete, their update will be lost along with the rest of the resource.

Usage:
  percli delete (-f [FILENAME] | TYPE ([NAME1 NAME2] | --all)) [flags]

Examples:

# Delete any kind of resources from a file
percli delete -f data.json

# Delete any kind of resources from stdin
percli data.json | percli delete -f -

# Delete a specific dashboard
percli delete dashboards node_exporter cadvisor

# Delete all dashboards
percli delete dashboards --all


Flags:
  -a, --all              Delete all resources in the project of the specified resource types.
  -f, --file string      Path to the file that contains the resources to delete
  -h, --help             help for delete
  -p, --project string   If present, the project scope for this CLI request

Global Flags:
      --log.level string      Set the log verbosity level. Possible values: panic, fatal, error, warning, info, debug, trace (default "info")
      --percliconfig string   Path to the percliconfig file to use for CLI requests. (default "/Users/ahusson/.perses/config.json")

@Nexucis Nexucis force-pushed the nexucis/cli-delete branch from ecb95bc to 9acc85e Compare March 8, 2022 09:58
@Nexucis Nexucis mentioned this pull request Mar 11, 2022
Nexucis added 2 commits March 23, 2022 11:46
Signed-off-by: Augustin Husson <husson.augustin@gmail.com>
Signed-off-by: Augustin Husson <husson.augustin@gmail.com>
@Nexucis Nexucis force-pushed the nexucis/cli-delete branch from 9a257d1 to 62e196e Compare March 23, 2022 10:48
Signed-off-by: Augustin Husson <husson.augustin@gmail.com>
Copy link
Contributor

@AntoineThebaud AntoineThebaud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just spotted few typos in some tests titles

ExpectedMessage: `resource "whatever" not managed`,
},
{
Title: "not connected to anyAPI",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any API

ExpectedMessage: "you are not connected to any API",
},
{
Title: "delete all project",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

projects

`,
},
{
Title: "delete multiples different resources from a file",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

multiple resources

Signed-off-by: Augustin Husson <husson.augustin@gmail.com>
@Nexucis
Copy link
Member Author

Nexucis commented Mar 23, 2022

cool, thanks @AntoineThebaud !

@Nexucis Nexucis merged commit 0e7d747 into main Mar 23, 2022
@Nexucis Nexucis deleted the nexucis/cli-delete branch March 23, 2022 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants