This repository has been archived by the owner on Jan 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
main.go
107 lines (94 loc) · 2.95 KB
/
main.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package main
import (
"fmt"
"os"
"github.com/cloudfoundry-incubator/diego-enabler/commands"
"github.com/cloudfoundry-incubator/diego-enabler/ui"
"github.com/cloudfoundry/cli/plugin"
"github.com/jessevdk/go-flags"
)
type DiegoEnabler struct{}
func (c *DiegoEnabler) GetMetadata() plugin.PluginMetadata {
return plugin.PluginMetadata{
Name: "Diego-Enabler",
Version: plugin.VersionType{
Major: 1,
Minor: 2,
Build: 4,
},
Commands: []plugin.Command{
{
Name: "enable-diego",
HelpText: "Migrate app to the Diego runtime",
UsageDetails: plugin.Usage{
Usage: `cf enable-diego APP_NAME
WARNING:
Migration of a running app causes a restart. Stopped apps will be configured to run on the target runtime but are not started.`,
},
},
{
Name: "disable-diego",
HelpText: "Migrate app to the DEA runtime",
UsageDetails: plugin.Usage{
Usage: `cf disable-diego APP_NAME
WARNING:
Migration of a running app causes a restart. Stopped apps will be configured to run on the target runtime but are not started.`,
},
},
{
Name: "has-diego-enabled",
HelpText: "Report whether an app is configured to run on the Diego runtime",
UsageDetails: plugin.Usage{
Usage: "cf has-diego-enabled APP_NAME",
},
},
{
Name: "diego-apps",
HelpText: "Lists all apps running on the Diego runtime that are visible to the user",
UsageDetails: plugin.Usage{
Usage: `cf diego-apps [-o ORG | -s SPACE]
OPTIONS:
-o Organization to restrict the app migration to,
-s Space in the targeted organization to limit results to`,
},
},
{
Name: "dea-apps",
HelpText: "Lists all apps running on the DEA runtime that are visible to the user",
UsageDetails: plugin.Usage{
Usage: `cf dea-apps [-o ORG | -s SPACE]
OPTIONS:
-o Organization to restrict the app migration to,
-s Space in the targeted organization to limit results to`,
},
},
{
Name: "migrate-apps",
HelpText: "Migrate all apps to Diego/DEA",
UsageDetails: plugin.Usage{
Usage: `cf migrate-apps (diego | dea) [-o ORG | -s SPACE] [-p MAX_IN_FLIGHT]
WARNING:
Migration of a running app causes a restart. Stopped apps will be configured to run on the target runtime but are not started.
OPTIONS:
-o Organization to restrict the app migration to
-s Space in the targeted organization to restrict the app migration to
-p Maximum number of apps to migrate in parallel (Default: 1, maximum: 100)`,
},
},
},
}
}
func main() {
plugin.Start(new(DiegoEnabler))
}
func (c *DiegoEnabler) Run(cliConnection plugin.CliConnection, args []string) {
commands.DiegoEnabler.CLIConnection = cliConnection
parser := flags.NewParser(&commands.DiegoEnabler, flags.HelpFlag|flags.PassDoubleDash)
parser.NamespaceDelimiter = "-"
_, err := parser.ParseArgs(args)
if err != nil {
ui.SayFailed()
fmt.Printf("Error: %s\n", err.Error())
os.Exit(1)
}
}