From 83df34a39ff96be79dad6a0387cc855676c1d031 Mon Sep 17 00:00:00 2001 From: Mukul Date: Sun, 19 Jul 2026 11:21:21 +0530 Subject: [PATCH 1/2] Fix test compilation on Windows in plugin installer package syscall.Umask does not exist on Windows, so 'go vet ./...' and 'go test ./internal/plugin/installer/' fail to compile there: internal\plugin\installer\http_installer_test.go:212:26: undefined: syscall.Umask Move the umask lookup behind build-tag-guarded helpers (umask_unix_test.go / umask_windows_test.go) and skip the POSIX permission assertions on Windows, where file modes are not honored. TestExtract itself still runs on Windows to cover the extraction path handling. Verified with 'go vet' and 'go test' on windows/amd64, plus GOOS=linux and GOOS=darwin 'go vet' cross-checks. Signed-off-by: Mukul --- .../plugin/installer/http_installer_test.go | 16 +++++----- internal/plugin/installer/umask_unix_test.go | 31 +++++++++++++++++++ .../plugin/installer/umask_windows_test.go | 28 +++++++++++++++++ 3 files changed, 68 insertions(+), 7 deletions(-) create mode 100644 internal/plugin/installer/umask_unix_test.go create mode 100644 internal/plugin/installer/umask_windows_test.go diff --git a/internal/plugin/installer/http_installer_test.go b/internal/plugin/installer/http_installer_test.go index df8385ed6..a802fa666 100644 --- a/internal/plugin/installer/http_installer_test.go +++ b/internal/plugin/installer/http_installer_test.go @@ -29,7 +29,6 @@ import ( "path/filepath" "strconv" "strings" - "syscall" "testing" "github.com/stretchr/testify/assert" @@ -167,8 +166,7 @@ func TestExtract(t *testing.T) { tempDir := t.TempDir() // Get current umask to predict expected permissions - currentUmask := syscall.Umask(0) - syscall.Umask(currentUmask) + currentUmask := processUmask() // Write a tarball to a buffer for us to extract var tarbuf bytes.Buffer @@ -226,8 +224,10 @@ func TestExtract(t *testing.T) { require.NotErrorIs(t, err, fs.ErrNotExist, "Expected %s to exist but doesn't", pluginYAMLFullPath) } require.NoError(t, err) - require.Equalf(t, expectedPluginYAMLPerm, info.Mode().Perm(), "Expected %s to have %o mode but has %o (umask: %o)", - pluginYAMLFullPath, expectedPluginYAMLPerm, info.Mode().Perm(), currentUmask) + if posixPermsSupported { + require.Equalf(t, expectedPluginYAMLPerm, info.Mode().Perm(), "Expected %s to have %o mode but has %o (umask: %o)", + pluginYAMLFullPath, expectedPluginYAMLPerm, info.Mode().Perm(), currentUmask) + } readmeFullPath := filepath.Join(tempDir, "README.md") info, err = os.Stat(readmeFullPath) @@ -235,8 +235,10 @@ func TestExtract(t *testing.T) { require.NotErrorIs(t, err, fs.ErrNotExist, "Expected %s to exist but doesn't", readmeFullPath) } require.NoError(t, err) - require.Equalf(t, expectedReadmePerm, info.Mode().Perm(), "Expected %s to have %o mode but has %o (umask: %o)", - readmeFullPath, expectedReadmePerm, info.Mode().Perm(), currentUmask) + if posixPermsSupported { + require.Equalf(t, expectedReadmePerm, info.Mode().Perm(), "Expected %s to have %o mode but has %o (umask: %o)", + readmeFullPath, expectedReadmePerm, info.Mode().Perm(), currentUmask) + } } func TestCleanJoin(t *testing.T) { diff --git a/internal/plugin/installer/umask_unix_test.go b/internal/plugin/installer/umask_unix_test.go new file mode 100644 index 000000000..ab97e0504 --- /dev/null +++ b/internal/plugin/installer/umask_unix_test.go @@ -0,0 +1,31 @@ +/* +Copyright The Helm Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +//go:build !windows + +package installer + +import "syscall" + +// posixPermsSupported reports whether the platform honors POSIX file +// permission bits, allowing tests to assert on extracted file modes. +const posixPermsSupported = true + +// processUmask returns the current process umask without changing it. +func processUmask() int { + umask := syscall.Umask(0) + syscall.Umask(umask) + return umask +} diff --git a/internal/plugin/installer/umask_windows_test.go b/internal/plugin/installer/umask_windows_test.go new file mode 100644 index 000000000..a03f3f499 --- /dev/null +++ b/internal/plugin/installer/umask_windows_test.go @@ -0,0 +1,28 @@ +/* +Copyright The Helm Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +//go:build windows + +package installer + +// posixPermsSupported reports whether the platform honors POSIX file +// permission bits, allowing tests to assert on extracted file modes. +// Windows does not, so permission assertions are skipped there. +const posixPermsSupported = false + +// processUmask returns 0 on Windows, which has no umask concept. +func processUmask() int { + return 0 +} From aa857abe02d39085b7bf770cb8d2cc69ef1621bd Mon Sep 17 00:00:00 2001 From: Mukul Date: Sat, 8 Aug 2026 10:04:25 +0530 Subject: [PATCH 2/2] Move build constraints above the license header gofmt -s wants the //go:build line first in the file, and the rest of the repo follows that layout (see internal/fileutil/fileutil_unix.go). Without this the golangci-lint job fails on the formatter check. Signed-off-by: Mukul --- internal/plugin/installer/umask_unix_test.go | 4 ++-- internal/plugin/installer/umask_windows_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/plugin/installer/umask_unix_test.go b/internal/plugin/installer/umask_unix_test.go index ab97e0504..632509028 100644 --- a/internal/plugin/installer/umask_unix_test.go +++ b/internal/plugin/installer/umask_unix_test.go @@ -1,3 +1,5 @@ +//go:build !windows + /* Copyright The Helm Authors. Licensed under the Apache License, Version 2.0 (the "License"); @@ -13,8 +15,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -//go:build !windows - package installer import "syscall" diff --git a/internal/plugin/installer/umask_windows_test.go b/internal/plugin/installer/umask_windows_test.go index a03f3f499..fd60c0191 100644 --- a/internal/plugin/installer/umask_windows_test.go +++ b/internal/plugin/installer/umask_windows_test.go @@ -1,3 +1,5 @@ +//go:build windows + /* Copyright The Helm Authors. Licensed under the Apache License, Version 2.0 (the "License"); @@ -13,8 +15,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -//go:build windows - package installer // posixPermsSupported reports whether the platform honors POSIX file