mirror of https://github.com/helm/helm
Guard newBase() in internal/plugin/installer/base.go against an empty
HELM_PLUGINS value: filepath.SplitList('') returns []string{}, so the
previous [0] indexing would panic. Use the raw value as fallback when
the split result is empty.
Remove the now-unused settings field from OCIInstaller: after the prior
fix that switched Path() to use i.base.PluginsDirectory, the field was
never read. Drop it from the struct, NewOCIInstaller, and update the
test accordingly.
Fix two pre-existing test portability problems on Windows:
- http_installer_test.go uses syscall.Umask which does not exist on
Windows; guard the file with //go:build !windows and move the shared
mockArchiveServer helper to testhelper_test.go so installer_test.go
keeps compiling on all platforms.
- TestOCIInstaller_Install_ComponentExtraction checks Unix execute bits
(mode & 0111) which are always zero on Windows; skip that assertion
on Windows via runtime.GOOS.
Also make TestPath cross-platform by using filepath.FromSlash and
filepath.Join for expected paths instead of hard-coded Unix strings.
Fixes https://github.com/helm/helm/issues/11310
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Arnav Nagzirkar <113314200+arnavnagzirkar@users.noreply.github.com>
pull/32242/head
parent
25fd5d503a
commit
a085bab5a5
@ -0,0 +1,35 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
package installer // import "helm.sh/helm/v4/internal/plugin/installer"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func mockArchiveServer() *httptest.Server {
|
||||
return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if !strings.HasSuffix(r.URL.Path, ".tar.gz") {
|
||||
w.Header().Add("Content-Type", "text/html")
|
||||
fmt.Fprintln(w, "broken")
|
||||
return
|
||||
}
|
||||
w.Header().Add("Content-Type", "application/gzip")
|
||||
fmt.Fprintln(w, "test")
|
||||
}))
|
||||
}
|
||||
Loading…
Reference in new issue