Skip to content

Commit

Permalink
Ignore status fields during drift detection (rancher#2522)
Browse files Browse the repository at this point in the history
  • Loading branch information
aruiz14 authored and Tommy12789 committed Jun 26, 2024
1 parent c220a0d commit 916717a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/rancher/wrangler v1.1.2 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/rubenv/sql-migrate v1.5.2 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,8 @@ github.com/rancher/helm/v3 v3.14.4-fleet.0 h1:fMyGOkEc6laHsr/kZn4GaZ37//pGBNioP9
github.com/rancher/helm/v3 v3.14.4-fleet.0/go.mod h1:Tje7LL4gprZpuBNTbG34d1Xn5NmRT3OWfBRwpOSer9I=
github.com/rancher/lasso v0.0.0-20240424194130-d87ec407d941 h1:1SvuoeyfANRvKVJUSzHWa1P781iuH8ktUjW9cPOxAAk=
github.com/rancher/lasso v0.0.0-20240424194130-d87ec407d941/go.mod h1:pYKOe2r/5O0w3ypoc7xHQF8LvWCp5PsNRea1Jpq3vBU=
github.com/rancher/wrangler v1.1.2 h1:oXbXo9k7y/H4drUpb4RM1c++vT9O3rpoNEfyusGykiU=
github.com/rancher/wrangler v1.1.2/go.mod h1:2k9MyhlBdjcutcBGoOJSUAz0HgDAXnMjv81d3n/AaQc=
github.com/rancher/wrangler/v2 v2.1.4 h1:ohov0i6A9dJHHO6sjfsH4Dqv93ZTdm5lIJVJdPzVdQc=
github.com/rancher/wrangler/v2 v2.1.4/go.mod h1:af5OaGU/COgreQh1mRbKiUI64draT2NN34uk+PALFY8=
github.com/reugn/go-quartz v0.11.2 h1:+jc54Ji06n/D/endEPmc+CuG/Jc8466nda1oxtFRrks=
Expand Down
17 changes: 9 additions & 8 deletions internal/helmdeployer/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ package helmdeployer
import (
"context"
"fmt"
"strings"
"time"

name1 "github.com/rancher/wrangler/pkg/name"

"github.com/pkg/errors"
"github.com/rancher/fleet/internal/helmdeployer/helmcache"
"helm.sh/helm/v3/pkg/action"
Expand Down Expand Up @@ -110,15 +113,17 @@ func (h *Helm) getOpts(bundleID string, options fleet.BundleDeploymentOptions) (
ns = h.defaultNamespace
}

if options.Helm != nil && options.Helm.ReleaseName != "" {
// JSON schema validation makes sure that the option is valid
return timeout, ns, options.Helm.ReleaseName
releaseName := name1.SafeConcatName(ns, options.Helm.ReleaseName)

if releaseName == "" {
releaseName = name2.HelmReleaseName(bundleID)
}

// releaseName has a limit of 53 in helm https://github.com/helm/helm/blob/main/pkg/action/install.go#L58
// fleet apply already produces valid names, but we need to make sure
// that bundles from other sources are valid
return timeout, ns, name2.HelmReleaseName(bundleID)
releaseName = strings.Trim(releaseName, "-_.")
return timeout, ns, releaseName
}

func (h *Helm) getCfg(ctx context.Context, namespace, serviceAccountName string) (action.Configuration, error) {
Expand All @@ -127,10 +132,6 @@ func (h *Helm) getCfg(ctx context.Context, namespace, serviceAccountName string)
getter = h.getter
)

if h.useGlobalCfg {
return h.globalCfg, nil
}

serviceAccountNamespace, serviceAccountName, err := h.getServiceAccount(ctx, serviceAccountName)
if err != nil {
return cfg, err
Expand Down

0 comments on commit 916717a

Please sign in to comment.