-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontext-route-plugin.go
More file actions
99 lines (92 loc) · 2.45 KB
/
context-route-plugin.go
File metadata and controls
99 lines (92 loc) · 2.45 KB
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
package main
import (
"fmt"
"github.com/cloudfoundry/cli/plugin"
"github.com/zrob/context-route-plugin/commands"
)
type ContextRoutePlugin struct {
}
func main() {
plugin.Start(new(ContextRoutePlugin))
}
func (crPlugin *ContextRoutePlugin) Run(cliConnection plugin.CliConnection, args []string) {
if args[0] == "create-context-route" {
if len(args) == 5 {
commands.CreateContextRoute(cliConnection, args)
} else {
fmt.Println(crPlugin.GetMetadata().Commands[0].UsageDetails.Usage)
}
} else if args[0] == "map-context-route" {
if len(args) == 5 {
commands.MapContextRoute(cliConnection, args)
} else {
fmt.Println(crPlugin.GetMetadata().Commands[1].UsageDetails.Usage)
}
} else if args[0] == "unmap-context-route" {
if len(args) == 5 {
commands.UnmapContextRoute(cliConnection, args)
} else {
fmt.Println(crPlugin.GetMetadata().Commands[2].UsageDetails.Usage)
}
} else if args[0] == "delete-context-route" {
if len(args) == 4 {
commands.DeleteContextRoute(cliConnection, args)
} else {
fmt.Println(crPlugin.GetMetadata().Commands[3].UsageDetails.Usage)
}
} else if args[0] == "list-context-routes" {
commands.ListContextRoutes(cliConnection, args)
}
}
func (crPlugin *ContextRoutePlugin) GetMetadata() plugin.PluginMetadata {
return plugin.PluginMetadata{
Name: "context-route-plugin",
Version: plugin.VersionType{
Major: 0,
Minor: 1,
Build: 0,
},
Commands: []plugin.Command{
{
Name: "create-context-route",
Alias: "ccr",
HelpText: "creates a route with a path",
UsageDetails: plugin.Usage{
Usage: "create-context-route SPACE DOMAIN HOSTNAME PATH",
},
},
{
Name: "map-context-route",
Alias: "mcr",
HelpText: "maps a context route to an app",
UsageDetails: plugin.Usage{
Usage: "map-context-route APP DOMAIN HOSTNAME PATH",
},
},
{
Name: "unmap-context-route",
Alias: "ucr",
HelpText: "unmaps a context route from an app",
UsageDetails: plugin.Usage{
Usage: "unmap-context-route APP DOMAIN HOSTNAME PATH",
},
},
{
Name: "delete-context-route",
Alias: "dcr",
HelpText: "deletes a context route",
UsageDetails: plugin.Usage{
Usage: "delete-context-route DOMAIN HOSTNAME PATH",
},
},
{
Name: "list-context-routes",
Alias: "lcr",
HelpText: "lists context routes",
UsageDetails: plugin.Usage{
Usage: "list-context-routes",
},
},
},
}
}