@@ -107,14 +107,24 @@ func (c *Config) providerOverride(provider proto.Provider) (string, string) {
107107 }
108108}
109109
110+ // pluginBinaryName returns the binary filename for the given plugin name,
111+ // appending .exe on Windows where executables require the extension.
112+ func pluginBinaryName (name string ) string {
113+ if runtime .GOOS == "windows" {
114+ return name + ".exe"
115+ }
116+ return name
117+ }
118+
110119func (c * Config ) Ensure (plugin , wantVersion string ) (string , error ) {
111120 logging .Debugf ("ensuring plugin %q is available" , plugin )
112121
113122 platform := runtime .GOOS + "_" + runtime .GOARCH
123+ binaryName := pluginBinaryName (plugin )
114124
115125 if len (wantVersion ) > 0 {
116126 // The user has requested a specific version.
117- want := filepath .Join (c .Cache , plugin , platform , wantVersion , plugin )
127+ want := filepath .Join (c .Cache , plugin , platform , wantVersion , binaryName )
118128 if _ , err := os .Stat (want ); err == nil {
119129 return want , nil
120130 }
@@ -123,7 +133,7 @@ func (c *Config) Ensure(plugin, wantVersion string) (string, error) {
123133 // When auto-update is disabled and the user hasn't picked a specific version, use the latest cached version if
124134 // available.
125135 if len (wantVersion ) == 0 && ! c .AutoUpdate {
126- matches , _ := filepath .Glob (filepath .Join (c .Cache , plugin , platform , "*" , plugin ))
136+ matches , _ := filepath .Glob (filepath .Join (c .Cache , plugin , platform , "*" , binaryName ))
127137 if len (matches ) > 0 {
128138 sort .Slice (matches , func (i , j int ) bool {
129139 vi := "v" + filepath .Base (filepath .Dir (matches [i ]))
@@ -162,7 +172,7 @@ func (c *Config) Ensure(plugin, wantVersion string) (string, error) {
162172 return "" , fmt .Errorf ("plugin %q version %q has no artifact for %s" , plugin , wantVersion , platform )
163173 }
164174
165- binaryPath := filepath .Join (c .Cache , plugin , platform , wantVersion , plugin )
175+ binaryPath := filepath .Join (c .Cache , plugin , platform , wantVersion , binaryName )
166176
167177 if _ , err := os .Stat (binaryPath ); err == nil {
168178 logging .Debugf ("plugin %q already cached at %s" , plugin , binaryPath )
@@ -188,7 +198,7 @@ func (c *Config) Ensure(plugin, wantVersion string) (string, error) {
188198 case strings .HasSuffix (artifact .Name , ".tar.gz" ):
189199 err = unpackTarGz (archivePath , tmpBinary , plugin )
190200 case strings .HasSuffix (artifact .Name , ".zip" ):
191- err = unpackZip (archivePath , tmpBinary , plugin + ".exe" )
201+ err = unpackZip (archivePath , tmpBinary , binaryName )
192202 default :
193203 err = fmt .Errorf ("unsupported archive format for %s" , artifact .Name )
194204 }
0 commit comments