From 2deed1cf044fb6fb7f4047b8f5a9b6eb8104bd7a Mon Sep 17 00:00:00 2001 From: Fraser Waters Date: Tue, 20 Dec 2022 08:18:30 +0000 Subject: [PATCH] Fix executable checks for windows --- ...-cli-plugin--fix-check-of-executable-bits-on-windows.yaml | 4 ++++ pkg/cmd/pulumi/package.go | 5 +++++ pkg/cmd/pulumi/plugin_install.go | 3 ++- 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 changelog/pending/20221220--cli-plugin--fix-check-of-executable-bits-on-windows.yaml 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..57f00382628e 100644 --- a/pkg/cmd/pulumi/plugin_install.go +++ b/pkg/cmd/pulumi/plugin_install.go @@ -233,7 +233,8 @@ 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" && (stat.Mode() & 0100) == 0 { return nil, fmt.Errorf("%s is not executable", source) } return workspace.SingleFilePlugin(f, spec), nil