-
Notifications
You must be signed in to change notification settings - Fork 329
Modify project destroy
to require -p
flag and delete projects created in UI without data source
#4212
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense! I have a few suggestions but otherwise I tested it out and works as expected 👍🏻
internal/cli/project_destroy.go
Outdated
if c.project == nil { | ||
c.ui.Output("The -project flag must be set.", terminal.WithErrorStyle()) | ||
if c.flagProject == "" { | ||
c.ui.Output("Must explicitly set -project (-p) flag to destroy project.", terminal.WithErrorStyle()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd reprint the help text here with c.Flags().Help()
.
c.ui.Output("Must explicitly set -project (-p) flag to destroy project.", terminal.WithErrorStyle()) | |
c.ui.Output("Must explicitly set -project (-p) flag to destroy project.\n%s", c.Flags().Help(), terminal.WithErrorStyle()) |
Something like that.
Then we should update the usage string to explicitly show that the flag is now required:
Usage waypoint project destroy -project=<project-name> [options]
...
...
_, err = c.project.DestroyProject(c.Ctx, &pb.Job_DestroyProjectOp{ | ||
Project: &pb.Ref_Project{Project: project.Project.Name}, | ||
SkipDestroyResources: c.skipDestroyResources, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This confused me at first - I wasn't sure what the difference was between these two DestroyProject
funcs. Maybe a quick doc comment note about how one is a client func that queues a DestroyProject operation, and the other is an API call to the server that deletes the projects record from the db with no job?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look great!
As the title suggests. :)
Previously,
waypoint project destroy
would ignore whatever arguments provided and attempt to destroy project in current directory. This enforces the use of the-project
or-p
flag regardless of where the command is called to resolve this bug, and for extra guardrails.This PR also introduces the ability to delete projects created in the UI without a data source or
waypoint.hcl
.