forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_plugin_fails_uninstall.go
59 lines (49 loc) · 1.3 KB
/
test_plugin_fails_uninstall.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
package main
import (
"fmt"
"os"
"path/filepath"
"strings"
"code.cloudfoundry.org/cli/plugin"
"github.com/blang/semver"
)
var (
pluginName string
commands string
commandHelps string
commandAliases string
version string
)
type ConfigurablePluginFailsUninstall struct{}
func (_ *ConfigurablePluginFailsUninstall) Run(cliConnection plugin.CliConnection, args []string) {
fmt.Fprintf(os.Stderr, "I'm failing...I'm failing...\n")
os.Exit(1)
}
func (_ *ConfigurablePluginFailsUninstall) GetMetadata() plugin.PluginMetadata {
v1, _ := semver.Make(version)
metadata := plugin.PluginMetadata{
Name: pluginName,
Version: plugin.VersionType{
Major: int(v1.Major),
Minor: int(v1.Minor),
Build: int(v1.Patch),
},
}
pluginCommandsList := strings.Split(commands, ",")
pluginHelpsList := strings.Split(commandHelps, ",")
pluginAliasesList := strings.Split(commandAliases, ",")
for i, _ := range pluginCommandsList {
metadata.Commands = append(metadata.Commands, plugin.Command{
Alias: pluginAliasesList[i],
Name: pluginCommandsList[i],
HelpText: pluginHelpsList[i],
})
}
return metadata
}
func uninstalling() {
os.Remove(filepath.Join(os.TempDir(), "uninstall-test-file-for-test_1.exe"))
}
func main() {
plugin.Start(new(ConfigurablePluginFailsUninstall))
}