ref: 79803b98b551ad1d924594263038bc901f684233 cisco/csc/cmd/instance/destroy.go -rw-r--r-- 547 bytes View raw
                                                                                
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
package instance

import (
	"cisco/csc/cmd"
	"cisco/sdk"
	"fmt"
	"github.com/spf13/cobra"
)

var instanceDestroy = &cobra.Command{
	Use:   "destroy",
	Short: "Destroy an instance",
	Args:  cobra.ExactArgs(1),
	Run: func(cmd *cobra.Command, args []string) {
		name := args[0]

		err := cisco.StopInstance(name)
		if err != nil {
			fmt.Printf("Error: %s\n", err.Error())
		}

		err = cisco.DeleteInstance(name)

		if err != nil {
			fmt.Printf("Error: %s\n", err.Error())
		}
	},
}

func init() {
	cmd.InstanceRootCmd.AddCommand(instanceDestroy)
}