7
7
"sort"
8
8
"strings"
9
9
10
+ "code.cloudfoundry.org/cli/actor/actionerror"
10
11
"code.cloudfoundry.org/cli/api/plugin"
11
12
"code.cloudfoundry.org/cli/util/configv3"
12
13
"code.cloudfoundry.org/cli/util/generic"
@@ -26,29 +27,6 @@ type CommandList interface {
26
27
HasAlias (string ) bool
27
28
}
28
29
29
- // PluginInvalidError is returned with a plugin is invalid because it is
30
- // missing a name or has 0 commands.
31
- type PluginInvalidError struct {
32
- Err error
33
- }
34
-
35
- func (PluginInvalidError ) Error () string {
36
- return "File is not a valid cf CLI plugin binary."
37
- }
38
-
39
- // PluginCommandConflictError is returned when a plugin command name conflicts
40
- // with a core or existing plugin command name.
41
- type PluginCommandsConflictError struct {
42
- PluginName string
43
- PluginVersion string
44
- CommandAliases []string
45
- CommandNames []string
46
- }
47
-
48
- func (PluginCommandsConflictError ) Error () string {
49
- return ""
50
- }
51
-
52
30
// CreateExecutableCopy makes a temporary copy of a plugin binary and makes it
53
31
// executable.
54
32
//
@@ -80,8 +58,8 @@ func (actor Actor) CreateExecutableCopy(path string, tempPluginDir string) (stri
80
58
return executablePath , nil
81
59
}
82
60
83
- // DownloadBinaryFromURL fetches a plugin binary from the specified URL, if
84
- // it exists.
61
+ // DownloadExecutableBinaryFromURL fetches a plugin binary from the specified
62
+ // URL, if it exists.
85
63
func (actor Actor ) DownloadExecutableBinaryFromURL (pluginURL string , tempPluginDir string , proxyReader plugin.ProxyReader ) (string , error ) {
86
64
tempFile , err := makeTempFile (tempPluginDir )
87
65
if err != nil {
@@ -106,7 +84,7 @@ func (actor Actor) FileExists(path string) bool {
106
84
func (actor Actor ) GetAndValidatePlugin (pluginMetadata PluginMetadata , commandList CommandList , path string ) (configv3.Plugin , error ) {
107
85
plugin , err := pluginMetadata .GetMetadata (path )
108
86
if err != nil || plugin .Name == "" || len (plugin .Commands ) == 0 {
109
- return configv3.Plugin {}, PluginInvalidError {Err : err }
87
+ return configv3.Plugin {}, actionerror. PluginInvalidError {Err : err }
110
88
}
111
89
112
90
installedPlugins := actor .config .Plugins ()
@@ -152,7 +130,7 @@ func (actor Actor) GetAndValidatePlugin(pluginMetadata PluginMetadata, commandLi
152
130
return strings .ToLower (conflictingAliases [i ]) < strings .ToLower (conflictingAliases [j ])
153
131
})
154
132
155
- return configv3.Plugin {}, PluginCommandsConflictError {
133
+ return configv3.Plugin {}, actionerror. PluginCommandsConflictError {
156
134
PluginName : plugin .Name ,
157
135
PluginVersion : plugin .Version .String (),
158
136
CommandNames : conflictingNames ,
0 commit comments