/
delete_app.go
52 lines (46 loc) · 1.51 KB
/
delete_app.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package commands
import (
"log"
"github.com/Skarlso/go-furnace/config"
"github.com/Skarlso/go-furnace/utils"
"github.com/Yitsushi/go-commander"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/codedeploy"
"github.com/fatih/color"
)
// DeleteApp command.
type DeleteApp struct {
}
// Execute defines what this command does.
func (c *DeleteApp) Execute(opts *commander.CommandHelper) {
appName := opts.Arg(0)
if len(appName) < 1 {
appName = config.STACKNAME
}
sess := session.New(&aws.Config{Region: aws.String(config.REGION)})
cdClient := codedeploy.New(sess, nil)
client := CDClient{cdClient}
deleteApplication(appName, &client)
}
func deleteApplication(appName string, client *CDClient) {
var yellow = color.New(color.FgYellow).SprintFunc()
log.Println("Deleting: ", yellow(appName))
_, err := client.Client.DeleteApplication(&codedeploy.DeleteApplicationInput{
ApplicationName: aws.String(appName),
})
utils.CheckError(err)
}
// NewDeleteApp Creates a new DeleteApp command.
func NewDeleteApp(appName string) *commander.CommandWrapper {
return &commander.CommandWrapper{
Handler: &DeleteApp{},
Help: &commander.CommandDescriptor{
Name: "delete-application",
ShortDescription: "Deletes an Application",
LongDescription: `Deletes a CodeDeploy Application complete with DeploymenyGroup and Deploys.`,
Arguments: "name",
Examples: []string{"delete-application", "delete-application CustomApplicationName"},
},
}
}