diff --git a/changelog/pending/20221220--cli-plugin--fix-check-of-executable-bits-on-windows.yaml b/changelog/pending/20221220--cli-plugin--fix-check-of-executable-bits-on-windows.yaml new file mode 100644 index 000000000000..2440b7a6bd4e --- /dev/null +++ b/changelog/pending/20221220--cli-plugin--fix-check-of-executable-bits-on-windows.yaml @@ -0,0 +1,4 @@ +changes: +- type: fix + scope: cli/plugin + description: Fix check of executable bits on Windows. diff --git a/pkg/cmd/pulumi/package.go b/pkg/cmd/pulumi/package.go index e229d3f5a72b..8218b50febf9 100644 --- a/pkg/cmd/pulumi/package.go +++ b/pkg/cmd/pulumi/package.go @@ -20,6 +20,7 @@ import ( "io/fs" "os" "path/filepath" + "runtime" "strings" "github.com/blang/semver" @@ -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() } diff --git a/pkg/cmd/pulumi/plugin_install.go b/pkg/cmd/pulumi/plugin_install.go index 0ac39e0aa03f..b205d51dbe3e 100644 --- a/pkg/cmd/pulumi/plugin_install.go +++ b/pkg/cmd/pulumi/plugin_install.go @@ -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