This repository has been archived by the owner on Jan 21, 2022. It is now read-only.
/
v3.go
211 lines (204 loc) · 5.39 KB
/
v3.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
package main
import (
"fmt"
"code.cloudfoundry.org/cli/plugin"
"github.com/cloudfoundry/v3-cli-plugin/commands"
)
type V3Plugin struct {
}
func main() {
plugin.Start(new(V3Plugin))
}
func (v3plugin *V3Plugin) Run(cliConnection plugin.CliConnection, args []string) {
if args[0] == "v3-push" {
commands.Push(cliConnection, args)
} else if args[0] == "v3-apps" {
if len(args) == 1 {
commands.Apps(cliConnection, args)
} else {
fmt.Printf("Wrong number of argument, type `cf %s -h` for help\n", args[0])
}
} else if args[0] == "v3-processes" {
if len(args) == 1 {
commands.Processes(cliConnection, args)
} else {
fmt.Printf("Wrong number of argument, type `cf %s -h` for help\n", args[0])
}
} else if args[0] == "v3-delete" {
if len(args) == 2 {
commands.Delete(cliConnection, args)
} else {
fmt.Printf("Wrong number of argument, type `cf %s -h` for help\n", args[0])
}
} else if args[0] == "v3-logs" {
if len(args) == 2 {
commands.Logs(cliConnection, args)
} else {
fmt.Printf("Wrong number of argument, type `cf %s -h` for help\n", args[0])
}
} else if args[0] == "v3-tasks" {
if len(args) == 2 {
commands.Tasks(cliConnection, args)
} else {
fmt.Printf("Wrong number of argument, type `cf %s -h` for help\n", args[0])
}
} else if args[0] == "v3-run-task" {
if len(args) == 4 {
commands.RunTask(cliConnection, args)
} else {
fmt.Printf("Wrong number of argument, type `cf %s -h` for help\n", args[0])
}
} else if args[0] == "v3-cancel-task" {
if len(args) == 3 {
commands.CancelTask(cliConnection, args)
} else {
fmt.Printf("Wrong number of argument, type `cf %s -h` for help\n", args[0])
}
} else if args[0] == "v3-bind-service" {
if len(args) >= 3 {
commands.BindService(cliConnection, args)
} else {
fmt.Printf("Wrong number of argument, type `cf %s -h` for help\n", args[0])
}
} else if args[0] == "v3-create-iso-seg" {
if len(args) == 2 {
commands.CreateIsolationSegment(cliConnection, args)
} else {
fmt.Printf("Wrong number of argument, type `cf %s -h` for help\n", args[0])
}
} else if args[0] == "v3-assign-iso-seg" {
if len(args) == 3 {
commands.AssignIsolationSegment(cliConnection, args)
} else {
fmt.Printf("Wrong number of argument, type `cf %s -h` for help\n", args[0])
}
} else if args[0] == "v3-unassign-iso-seg" {
if len(args) == 3 {
commands.UnassignIsolationSegment(cliConnection, args)
} else {
fmt.Printf("Wrong number of argument, type `cf %s -h` for help\n", args[0])
}
}
}
func (v3plugin *V3Plugin) GetMetadata() plugin.PluginMetadata {
return plugin.PluginMetadata{
Name: "v3_beta",
Version: plugin.VersionType{
Major: 0,
Minor: 7,
Build: 4,
},
Commands: []plugin.Command{
{
Name: "v3-push",
Alias: "v3-p",
HelpText: "pushes current dir as a v3 process",
UsageDetails: plugin.Usage{
Usage: "v3-push APPNAME",
Options: map[string]string{
"p": "path to dir or zip to push",
"b": "custom buildpack by name or Git URL",
"di": "path to docker image to push",
},
},
},
{
Name: "v3-apps",
Alias: "v3-a",
HelpText: "displays all v3 apps",
UsageDetails: plugin.Usage{
Usage: "v3-apps",
Options: map[string]string{},
},
},
{
Name: "v3-processes",
Alias: "",
HelpText: "displays all v3 processes",
UsageDetails: plugin.Usage{
Usage: "v3-processes",
Options: map[string]string{},
},
},
{
Name: "v3-delete",
Alias: "v3-d",
HelpText: "delete a v3 app",
UsageDetails: plugin.Usage{
Usage: "v3-delete APPNAME",
Options: map[string]string{},
},
},
{
Name: "v3-logs",
Alias: "",
HelpText: "tail logs for a v3 app",
UsageDetails: plugin.Usage{
Usage: "v3-logs APPNAME",
Options: map[string]string{},
},
},
{
Name: "v3-tasks",
Alias: "v3-t",
HelpText: "list tasks for a v3 app",
UsageDetails: plugin.Usage{
Usage: "v3-tasks APPNAME",
Options: map[string]string{},
},
},
{
Name: "v3-bind-service",
Alias: "v3-bs",
HelpText: "bind a service instance to a v3 app",
UsageDetails: plugin.Usage{
Usage: "v3-bind-service APPNAME SERVICEINSTANCE",
Options: map[string]string{
"c": "parameters as json",
},
},
},
{
Name: "v3-run-task",
Alias: "v3-rt",
HelpText: "run a task on a v3 app",
UsageDetails: plugin.Usage{
Usage: "v3-run-task APPNAME TASKNAME COMMAND",
Options: map[string]string{},
},
},
{
Name: "v3-cancel-task",
Alias: "v3-ct",
HelpText: "cancel a task on a v3 app",
UsageDetails: plugin.Usage{
Usage: "v3-cancel-task APPNAME TASKNAME",
},
},
{
Name: "v3-create-iso-seg",
Alias: "v3-cis",
HelpText: "create an isolation segment",
UsageDetails: plugin.Usage{
Usage: "v3-create-iso-seg ISOSEGNAME",
},
},
{
Name: "v3-assign-iso-seg",
Alias: "v3-ais",
HelpText: "assign an isolation segment to an organization",
UsageDetails: plugin.Usage{
Usage: "v3-assign-iso-seg ORGNAME ISOSEGNAME",
},
},
{
Name: "v3-unassign-iso-seg",
Alias: "v3-uis",
HelpText: "unassign an isolation segment from an organization",
UsageDetails: plugin.Usage{
Usage: "v3-unassign-iso-seg ORGNAME ISOSEGNAME",
},
},
},
}
}