Merge branch 'helm:main' into feature/rollback-description-flag

pull/31580/head
MrJack 2 weeks ago committed by GitHub
commit 5d3c1a18f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -22,7 +22,7 @@ jobs:
- name: Add variables to environment file
run: cat ".github/env" >> "$GITHUB_ENV"
- name: Setup Go
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # pin@6.1.0
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # pin@6.2.0
with:
go-version: '${{ env.GOLANG_VERSION }}'
check-latest: true

@ -17,7 +17,7 @@ jobs:
- name: Add variables to environment file
run: cat ".github/env" >> "$GITHUB_ENV"
- name: Setup Go
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # pin@6.1.0
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # pin@6.2.0
with:
go-version: '${{ env.GOLANG_VERSION }}'
check-latest: true

@ -25,7 +25,7 @@ jobs:
- name: Add variables to environment file
run: cat ".github/env" >> "$GITHUB_ENV"
- name: Setup Go
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # pin@6.1.0
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # pin@6.2.0
with:
go-version: '${{ env.GOLANG_VERSION }}'
check-latest: true

@ -28,7 +28,7 @@ jobs:
run: cat ".github/env" >> "$GITHUB_ENV"
- name: Setup Go
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # pin@6.1.0
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # pin@6.2.0
with:
go-version: '${{ env.GOLANG_VERSION }}'
check-latest: true
@ -91,7 +91,7 @@ jobs:
run: cat ".github/env" >> "$GITHUB_ENV"
- name: Setup Go
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # pin@6.1.0
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # pin@6.2.0
with:
go-version: '${{ env.GOLANG_VERSION }}'
check-latest: true

@ -159,7 +159,7 @@ type ChartPathOptions struct {
func NewInstall(cfg *Configuration) *Install {
in := &Install{
cfg: cfg,
ServerSideApply: true,
ServerSideApply: true, // Must always match the CLI default.
DryRunStrategy: DryRunNone,
}
in.registryClient = cfg.RegistryClient

@ -66,8 +66,9 @@ type Rollback struct {
// NewRollback creates a new Rollback object with the given configuration.
func NewRollback(cfg *Configuration) *Rollback {
return &Rollback{
cfg: cfg,
DryRunStrategy: DryRunNone,
cfg: cfg,
ServerSideApply: "auto", // Must always match the CLI default.
DryRunStrategy: DryRunNone,
}
}

@ -142,7 +142,7 @@ type resultMessage struct {
func NewUpgrade(cfg *Configuration) *Upgrade {
up := &Upgrade{
cfg: cfg,
ServerSideApply: "auto",
ServerSideApply: "auto", // Must always match the CLI default.
DryRunStrategy: DryRunNone,
}
up.registryClient = cfg.RegistryClient

@ -59,9 +59,8 @@ func AddWaitFlag(cmd *cobra.Command, wait *kube.WaitStrategy) {
cmd.Flags().Var(
newWaitValue(kube.HookOnlyStrategy, wait),
"wait",
"if specified, wait until resources are ready (up to --timeout). Values: 'watcher', 'hookOnly', and 'legacy'.",
"wait until resources are ready (up to --timeout). Use '--wait' alone for 'watcher' strategy, or specify one of: 'watcher', 'hookOnly', 'legacy'. Default when flag is omitted: 'hookOnly'.",
)
// Sets the strategy to use the watcher strategy if `--wait` is used without an argument
cmd.Flags().Lookup("wait").NoOptDefVal = string(kube.StatusWatcherStrategy)
}

@ -339,12 +339,14 @@ func Init(d driver.Driver) *Storage {
Driver: d,
}
var h slog.Handler
// Get logger from driver if it implements the LoggerSetterGetter interface
if ls, ok := d.(logging.LoggerSetterGetter); ok {
ls.SetLogger(s.Logger().Handler())
h = ls.Logger().Handler()
} else {
// If the driver does not implement the LoggerSetterGetter interface, set the default logger
s.SetLogger(slog.Default().Handler())
h = slog.Default().Handler()
}
s.SetLogger(h)
return s
}

@ -17,8 +17,10 @@ limitations under the License.
package storage // import "helm.sh/helm/v4/pkg/storage"
import (
"context"
"errors"
"fmt"
"log/slog"
"reflect"
"testing"
@ -579,3 +581,35 @@ func assertErrNil(eh func(args ...interface{}), err error, message string) {
eh(fmt.Sprintf("%s: %q", message, err))
}
}
func TestStorageGetsLoggerFromDriver(t *testing.T) {
d := driver.NewMemory()
l := &mockSLogHandler{}
d.SetLogger(l)
s := Init(d)
_, _ = s.Get("doesnt-matter", 123)
if !l.Called {
t.Fatalf("Expected storage to use driver's logger, but it did not")
}
}
type mockSLogHandler struct {
Called bool
}
func (m *mockSLogHandler) Enabled(context.Context, slog.Level) bool {
return true
}
func (m *mockSLogHandler) Handle(context.Context, slog.Record) error {
m.Called = true
return nil
}
func (m *mockSLogHandler) WithAttrs([]slog.Attr) slog.Handler {
return m
}
func (m *mockSLogHandler) WithGroup(string) slog.Handler {
return m
}

Loading…
Cancel
Save