Skip to content

Commit

Permalink
Fix executable checks for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Frassle committed Dec 20, 2022
1 parent 36b0c2f commit d601314
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
@@ -0,0 +1,4 @@
changes:
- type: fix
scope: cli/plugin
description: Fix check of executable bits on Windows.
5 changes: 5 additions & 0 deletions pkg/cmd/pulumi/package.go
Expand Up @@ -20,6 +20,7 @@ import (
"io/fs"
"os"
"path/filepath"
"runtime"
"strings"

"github.com/blang/semver"
Expand Down Expand Up @@ -109,6 +110,10 @@ func schemaFromSchemaSource(packageSource string) (*schema.Package, error) {
}

isExecutable := func(info fs.FileInfo) bool {
// Windows doesn't have executable bits to check
if runtime.GOOS == "windows" {
return !info.IsDir()
}
return info.Mode()&0111 != 0 && !info.IsDir()
}

Expand Down
7 changes: 6 additions & 1 deletion pkg/cmd/pulumi/plugin_install.go
Expand Up @@ -233,7 +233,12 @@ func getFilePayload(file string, spec workspace.PluginSpec) (workspace.PluginCon
return nil, fmt.Errorf("seeking back in file %s: %w", source, err)
}
if !encoding.IsCompressed(compressHeader) {
if (stat.Mode() & 0100) == 0 {
// Windows doesn't have executable bits to check
if runtime.GOOS == "windows" {
if info.IsDir() {
return nil, fmt.Errorf("%s is not executable", source)
}
} else if (stat.Mode() & 0100) == 0 || info.IsDir() { {
return nil, fmt.Errorf("%s is not executable", source)
}
return workspace.SingleFilePlugin(f, spec), nil
Expand Down

0 comments on commit d601314

Please sign in to comment.