Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
go-version-file: 'go.mod'
- uses: golangci/golangci-lint-action@v9
with:
version: v2.7.2
version: v2.12.2
1 change: 1 addition & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ linters:
- dupl
- errcheck
- funlen
- goconst
- gocyclo
- gosec
path: _test\.go
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.release
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.25.9
FROM golang:1.26.0

# See https://github.com/cli/cli/blob/trunk/docs/install_linux.md#debian-ubuntu-linux-raspberry-pi-os-apt
# for the latest gh install instructions when the below didn't work
Expand Down
8 changes: 4 additions & 4 deletions cmd/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ func (d *diffCmd) template(isUpgrade bool) ([]byte, error) {
// Note: dryRunMode="true" behaves like "client" (no cluster access).
// Note: dryRunMode="false" behaves like "none" (no dry-run flag at all).
// See https://github.com/databus23/helm-diff/issues/894
if !slices.Contains([]string{"client", "true", "false"}, d.dryRunMode) {
if !slices.Contains([]string{dryRunNoOptDefVal, envTrue, envFalse}, d.dryRunMode) {
flags = append(flags, "--dry-run=server")
}
} else {
Expand Down Expand Up @@ -383,10 +383,10 @@ func (d *diffCmd) template(isUpgrade bool) ([]byte, error) {
// additional dry-run flag here. In all other cases (Helm v3 or d.dryRunMode is "client"/"true"),
// we add the appropriate dry-run mode below.
// Note: dryRunMode="false" means no dry-run flag at all.
if d.dryRunMode == "false" {
if d.dryRunMode == envFalse {
// "false" means no dry-run, skip adding any dry-run flag
} else if !(isHelmV4 && !slices.Contains([]string{"client", "true"}, d.dryRunMode)) {
if d.dryRunMode == "server" {
} else if !(isHelmV4 && !slices.Contains([]string{dryRunNoOptDefVal, envTrue}, d.dryRunMode)) {
if d.dryRunMode == dryRunServer {
// This is for security reasons!
//
// We give helm-template the additional cluster access for the helm `lookup` function
Expand Down
2 changes: 1 addition & 1 deletion cmd/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var (
)

func isDebug() bool {
return os.Getenv("HELM_DEBUG") == "true"
return os.Getenv("HELM_DEBUG") == envTrue
}
func debugPrint(format string, a ...interface{}) {
if isDebug() {
Expand Down
11 changes: 7 additions & 4 deletions cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ import (
)

var (
validDryRunValues = []string{"server", "client", "true", "false"}
validDryRunValues = []string{dryRunServer, dryRunNoOptDefVal, envTrue, envFalse}
)

const (
dryRunNoOptDefVal = "client"
dryRunNone = "none"
dryRunServer = "server"
envTrue = "true"
envFalse = "false"
)

type diffCmd struct {
Expand Down Expand Up @@ -102,7 +105,7 @@ func (d *diffCmd) isAllowUnreleased() bool {
//
// See also https://github.com/helm/helm/pull/9426#discussion_r1181397259
func (d *diffCmd) clusterAccessAllowed() bool {
return d.dryRunMode == "none" || d.dryRunMode == "false" || d.dryRunMode == "server"
return d.dryRunMode == dryRunNone || d.dryRunMode == envFalse || d.dryRunMode == dryRunServer
}

const globalUsage = `Show a diff explaining what a helm upgrade would change.
Expand Down Expand Up @@ -158,9 +161,9 @@ func newChartCommand() *cobra.Command {
},
RunE: func(cmd *cobra.Command, args []string) error {
if diff.dryRunMode == "" {
diff.dryRunMode = "none"
diff.dryRunMode = dryRunNone
} else if !slices.Contains(validDryRunValues, diff.dryRunMode) {
return fmt.Errorf("flag %q must take a bool value or either %q or %q, but got %q", "dry-run", "client", "server", diff.dryRunMode)
return fmt.Errorf("flag %q must take a bool value or either %q or %q, but got %q", "dry-run", dryRunNoOptDefVal, dryRunServer, diff.dryRunMode)
}

// Suppress the command usage on error. See #77 for more info
Expand Down
8 changes: 5 additions & 3 deletions diff/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ type Options struct {
SuppressedOutputLineRegex []string
}

const kindSecret = "Secret"

// StructuredOutput returns true when the structured JSON output is requested.
func (o *Options) StructuredOutput() bool {
return o != nil && o.OutputFormat == "structured"
Expand Down Expand Up @@ -213,7 +215,7 @@ func contentSearch(report *Report, possiblyRemoved []string, oldIndex map[string
// Skip the length-ratio filter for Secrets: their raw content length can
// differ greatly from the post-processed (redacted/decoded) length, so the
// ratio would be an unreliable predictor of content similarity.
if oldContent.Kind != "Secret" {
if oldContent.Kind != kindSecret {
ratio := float32(oldLen) / float32(newLen)
if ratio < renameDetectionMinLengthRatio || ratio > renameDetectionMaxLengthRatio {
continue
Expand Down Expand Up @@ -351,7 +353,7 @@ func preHandleSecrets(old, new *manifest.MappingResult) (v1.Secret, v1.Secret, e

// redactSecrets redacts secrets from the diff output.
func redactSecrets(old, new *manifest.MappingResult) {
if (old != nil && old.Kind != "Secret") || (new != nil && new.Kind != "Secret") {
if (old != nil && old.Kind != kindSecret) || (new != nil && new.Kind != kindSecret) {
return
}
serializer := json.NewYAMLSerializer(json.DefaultMetaFactory, scheme.Scheme, scheme.Scheme)
Expand Down Expand Up @@ -402,7 +404,7 @@ func redactSecrets(old, new *manifest.MappingResult) {

// decodeSecrets decodes secrets from the diff output.
func decodeSecrets(old, new *manifest.MappingResult) {
if (old != nil && old.Kind != "Secret") || (new != nil && new.Kind != "Secret") {
if (old != nil && old.Kind != kindSecret) || (new != nil && new.Kind != kindSecret) {
return
}
serializer := json.NewYAMLSerializer(json.DefaultMetaFactory, scheme.Scheme, scheme.Scheme)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/databus23/helm-diff/v3

go 1.25.9
go 1.26.0

require (
github.com/Masterminds/semver/v3 v3.5.0
Expand Down
Loading