Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Modify project destroy to require -p flag and delete projects created in UI without data source #4212

Merged
merged 12 commits into from
Nov 29, 2022

Conversation

xiaolin-ninja
Copy link
Contributor

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.

Copy link
Member

@briancain briancain left a 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 👍🏻

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())
Copy link
Member

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().

Suggested change
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,
})
Copy link
Member

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?

Copy link
Member

@briancain briancain left a comment

Choose a reason for hiding this comment

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

Look great!

@xiaolin-ninja xiaolin-ninja added backport/0.10.x backport/website Automerge PR into stable-website branch after merge to main and removed backport/website Automerge PR into stable-website branch after merge to main labels Nov 29, 2022
@xiaolin-ninja xiaolin-ninja merged commit 0f5679e into main Nov 29, 2022
@xiaolin-ninja xiaolin-ninja deleted the project-destroy-fix branch November 29, 2022 22:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants