forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_plugin.go
170 lines (163 loc) · 4.85 KB
/
test_plugin.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
package main
import (
"fmt"
"os"
"path/filepath"
"code.cloudfoundry.org/cli/plugin"
)
type Test1 struct {
}
func (c *Test1) Run(cliConnection plugin.CliConnection, args []string) {
switch args[0] {
case "CliCommandWithoutTerminalOutput":
result, _ := cliConnection.CliCommandWithoutTerminalOutput("target")
fmt.Println("Done CliCommandWithoutTerminalOutput:", result)
case "CliCommand":
result, _ := cliConnection.CliCommand("target")
fmt.Println("Done CliCommand:", result)
case "GetCurrentOrg":
result, _ := cliConnection.GetCurrentOrg()
fmt.Println("Done GetCurrentOrg:", result)
case "GetCurrentSpace":
result, _ := cliConnection.GetCurrentSpace()
fmt.Println("Done GetCurrentSpace:", result)
case "Username":
result, _ := cliConnection.Username()
fmt.Println("Done Username:", result)
case "UserGuid":
result, _ := cliConnection.UserGuid()
fmt.Println("Done UserGuid:", result)
case "UserEmail":
result, _ := cliConnection.UserEmail()
fmt.Println("Done UserEmail:", result)
case "IsLoggedIn":
result, _ := cliConnection.IsLoggedIn()
fmt.Println("Done IsLoggedIn:", result)
case "IsSSLDisabled":
result, err := cliConnection.IsSSLDisabled()
if err != nil {
fmt.Println("Error in IsSSLDisabled()", err)
}
fmt.Println("Done IsSSLDisabled:", result)
case "ApiEndpoint":
result, _ := cliConnection.ApiEndpoint()
fmt.Println("Done ApiEndpoint:", result)
case "ApiVersion":
result, _ := cliConnection.ApiVersion()
fmt.Println("Done ApiVersion:", result)
case "HasAPIEndpoint":
result, err := cliConnection.HasAPIEndpoint()
if err != nil {
fmt.Println("Error in HasAPIEndpoint()", err)
}
fmt.Println("Done HasAPIEndpoint:", result)
case "HasOrganization":
result, _ := cliConnection.HasOrganization()
fmt.Println("Done HasOrganization:", result)
case "HasSpace":
result, _ := cliConnection.HasSpace()
fmt.Println("Done HasSpace:", result)
case "LoggregatorEndpoint":
result, _ := cliConnection.LoggregatorEndpoint()
fmt.Println("Done LoggregatorEndpoint:", result)
case "DopplerEndpoint":
result, _ := cliConnection.DopplerEndpoint()
fmt.Println("Done DopplerEndpoint:", result)
case "AccessToken":
result, _ := cliConnection.AccessToken()
fmt.Println("Done AccessToken:", result)
case "GetApp":
result, _ := cliConnection.GetApp(args[1])
fmt.Println("Done GetApp:", result)
case "GetApps":
result, _ := cliConnection.GetApps()
fmt.Println("Done GetApps:", result)
case "GetOrg":
result, _ := cliConnection.GetOrg(args[1])
fmt.Println("Done GetOrg:", result)
case "GetOrgs":
result, _ := cliConnection.GetOrgs()
fmt.Println("Done GetOrgs:", result)
case "GetSpace":
result, _ := cliConnection.GetSpace(args[1])
fmt.Println("Done GetSpace:", result)
case "GetSpaces":
result, _ := cliConnection.GetSpaces()
fmt.Println("Done GetSpaces:", result)
case "GetOrgUsers":
result, _ := cliConnection.GetOrgUsers(args[1], args[2:]...)
fmt.Println("Done GetOrgUsers:", result)
case "GetSpaceUsers":
result, _ := cliConnection.GetSpaceUsers(args[1], args[2])
fmt.Println("Done GetSpaceUsers:", result)
case "GetServices":
result, _ := cliConnection.GetServices()
fmt.Println("Done GetServices:", result)
case "GetService":
result, _ := cliConnection.GetService(args[1])
fmt.Println("Done GetService:", result)
case "TestPluginCommandWithAlias", "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF":
fmt.Println("You called Test Plugin Command With Alias!")
}
}
func (c *Test1) GetMetadata() plugin.PluginMetadata {
return plugin.PluginMetadata{
Name: "CF-CLI-Integration-Test-Plugin",
Version: plugin.VersionType{
Major: 1,
Minor: 2,
Build: 4,
},
MinCliVersion: plugin.VersionType{
Major: 5,
Minor: 0,
Build: 0,
},
Commands: []plugin.Command{
{Name: "CliCommandWithoutTerminalOutput"},
{Name: "CliCommand"},
{Name: "GetCurrentSpace"},
{Name: "GetCurrentOrg"},
{Name: "Username"},
{Name: "UserGuid"},
{Name: "UserEmail"},
{Name: "IsLoggedIn"},
{Name: "IsSSLDisabled"},
{Name: "ApiEndpoint"},
{Name: "ApiVersion"},
{Name: "HasAPIEndpoint"},
{Name: "HasOrganization"},
{Name: "HasSpace"},
{Name: "LoggregatorEndpoint"},
{Name: "DopplerEndpoint"},
{Name: "AccessToken"},
{Name: "GetApp"},
{Name: "GetApps"},
{Name: "GetOrg"},
{Name: "GetOrgs"},
{Name: "GetSpace"},
{Name: "GetSpaces"},
{Name: "GetOrgUsers"},
{Name: "GetSpaceUsers"},
{Name: "GetServices"},
{Name: "GetService"},
{
Name: "TestPluginCommandWithAlias",
Alias: "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
HelpText: "This is my plugin help test. Banana.",
UsageDetails: plugin.Usage{
Usage: "I R Usage",
Options: map[string]string{
"--dis-flag": "is a flag",
},
},
},
},
}
}
func uninstalling() {
os.Remove(filepath.Join(os.TempDir(), "uninstall-test-file-for-test_1.exe"))
}
func main() {
plugin.Start(new(Test1))
}