Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
pull/13604/head
Austin Abro 6 months ago
commit 83266254f0
No known key found for this signature in database
GPG Key ID: 92EB5159E403F9D6

@ -20,7 +20,7 @@ jobs:
- name: Checkout source code - name: Checkout source code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # pin@v4.2.2 uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # pin@v4.2.2
- name: Setup Go - name: Setup Go
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # pin@5.3.0 uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # pin@5.4.0
with: with:
go-version: '1.23' go-version: '1.23'
check-latest: true check-latest: true

@ -16,7 +16,7 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # pin@v4.2.2 uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # pin@v4.2.2
- name: Setup Go - name: Setup Go
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # pin@5.3.0 uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # pin@5.4.0
with: with:
go-version: '1.23' go-version: '1.23'
check-latest: true check-latest: true

@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Setup Go - name: Setup Go
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # pin@5.3.0 uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # pin@5.4.0
with: with:
go-version: '1.23' go-version: '1.23'
check-latest: true check-latest: true

@ -25,7 +25,7 @@ jobs:
fetch-depth: 0 fetch-depth: 0
- name: Setup Go - name: Setup Go
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # pin@5.3.0 uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # pin@5.4.0
with: with:
go-version: '1.23' go-version: '1.23'
@ -81,7 +81,7 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # pin@v4.2.2 uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # pin@v4.2.2
- name: Setup Go - name: Setup Go
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # pin@5.3.0 uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # pin@5.4.0
with: with:
go-version: '1.23' go-version: '1.23'
check-latest: true check-latest: true

@ -55,7 +55,7 @@ jobs:
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab. # format to the repository Actions tab.
- name: "Upload artifact" - name: "Upload artifact"
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with: with:
name: SARIF file name: SARIF file
path: results.sarif path: results.sarif

