forked from toolshed/abra
		
	
		
			
				
	
	
		
			62 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			62 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package app
 | |
| 
 | |
| import (
 | |
| 	"context"
 | |
| 
 | |
| 	"coopcloud.tech/abra/cli/internal"
 | |
| 	"coopcloud.tech/abra/pkg/autocomplete"
 | |
| 	"coopcloud.tech/abra/pkg/client"
 | |
| 	stack "coopcloud.tech/abra/pkg/upstream/stack"
 | |
| 	"github.com/sirupsen/logrus"
 | |
| 	"github.com/urfave/cli"
 | |
| )
 | |
| 
 | |
| var appUndeployCommand = cli.Command{
 | |
| 	Name:      "undeploy",
 | |
| 	Aliases:   []string{"un"},
 | |
| 	ArgsUsage: "<domain>",
 | |
| 	Flags: []cli.Flag{
 | |
| 		internal.DebugFlag,
 | |
| 		internal.NoInputFlag,
 | |
| 	},
 | |
| 	Before: internal.SubCommandBefore,
 | |
| 	Usage:  "Undeploy an app",
 | |
| 	Description: `
 | |
| This does not destroy any of the application data. However, you should remain
 | |
| vigilant, as your swarm installation will consider any previously attached
 | |
| volumes as eligiblef or pruning once undeployed.
 | |
| `,
 | |
| 	Action: func(c *cli.Context) error {
 | |
| 		app := internal.ValidateApp(c)
 | |
| 		stackName := app.StackName()
 | |
| 
 | |
| 		cl, err := client.New(app.Server)
 | |
| 		if err != nil {
 | |
| 			logrus.Fatal(err)
 | |
| 		}
 | |
| 
 | |
| 		logrus.Debugf("checking whether %s is already deployed", stackName)
 | |
| 
 | |
| 		isDeployed, deployedVersion, err := stack.IsDeployed(context.Background(), cl, stackName)
 | |
| 		if err != nil {
 | |
| 			logrus.Fatal(err)
 | |
| 		}
 | |
| 
 | |
| 		if !isDeployed {
 | |
| 			logrus.Fatalf("%s is not deployed?", app.Name)
 | |
| 		}
 | |
| 
 | |
| 		if err := internal.DeployOverview(app, deployedVersion, "continue with undeploy?"); err != nil {
 | |
| 			logrus.Fatal(err)
 | |
| 		}
 | |
| 
 | |
| 		rmOpts := stack.Remove{Namespaces: []string{app.StackName()}}
 | |
| 		if err := stack.RunRemove(context.Background(), cl, rmOpts); err != nil {
 | |
| 			logrus.Fatal(err)
 | |
| 		}
 | |
| 
 | |
| 		return nil
 | |
| 	},
 | |
| 	BashComplete: autocomplete.AppNameComplete,
 | |
| }
 |