Merge branch 'helm:main' into main

pull/31068/head
蔡秀吉 2 months ago committed by GitHub
commit bbbe037edb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -5,7 +5,7 @@
[![GoDoc](https://img.shields.io/static/v1?label=godoc&message=reference&color=blue)](https://pkg.go.dev/helm.sh/helm/v4) [![GoDoc](https://img.shields.io/static/v1?label=godoc&message=reference&color=blue)](https://pkg.go.dev/helm.sh/helm/v4)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/3131/badge)](https://bestpractices.coreinfrastructure.org/projects/3131) [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/3131/badge)](https://bestpractices.coreinfrastructure.org/projects/3131)
[![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/helm/helm/badge)](https://scorecard.dev/viewer/?uri=github.com/helm/helm) [![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/helm/helm/badge)](https://scorecard.dev/viewer/?uri=github.com/helm/helm)
[![LFX Health Score](https://img.shields.io/static/v1?label=Health%20Score&message=Healthy&color=A7F3D0&logo=linuxfoundation&logoColor=white&style=flat)](https://insights.linuxfoundation.org/project/helm) [![LFX Health Score](https://insights.production.lfx.dev/api/badge/health-score?project=helm)](https://insights.linuxfoundation.org/project/helm)
Helm is a tool for managing Charts. Charts are packages of pre-configured Kubernetes resources. Helm is a tool for managing Charts. Charts are packages of pre-configured Kubernetes resources.

@ -746,6 +746,25 @@ OUTER:
return nil return nil
} }
func portOrDefault(u *url.URL) string {
if p := u.Port(); p != "" {
return p
}
switch u.Scheme {
case "http":
return "80"
case "https":
return "443"
default:
return ""
}
}
func urlEqual(u1, u2 *url.URL) bool {
return u1.Scheme == u2.Scheme && u1.Hostname() == u2.Hostname() && portOrDefault(u1) == portOrDefault(u2)
}
// LocateChart looks for a chart directory in known places, and returns either the full path or an error. // LocateChart looks for a chart directory in known places, and returns either the full path or an error.
// //
// This does not ensure that the chart is well-formed; only that the requested filename exists. // This does not ensure that the chart is well-formed; only that the requested filename exists.
@ -833,7 +852,7 @@ func (c *ChartPathOptions) LocateChart(name string, settings *cli.EnvSettings) (
// Host on URL (returned from url.Parse) contains the port if present. // Host on URL (returned from url.Parse) contains the port if present.
// This check ensures credentials are not passed between different // This check ensures credentials are not passed between different
// services on different ports. // services on different ports.
if c.PassCredentialsAll || (u1.Scheme == u2.Scheme && u1.Host == u2.Host) { if c.PassCredentialsAll || urlEqual(u1, u2) {
dl.Options = append(dl.Options, getter.WithBasicAuth(c.Username, c.Password)) dl.Options = append(dl.Options, getter.WithBasicAuth(c.Username, c.Password))
} else { } else {
dl.Options = append(dl.Options, getter.WithBasicAuth("", "")) dl.Options = append(dl.Options, getter.WithBasicAuth("", ""))

@ -24,6 +24,7 @@ import (
"io" "io"
"io/fs" "io/fs"
"net/http" "net/http"
"net/url"
"os" "os"
"path/filepath" "path/filepath"
"regexp" "regexp"
@ -933,3 +934,68 @@ func TestInstallWithSystemLabels(t *testing.T) {
is.Equal(fmt.Errorf("user supplied labels contains system reserved label name. System labels: %+v", driver.GetSystemLabels()), err) is.Equal(fmt.Errorf("user supplied labels contains system reserved label name. System labels: %+v", driver.GetSystemLabels()), err)
} }
func TestUrlEqual(t *testing.T) {
is := assert.New(t)
tests := []struct {
name string
url1 string
url2 string
expected bool
}{
{
name: "identical URLs",
url1: "https://example.com:443",
url2: "https://example.com:443",
expected: true,
},
{
name: "same host, scheme, default HTTPS port vs explicit",
url1: "https://example.com",
url2: "https://example.com:443",
expected: true,
},
{
name: "same host, scheme, default HTTP port vs explicit",
url1: "http://example.com",
url2: "http://example.com:80",
expected: true,
},
{
name: "different schemes",
url1: "http://example.com",
url2: "https://example.com",
expected: false,
},
{
name: "different hosts",
url1: "https://example.com",
url2: "https://www.example.com",
expected: false,
},
{
name: "different ports",
url1: "https://example.com:8080",
url2: "https://example.com:9090",
expected: false,
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
u1, err := url.Parse(tc.url1)
if err != nil {
t.Fatalf("Failed to parse URL1 %s: %v", tc.url1, err)
}
u2, err := url.Parse(tc.url2)
if err != nil {
t.Fatalf("Failed to parse URL2 %s: %v", tc.url2, err)
}
is.Equal(tc.expected, urlEqual(u1, u2))
})
}
}

@ -38,7 +38,7 @@ func processDependencyConditions(reqs []*chart.Dependency, cvals Values, cpath s
return return
} }
for _, r := range reqs { for _, r := range reqs {
for _, c := range strings.Split(strings.TrimSpace(r.Condition), ",") { for c := range strings.SplitSeq(strings.TrimSpace(r.Condition), ",") {
if len(c) > 0 { if len(c) > 0 {
// retrieve value // retrieve value
vv, err := cvals.PathValue(cpath + c) vv, err := cvals.PathValue(cpath + c)

@ -350,7 +350,7 @@ func pluginDynamicComp(plug *plugin.Plugin, cmd *cobra.Command, args []string, t
} }
var completions []string var completions []string
for _, comp := range strings.Split(buf.String(), "\n") { for comp := range strings.SplitSeq(buf.String(), "\n") {
// Remove any empty lines // Remove any empty lines
if len(comp) > 0 { if len(comp) > 0 {
completions = append(completions, comp) completions = append(completions, comp)

@ -132,12 +132,6 @@ type Metadata struct {
// Downloaders field is used if the plugin supply downloader mechanism // Downloaders field is used if the plugin supply downloader mechanism
// for special protocols. // for special protocols.
Downloaders []Downloaders `json:"downloaders"` Downloaders []Downloaders `json:"downloaders"`
// UseTunnelDeprecated indicates that this command needs a tunnel.
// Setting this will cause a number of side effects, such as the
// automatic setting of HELM_HOST.
// DEPRECATED and unused, but retained for backwards compatibility with Helm 2 plugins. Remove in Helm 4
UseTunnelDeprecated bool `json:"useTunnel,omitempty"`
} }
// Plugin represents a plugin. // Plugin represents a plugin.

@ -185,7 +185,7 @@ func (file *manifestFile) sort(result *result) error {
} }
isUnknownHook := false isUnknownHook := false
for _, hookType := range strings.Split(hookTypes, ",") { for hookType := range strings.SplitSeq(hookTypes, ",") {
hookType = strings.ToLower(strings.TrimSpace(hookType)) hookType = strings.ToLower(strings.TrimSpace(hookType))
e, ok := events[hookType] e, ok := events[hookType]
if !ok { if !ok {
@ -236,7 +236,7 @@ func calculateHookWeight(entry SimpleHead) int {
// operateAnnotationValues finds the given annotation and runs the operate function with the value of that annotation // operateAnnotationValues finds the given annotation and runs the operate function with the value of that annotation
func operateAnnotationValues(entry SimpleHead, annotation string, operate func(p string)) { func operateAnnotationValues(entry SimpleHead, annotation string, operate func(p string)) {
if dps, ok := entry.Metadata.Annotations[annotation]; ok { if dps, ok := entry.Metadata.Annotations[annotation]; ok {
for _, dp := range strings.Split(dps, ",") { for dp := range strings.SplitSeq(dps, ",") {
dp = strings.ToLower(strings.TrimSpace(dp)) dp = strings.ToLower(strings.TrimSpace(dp))
operate(dp) operate(dp)
} }

Loading…
Cancel
Save