Add abra app remove command #43
No reviewers
Labels
No Label
bug
build
ci/cd
contributing
design
documentation
duplicate
enhancement
help wanted
invalid
meta
question
security
wontfix
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: coop-cloud/abra#43
Loading…
Reference in New Issue
No description provided.
Delete Branch "knoflook:dev"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When ran with no flags, it removes the env file and lets you choose which secrets to remove. If you add --volumes, it also lets you choose which volumes should be removed.
If you only specify --force, the env file and all secrets will be removed
If you specify --force --volumes, the volumes will also be removed.
Nice one! Buncha comments, hope it is not overwhelming 🙈
Can we have it remove env file, secrets and volumes?
Thanks 🚀
(hmu on matrix if anything is unclear)
@ -17,1 +28,4 @@
var Force bool
var ForceFlag = &cli.BoolFlag{
This is a general flag we'll add to other sub-commands, it can live in cli/internal/common.go?
@ -23,0 +42,4 @@
ForceFlag,
},
Action: func(c *cli.Context) error {
// Check if app name was provided by user
We haven't discussed this but the existing convention that I see is that we don't add comments to code to explain what it is doing unless it is doing something strange or difficult. Otherwise, we comment to explain why we're doing something (context, not what it is doing).
The issue is, that when the code changes, you might forget to change the comment and then the next person might be caught reading the comment which describes code that doesn'te exist anymore. I would say have a look around the rest of the codebase at comment usage and perhaps remove the obvious ones in this function.
For example the
// we have to map the names to ID's
comment is a good one, I'd keep that.@ -23,0 +43,4 @@
},
Action: func(c *cli.Context) error {
// Check if app name was provided by user
AppName := c.Args().First()
appName
(e.g. host)@ -23,0 +51,4 @@
if !Force {
response := false
prompt := &survey.Confirm{
Message: "About to delete " + AppName + ", are you sure?",
Message: fmt.Sprintf("About to delete %s, are you sure?", appName)
@ -23,0 +54,4 @@
Message: "About to delete " + AppName + ", are you sure?",
}
survey.AskOne(prompt, &response)
if response == false {
@ -23,0 +59,4 @@
}
}
// Get app list
AppFiles, err := config.LoadAppFiles("")
appFiles, err := config.LoadAppFiles()
Can't do it that way, if you remove "" LoadAppFiles returns an empty map[]
@ -23,0 +61,4 @@
// Get app list
AppFiles, err := config.LoadAppFiles("")
if err != nil {
return err
logrus.Fatal(err)
@ -23,0 +63,4 @@
if err != nil {
return err
}
AppPath := AppFiles[AppName].Path
appPath := AppFiles[appName].Path
@ -23,0 +73,4 @@
}
// Remove the file
err = os.Remove(AppPath)
if err != nil {
@ -23,0 +84,4 @@
fs.Add("name", AppName)
SecretList, err := cl.SecretList(ctx, types.SecretListOptions{Filters: fs})
if err != nil {
return err
logrus.Fatal(err)
@ -23,0 +108,4 @@
// Actually remove the secrets
for _, name := range SecretNamesToRemove {
// DEBUG: SecretIDsToRemove = append(SecretIDsToRemove, Secrets[name])
Let's remove that 🙃
@ -23,0 +110,4 @@
for _, name := range SecretNamesToRemove {
// DEBUG: SecretIDsToRemove = append(SecretIDsToRemove, Secrets[name])
err := cl.SecretRemove(ctx, Secrets[name])
if err != nil {
@ -23,0 +121,4 @@
VolumeListOKBody, err := cl.VolumeList(ctx, fs)
VolumeList := VolumeListOKBody.Volumes
if err != nil {
return err
logrus.Fatal(err)
@ -23,0 +128,4 @@
Vols = append(Vols, vol.Name)
}
// Remove the volumes if desired
if Volumes == true {
if Volumes {
Lol accidentally clicked that approve button but anyway, you get the idea 🙈
In the image: discussion about
--force
behaviour without--volumes
specifiedMerged in
6732edf8db
🥳(some
git rebase
-foo which we can co-work on figuring out next time)Also took a pass in
36af302d5f
to drop some "dangling else" stuff, down to chat about that also.Thanks so much for this!
Pull request closed