@ -11,7 +11,6 @@ require (
github.com/Masterminds/squirrel v1.5.4 github.com/Masterminds/squirrel v1.5.4
github.com/Masterminds/vcs v1.13.3 github.com/Masterminds/vcs v1.13.3
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2
github.com/containerd/containerd v1.7.27
github.com/cyphar/filepath-securejoin v0.4.1 github.com/cyphar/filepath-securejoin v0.4.1
github.com/distribution/distribution/v3 v3.0.0-rc.3 github.com/distribution/distribution/v3 v3.0.0-rc.3
github.com/evanphx/json-patch v5.9.11+incompatible github.com/evanphx/json-patch v5.9.11+incompatible
@ -61,9 +60,6 @@ require (
github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/chai2010/gettext-go v1.0.2 // indirect github.com/chai2010/gettext-go v1.0.2 // indirect
github.com/containerd/errdefs v0.3.0 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/containerd/platforms v0.2.1 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect

@ -48,14 +48,6 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/chai2010/gettext-go v1.0.2 h1:1Lwwip6Q2QGsAdl/ZKPCwTe9fe0CjlUbqj5bFNSjIRk= github.com/chai2010/gettext-go v1.0.2 h1:1Lwwip6Q2QGsAdl/ZKPCwTe9fe0CjlUbqj5bFNSjIRk=
github.com/chai2010/gettext-go v1.0.2/go.mod h1:y+wnP2cHYaVj19NZhYKAwEMH2CI1gNHeQQ+5AjwawxA= github.com/chai2010/gettext-go v1.0.2/go.mod h1:y+wnP2cHYaVj19NZhYKAwEMH2CI1gNHeQQ+5AjwawxA=
github.com/containerd/containerd v1.7.27 h1:yFyEyojddO3MIGVER2xJLWoCIn+Up4GaHFquP7hsFII=
github.com/containerd/containerd v1.7.27/go.mod h1:xZmPnl75Vc+BLGt4MIfu6bp+fy03gdHAn9bz+FreFR0=
github.com/containerd/errdefs v0.3.0 h1:FSZgGOeK4yuT/+DnF07/Olde/q4KBoMsaamhXxIMDp4=
github.com/containerd/errdefs v0.3.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M=
github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpSBQv6A=
github.com/containerd/platforms v0.2.1/go.mod h1:XHCb+2/hzowdiut9rkudds9bE5yJ7npe7dG/wG+uFPw=
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0= github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0=

@ -21,7 +21,7 @@ limitations under the License.
package sympath package sympath
import ( import (
"log" "log/slog"
"os" "os"
"path/filepath" "path/filepath"
"sort" "sort"
@ -72,7 +72,7 @@ func symwalk(path string, info os.FileInfo, walkFn filepath.WalkFunc) error {
return errors.Wrapf(err, "error evaluating symlink %s", path) return errors.Wrapf(err, "error evaluating symlink %s", path)
} }
//This log message is to highlight a symlink that is being used within a chart, symlinks can be used for nefarious reasons. //This log message is to highlight a symlink that is being used within a chart, symlinks can be used for nefarious reasons.
log.Printf("found symbolic link in path: %s resolves to %s. Contents of linked file included and used", path, resolved) slog.Info("found symbolic link in path. Contents of linked file included and used", "path", path, "resolved", resolved)
if info, err = os.Lstat(resolved); err != nil { if info, err = os.Lstat(resolved); err != nil {
return err return err
} }

@ -16,7 +16,7 @@ limitations under the License.
package util package util
import ( import (
"log" "log/slog"
"strings" "strings"
"github.com/mitchellh/copystructure" "github.com/mitchellh/copystructure"
@ -48,10 +48,10 @@ func processDependencyConditions(reqs []*chart.Dependency, cvals Values, cpath s
r.Enabled = bv r.Enabled = bv
break break
} }
log.Printf("Warning: Condition path '%s' for chart %s returned non-bool value", c, r.Name) slog.Warn("returned non-bool value", "path", c, "chart", r.Name)
} else if _, ok := err.(ErrNoValue); !ok { } else if _, ok := err.(ErrNoValue); !ok {
// this is a real error // this is a real error
log.Printf("Warning: PathValue returned error %v", err) slog.Warn("the method PathValue returned error", slog.Any("error", err))
} }
} }
} }
@ -79,7 +79,7 @@ func processDependencyTags(reqs []*chart.Dependency, cvals Values) {
hasFalse = true hasFalse = true
} }
} else { } else {
log.Printf("Warning: Tag '%s' for chart %s returned non-bool value", k, r.Name) slog.Warn("returned non-bool value", "tag", k, "chart", r.Name)
} }
} }
} }
@ -254,7 +254,7 @@ func processImportValues(c *chart.Chart, merge bool) error {
// get child table // get child table
vv, err := cvals.Table(r.Name + "." + child) vv, err := cvals.Table(r.Name + "." + child)
if err != nil { if err != nil {
log.Printf("Warning: ImportValues missing table from chart %s: %v", r.Name, err) slog.Warn("ImportValues missing table from chart", "chart", r.Name, "error", err)
continue continue
} }
// create value map from child to be merged into parent // create value map from child to be merged into parent
@ -271,7 +271,7 @@ func processImportValues(c *chart.Chart, merge bool) error {
}) })
vm, err := cvals.Table(r.Name + "." + child) vm, err := cvals.Table(r.Name + "." + child)
if err != nil { if err != nil {
log.Printf("Warning: ImportValues missing table: %v", err) slog.Warn("ImportValues missing table", slog.Any("error", err))
continue continue
} }
if merge { if merge {

@ -42,11 +42,10 @@ To update all the repositories, use 'helm repo update'.
var errNoRepositories = errors.New("no repositories found. You must add one before updating") var errNoRepositories = errors.New("no repositories found. You must add one before updating")
type repoUpdateOptions struct { type repoUpdateOptions struct {
update func([]*repo.ChartRepository, io.Writer, bool) error update func([]*repo.ChartRepository, io.Writer) error
repoFile string repoFile string
repoCache string repoCache string
names []string names []string
failOnRepoUpdateFail bool
} }
func newRepoUpdateCmd(out io.Writer) *cobra.Command { func newRepoUpdateCmd(out io.Writer) *cobra.Command {
@ -69,12 +68,6 @@ func newRepoUpdateCmd(out io.Writer) *cobra.Command {
}, },
} }
f := cmd.Flags()
// Adding this flag for Helm 3 as stop gap functionality for https://github.com/helm/helm/issues/10016.
// This should be deprecated in Helm 4 by update to the behaviour of `helm repo update` command.
f.BoolVar(&o.failOnRepoUpdateFail, "fail-on-repo-update-fail", false, "update fails if any of the repository updates fail")
return cmd return cmd
} }
@ -112,10 +105,10 @@ func (o *repoUpdateOptions) run(out io.Writer) error {
} }
} }
return o.update(repos, out, o.failOnRepoUpdateFail) return o.update(repos, out)
} }
func updateCharts(repos []*repo.ChartRepository, out io.Writer, failOnRepoUpdateFail bool) error { func updateCharts(repos []*repo.ChartRepository, out io.Writer) error {
fmt.Fprintln(out, "Hang tight while we grab the latest from your chart repositories...") fmt.Fprintln(out, "Hang tight while we grab the latest from your chart repositories...")
var wg sync.WaitGroup var wg sync.WaitGroup
var repoFailList []string var repoFailList []string
@ -133,7 +126,7 @@ func updateCharts(repos []*repo.ChartRepository, out io.Writer, failOnRepoUpdate
} }
wg.Wait() wg.Wait()
if len(repoFailList) > 0 && failOnRepoUpdateFail { if len(repoFailList) > 0 {
return fmt.Errorf("Failed to update the following repositories: %s", return fmt.Errorf("Failed to update the following repositories: %s",
repoFailList) repoFailList)
} }

@ -34,7 +34,7 @@ func TestUpdateCmd(t *testing.T) {
var out bytes.Buffer var out bytes.Buffer
// Instead of using the HTTP updater, we provide our own for this test. // Instead of using the HTTP updater, we provide our own for this test.
// The TestUpdateCharts test verifies the HTTP behavior independently. // The TestUpdateCharts test verifies the HTTP behavior independently.
updater := func(repos []*repo.ChartRepository, out io.Writer, _ bool) error { updater := func(repos []*repo.ChartRepository, out io.Writer) error {
for _, re := range repos { for _, re := range repos {
fmt.Fprintln(out, re.Config.Name) fmt.Fprintln(out, re.Config.Name)
} }
@ -59,7 +59,7 @@ func TestUpdateCmdMultiple(t *testing.T) {
var out bytes.Buffer var out bytes.Buffer
// Instead of using the HTTP updater, we provide our own for this test. // Instead of using the HTTP updater, we provide our own for this test.
// The TestUpdateCharts test verifies the HTTP behavior independently. // The TestUpdateCharts test verifies the HTTP behavior independently.
updater := func(repos []*repo.ChartRepository, out io.Writer, _ bool) error { updater := func(repos []*repo.ChartRepository, out io.Writer) error {
for _, re := range repos { for _, re := range repos {
fmt.Fprintln(out, re.Config.Name) fmt.Fprintln(out, re.Config.Name)
} }
@ -85,7 +85,7 @@ func TestUpdateCmdInvalid(t *testing.T) {
var out bytes.Buffer var out bytes.Buffer
// Instead of using the HTTP updater, we provide our own for this test. // Instead of using the HTTP updater, we provide our own for this test.
// The TestUpdateCharts test verifies the HTTP behavior independently. // The TestUpdateCharts test verifies the HTTP behavior independently.
updater := func(repos []*repo.ChartRepository, out io.Writer, _ bool) error { updater := func(repos []*repo.ChartRepository, out io.Writer) error {
for _, re := range repos { for _, re := range repos {
fmt.Fprintln(out, re.Config.Name) fmt.Fprintln(out, re.Config.Name)
} }
@ -145,7 +145,7 @@ func TestUpdateCharts(t *testing.T) {
} }
b := bytes.NewBuffer(nil) b := bytes.NewBuffer(nil)
updateCharts([]*repo.ChartRepository{r}, b, false) updateCharts([]*repo.ChartRepository{r}, b)
got := b.String() got := b.String()
if strings.Contains(got, "Unable to get an update") { if strings.Contains(got, "Unable to get an update") {
@ -161,39 +161,6 @@ func TestRepoUpdateFileCompletion(t *testing.T) {
checkFileCompletion(t, "repo update repo1", false) checkFileCompletion(t, "repo update repo1", false)
} }
func TestUpdateChartsFail(t *testing.T) {
defer resetEnv()()
ensure.HelmHome(t)
ts := repotest.NewTempServer(
t,
repotest.WithChartSourceGlob("testdata/testserver/*.*"),
)
defer ts.Stop()
var invalidURL = ts.URL() + "55"
r, err := repo.NewChartRepository(&repo.Entry{
Name: "charts",
URL: invalidURL,
}, getter.All(settings))
if err != nil {
t.Error(err)
}
b := bytes.NewBuffer(nil)
if err := updateCharts([]*repo.ChartRepository{r}, b, false); err != nil {
t.Error("Repo update should not return error if update of repository fails")
}
got := b.String()
if !strings.Contains(got, "Unable to get an update") {
t.Errorf("Repo should have failed update but instead got: %q", got)
}
if !strings.Contains(got, "Update Complete.") {
t.Error("Update was not successful")
}
}
func TestUpdateChartsFailWithError(t *testing.T) { func TestUpdateChartsFailWithError(t *testing.T) {
defer resetEnv()() defer resetEnv()()
ensure.HelmHome(t) ensure.HelmHome(t)
@ -214,7 +181,7 @@ func TestUpdateChartsFailWithError(t *testing.T) {
} }
b := bytes.NewBuffer(nil) b := bytes.NewBuffer(nil)
err = updateCharts([]*repo.ChartRepository{r}, b, true) err = updateCharts([]*repo.ChartRepository{r}, b)
if err == nil { if err == nil {
t.Error("Repo update should return error because update of repository fails and 'fail-on-repo-update-fail' flag set") t.Error("Repo update should return error because update of repository fails and 'fail-on-repo-update-fail' flag set")
return return

@ -18,7 +18,7 @@ package engine
import ( import (
"fmt" "fmt"
"log" "log/slog"
"path" "path"
"path/filepath" "path/filepath"
"regexp" "regexp"
@ -203,7 +203,7 @@ func (e Engine) initFunMap(t *template.Template) {
if val == nil { if val == nil {
if e.LintMode { if e.LintMode {
// Don't fail on missing required values when linting // Don't fail on missing required values when linting
log.Printf("[INFO] Missing required value: %s", warn) slog.Warn("missing required value", "message", warn)
return "", nil return "", nil
} }
return val, errors.New(warnWrap(warn)) return val, errors.New(warnWrap(warn))
@ -211,7 +211,7 @@ func (e Engine) initFunMap(t *template.Template) {
if val == "" { if val == "" {
if e.LintMode { if e.LintMode {
// Don't fail on missing required values when linting // Don't fail on missing required values when linting
log.Printf("[INFO] Missing required value: %s", warn) slog.Warn("missing required values", "message", warn)
return "", nil return "", nil
} }
return val, errors.New(warnWrap(warn)) return val, errors.New(warnWrap(warn))
@ -224,7 +224,7 @@ func (e Engine) initFunMap(t *template.Template) {
funcMap["fail"] = func(msg string) (string, error) { funcMap["fail"] = func(msg string) (string, error) {
if e.LintMode { if e.LintMode {
// Don't fail when linting // Don't fail when linting
log.Printf("[INFO] Fail: %s", msg) slog.Info("funcMap fail", "message", msg)
return "", nil return "", nil
} }
return "", errors.New(warnWrap(msg)) return "", errors.New(warnWrap(msg))

@ -18,7 +18,7 @@ package engine
import ( import (
"context" "context"
"log" "log/slog"
"strings" "strings"
"github.com/pkg/errors" "github.com/pkg/errors"
@ -101,7 +101,7 @@ func getDynamicClientOnKind(apiversion string, kind string, config *rest.Config)
gvk := schema.FromAPIVersionAndKind(apiversion, kind) gvk := schema.FromAPIVersionAndKind(apiversion, kind)
apiRes, err := getAPIResourceForGVK(gvk, config) apiRes, err := getAPIResourceForGVK(gvk, config)
if err != nil { if err != nil {
log.Printf("[ERROR] unable to get apiresource from unstructured: %s , error %s", gvk.String(), err) slog.Error("unable to get apiresource", "groupVersionKind", gvk.String(), "error", err)
return nil, false, errors.Wrapf(err, "unable to get apiresource from unstructured: %s", gvk.String()) return nil, false, errors.Wrapf(err, "unable to get apiresource from unstructured: %s", gvk.String())
} }
gvr := schema.GroupVersionResource{ gvr := schema.GroupVersionResource{
@ -111,7 +111,7 @@ func getDynamicClientOnKind(apiversion string, kind string, config *rest.Config)
} }
intf, err := dynamic.NewForConfig(config) intf, err := dynamic.NewForConfig(config)
if err != nil { if err != nil {
log.Printf("[ERROR] unable to get dynamic client %s", err) slog.Error("unable to get dynamic client", slog.Any("error", err))
return nil, false, err return nil, false, err
} }
res := intf.Resource(gvr) res := intf.Resource(gvr)
@ -122,12 +122,12 @@ func getAPIResourceForGVK(gvk schema.GroupVersionKind, config *rest.Config) (met
res := metav1.APIResource{} res := metav1.APIResource{}
discoveryClient, err := discovery.NewDiscoveryClientForConfig(config) discoveryClient, err := discovery.NewDiscoveryClientForConfig(config)
if err != nil { if err != nil {
log.Printf("[ERROR] unable to create discovery client %s", err) slog.Error("unable to create discovery client", slog.Any("error", err))
return res, err return res, err
} }
resList, err := discoveryClient.ServerResourcesForGroupVersion(gvk.GroupVersion().String()) resList, err := discoveryClient.ServerResourcesForGroupVersion(gvk.GroupVersion().String())
if err != nil { if err != nil {
log.Printf("[ERROR] unable to retrieve resource list for: %s , error: %s", gvk.GroupVersion().String(), err) slog.Error("unable to retrieve resource list", "GroupVersion", gvk.GroupVersion().String(), "error", err)
return res, err return res, err
} }
for _, resource := range resList.APIResources { for _, resource := range resList.APIResources {

@ -20,7 +20,7 @@ import (
"bufio" "bufio"
"bytes" "bytes"
"io" "io"
"log" "log/slog"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
@ -102,7 +102,7 @@ func (r *Rules) Ignore(path string, fi os.FileInfo) bool {
} }
for _, p := range r.patterns { for _, p := range r.patterns {
if p.match == nil { if p.match == nil {
log.Printf("ignore: no matcher supplied for %q", p.raw) slog.Info("this will be ignored no matcher supplied", "patterns", p.raw)
return false return false
} }
@ -177,7 +177,7 @@ func (r *Rules) parseRule(rule string) error {
rule = strings.TrimPrefix(rule, "/") rule = strings.TrimPrefix(rule, "/")
ok, err := filepath.Match(rule, n) ok, err := filepath.Match(rule, n)
if err != nil { if err != nil {
log.Printf("Failed to compile %q: %s", rule, err) slog.Error("failed to compile", "rule", rule, "error", err)
return false return false
} }
return ok return ok
@ -187,7 +187,7 @@ func (r *Rules) parseRule(rule string) error {
p.match = func(n string, _ os.FileInfo) bool { p.match = func(n string, _ os.FileInfo) bool {
ok, err := filepath.Match(rule, n) ok, err := filepath.Match(rule, n)
if err != nil { if err != nil {
log.Printf("Failed to compile %q: %s", rule, err) slog.Error("failed to compile", "rule", rule, "error", err)
return false return false
} }
return ok return ok
@ -199,7 +199,7 @@ func (r *Rules) parseRule(rule string) error {
n = filepath.Base(n) n = filepath.Base(n)
ok, err := filepath.Match(rule, n) ok, err := filepath.Match(rule, n)
if err != nil { if err != nil {
log.Printf("Failed to compile %q: %s", rule, err) slog.Error("failed to compile", "rule", rule, "error", err)
return false return false
} }
return ok return ok

@ -19,6 +19,7 @@ package kube // import "helm.sh/helm/v4/pkg/kube"
import ( import (
"context" "context"
"fmt" "fmt"
"log/slog"
"net/http" "net/http"
"time" "time"
@ -120,12 +121,13 @@ func (hw *legacyWaiter) isRetryableHTTPStatusCode(httpStatusCode int32) bool {
// waitForDeletedResources polls to check if all the resources are deleted or a timeout is reached // waitForDeletedResources polls to check if all the resources are deleted or a timeout is reached
func (hw *legacyWaiter) WaitForDelete(deleted ResourceList, timeout time.Duration) error { func (hw *legacyWaiter) WaitForDelete(deleted ResourceList, timeout time.Duration) error {
hw.log("beginning wait for %d resources to be deleted with timeout of %v", len(deleted), timeout) slog.Debug("beginning wait for resources to be deleted", "count", len(deleted), "timeout", timeout)
startTime := time.Now()
ctx, cancel := context.WithTimeout(context.Background(), timeout) ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel() defer cancel()
return wait.PollUntilContextCancel(ctx, 2*time.Second, true, func(_ context.Context) (bool, error) { err := wait.PollUntilContextCancel(ctx, 2*time.Second, true, func(_ context.Context) (bool, error) {
for _, v := range deleted { for _, v := range deleted {
err := v.Get() err := v.Get()
if err == nil || !apierrors.IsNotFound(err) { if err == nil || !apierrors.IsNotFound(err) {
@ -134,6 +136,15 @@ func (hw *legacyWaiter) WaitForDelete(deleted ResourceList, timeout time.Duratio
} }
return true, nil return true, nil
}) })
elapsed := time.Since(startTime).Round(time.Second)
if err != nil {
slog.Debug("wait for resources failed", "elapsed", elapsed, slog.Any("error", err))
} else {
slog.Debug("wait for resources succeeded", "elapsed", elapsed)
}
return err
} }
// SelectorsForObject returns the pod label selector for a given object // SelectorsForObject returns the pod label selector for a given object

@ -20,6 +20,7 @@ import (
"bytes" "bytes"
"compress/gzip" "compress/gzip"
"io" "io"
"log/slog"
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
@ -144,7 +145,7 @@ func (i *HTTPInstaller) Install() error {
return err return err
} }
debug("copying %s to %s", src, i.Path()) slog.Debug("copying", "source", src, "path", i.Path())
return fs.CopyDir(src, i.Path()) return fs.CopyDir(src, i.Path())
} }

@ -16,8 +16,6 @@ limitations under the License.
package installer package installer
import ( import (
"fmt"
"log"
"net/http" "net/http"
"os" "os"
"path/filepath" "path/filepath"
@ -125,11 +123,3 @@ func isPlugin(dirname string) bool {
_, err := os.Stat(filepath.Join(dirname, plugin.PluginFileName)) _, err := os.Stat(filepath.Join(dirname, plugin.PluginFileName))
return err == nil return err == nil
} }
var logger = log.New(os.Stderr, "[debug] ", log.Lshortfile)
func debug(format string, args ...interface{}) {
if Debug {
logger.Output(2, fmt.Sprintf(format, args...))
}
}

@ -16,6 +16,7 @@ limitations under the License.
package installer // import "helm.sh/helm/v4/pkg/plugin/installer" package installer // import "helm.sh/helm/v4/pkg/plugin/installer"
import ( import (
"log/slog"
"os" "os"
"path/filepath" "path/filepath"
@ -57,12 +58,12 @@ func (i *LocalInstaller) Install() error {
if !isPlugin(i.Source) { if !isPlugin(i.Source) {
return ErrMissingMetadata return ErrMissingMetadata
} }
debug("symlinking %s to %s", i.Source, i.Path()) slog.Debug("symlinking", "source", i.Source, "path", i.Path())
return os.Symlink(i.Source, i.Path()) return os.Symlink(i.Source, i.Path())
} }
// Update updates a local repository // Update updates a local repository
func (i *LocalInstaller) Update() error { func (i *LocalInstaller) Update() error {
debug("local repository is auto-updated") slog.Debug("local repository is auto-updated")
return nil return nil
} }

@ -16,6 +16,7 @@ limitations under the License.
package installer // import "helm.sh/helm/v4/pkg/plugin/installer" package installer // import "helm.sh/helm/v4/pkg/plugin/installer"
import ( import (
"log/slog"
"os" "os"
"sort" "sort"
@ -88,13 +89,13 @@ func (i *VCSInstaller) Install() error {
return ErrMissingMetadata return ErrMissingMetadata
} }
debug("copying %s to %s", i.Repo.LocalPath(), i.Path()) slog.Debug("copying files", "source", i.Repo.LocalPath(), "destination", i.Path())
return fs.CopyDir(i.Repo.LocalPath(), i.Path()) return fs.CopyDir(i.Repo.LocalPath(), i.Path())
} }
// Update updates a remote repository // Update updates a remote repository
func (i *VCSInstaller) Update() error { func (i *VCSInstaller) Update() error {
debug("updating %s", i.Repo.Remote()) slog.Debug("updating", "source", i.Repo.Remote())
if i.Repo.IsDirty() { if i.Repo.IsDirty() {
return errors.New("plugin repo was modified") return errors.New("plugin repo was modified")
} }
@ -128,7 +129,7 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) {
if err != nil { if err != nil {
return "", err return "", err
} }
debug("found refs: %s", refs) slog.Debug("found refs", "refs", refs)
// Convert and filter the list to semver.Version instances // Convert and filter the list to semver.Version instances
semvers := getSemVers(refs) semvers := getSemVers(refs)
@ -139,7 +140,7 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) {
if constraint.Check(v) { if constraint.Check(v) {
// If the constraint passes get the original reference // If the constraint passes get the original reference
ver := v.Original() ver := v.Original()
debug("setting to %s", ver) slog.Debug("setting to version", "version", ver)
return ver, nil return ver, nil
} }
} }
@ -149,17 +150,17 @@ func (i *VCSInstaller) solveVersion(repo vcs.Repo) (string, error) {
// setVersion attempts to checkout the version // setVersion attempts to checkout the version
func (i *VCSInstaller) setVersion(repo vcs.Repo, ref string) error { func (i *VCSInstaller) setVersion(repo vcs.Repo, ref string) error {
debug("setting version to %q", i.Version) slog.Debug("setting version", "version", i.Version)
return repo.UpdateVersion(ref) return repo.UpdateVersion(ref)
} }
// sync will clone or update a remote repo. // sync will clone or update a remote repo.
func (i *VCSInstaller) sync(repo vcs.Repo) error { func (i *VCSInstaller) sync(repo vcs.Repo) error {
if _, err := os.Stat(repo.LocalPath()); os.IsNotExist(err) { if _, err := os.Stat(repo.LocalPath()); os.IsNotExist(err) {
debug("cloning %s to %s", repo.Remote(), repo.LocalPath()) slog.Debug("cloning", "source", repo.Remote(), "destination", repo.LocalPath())
return repo.Get() return repo.Get()
} }
debug("updating %s", repo.Remote()) slog.Debug("updating", "source", repo.Remote(), "destination", repo.LocalPath())
return repo.Update() return repo.Update()
} }

@ -31,7 +31,6 @@ import (
"sync" "sync"
"github.com/Masterminds/semver/v3" "github.com/Masterminds/semver/v3"
"github.com/containerd/containerd/remotes"
"github.com/opencontainers/image-spec/specs-go" "github.com/opencontainers/image-spec/specs-go"
ocispec "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors" "github.com/pkg/errors"
@ -56,8 +55,6 @@ storing semantic versions, Helm adopts the convention of changing plus (+) to
an underscore (_) in chart version tags when pushing to a registry and back to an underscore (_) in chart version tags when pushing to a registry and back to
a plus (+) when pulling from a registry.` a plus (+) when pulling from a registry.`
var errDeprecatedRemote = errors.New("providing github.com/containerd/containerd/remotes.Resolver via ClientOptResolver is no longer suported")
type ( type (
// RemoteClient shadows the ORAS remote.Client interface // RemoteClient shadows the ORAS remote.Client interface
// (hiding the ORAS type from Helm client visibility) // (hiding the ORAS type from Helm client visibility)
@ -231,12 +228,6 @@ func ClientOptPlainHTTP() ClientOption {
} }
} }
func ClientOptResolver(_ remotes.Resolver) ClientOption {
return func(c *Client) {
c.err = errDeprecatedRemote
}
}
type ( type (
// LoginOption allows specifying various settings on login // LoginOption allows specifying various settings on login
LoginOption func(*loginOperation) LoginOption func(*loginOperation)
@ -771,7 +762,7 @@ func PushOptStrictMode(strictMode bool) PushOption {
} }
} }
// PushOptCreationDate returns a function that sets the creation time // PushOptCreationTime returns a function that sets the creation time
func PushOptCreationTime(creationTime string) PushOption { func PushOptCreationTime(creationTime string) PushOption {
return func(operation *pushOperation) { return func(operation *pushOperation) {
operation.creationTime = creationTime operation.creationTime = creationTime

@ -1,33 +0,0 @@
/*
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 registry
import (
"testing"
"github.com/containerd/containerd/remotes"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestNewClientResolverNotSupported(t *testing.T) {
var r remotes.Resolver
client, err := NewClient(ClientOptResolver(r))
require.Equal(t, err, errDeprecatedRemote)
assert.Nil(t, client)
}

@ -17,7 +17,7 @@ limitations under the License.
package util package util
import ( import (
"log" "log/slog"
"path" "path"
"sort" "sort"
"strconv" "strconv"
@ -196,7 +196,7 @@ func (file *manifestFile) sort(result *result) error {
} }
if isUnknownHook { if isUnknownHook {
log.Printf("info: skipping unknown hook: %q", hookTypes) slog.Info("skipping unknown hooks", "hookTypes", hookTypes)
continue continue
} }

@ -22,7 +22,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"log" "log/slog"
"net/url" "net/url"
"os" "os"
"path/filepath" "path/filepath"
@ -343,7 +343,8 @@ func ResolveReferenceURL(baseURL, refURL string) (string, error) {
func (e *Entry) String() string { func (e *Entry) String() string {
buf, err := json.Marshal(e) buf, err := json.Marshal(e)
if err != nil { if err != nil {
log.Panic(err) slog.Error("failed to marshal entry", slog.Any("error", err))
panic(err)
} }
return string(buf) return string(buf)
} }

@ -166,7 +166,7 @@ func (mock *MockConfigMapsInterface) Delete(_ context.Context, name string, _ me
return nil return nil
} }
// newTestFixture initializes a MockSecretsInterface. // newTestFixtureSecrets initializes a MockSecretsInterface.
// Secrets are created for each release provided. // Secrets are created for each release provided.
func newTestFixtureSecrets(t *testing.T, releases ...*rspb.Release) *Secrets { func newTestFixtureSecrets(t *testing.T, releases ...*rspb.Release) *Secrets {
var mock MockSecretsInterface var mock MockSecretsInterface

@ -476,7 +476,7 @@ func TestStorageLast(t *testing.T) {
} }
} }
// TestUpgradeInitiallyFailedRelease tests a case when there are no deployed release yet, but history limit has been // TestUpgradeInitiallyFailedReleaseWithHistoryLimit tests a case when there are no deployed release yet, but history limit has been
// reached: the has-no-deployed-releases error should not occur in such case. // reached: the has-no-deployed-releases error should not occur in such case.
func TestUpgradeInitiallyFailedReleaseWithHistoryLimit(t *testing.T) { func TestUpgradeInitiallyFailedReleaseWithHistoryLimit(t *testing.T) {
storage := Init(driver.NewMemory()) storage := Init(driver.NewMemory())

Loading…
Cancel
Save