Fixes for updates from rebase

Signed-off-by: Anton Bretting <sajfer@gmail.com>
This commit is contained in:
Anton Bretting 2022-09-14 19:11:44 +02:00 committed by Yusuke Kuoka
parent fcdd852153
commit f0b76e9e26
6 changed files with 37 additions and 17 deletions

3
go.mod
View File

@ -29,12 +29,14 @@ require (
github.com/variantdev/vals v0.18.0 github.com/variantdev/vals v0.18.0
go.uber.org/multierr v1.6.0 go.uber.org/multierr v1.6.0
go.uber.org/zap v1.23.0 go.uber.org/zap v1.23.0
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v2 v2.4.0
gotest.tools v2.2.0+incompatible gotest.tools v2.2.0+incompatible
helm.sh/helm/v3 v3.8.1 helm.sh/helm/v3 v3.8.1
k8s.io/apimachinery v0.24.4 k8s.io/apimachinery v0.24.4
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9
) )
require ( require (
@ -194,7 +196,6 @@ require (
k8s.io/client-go v0.23.4 // indirect k8s.io/client-go v0.23.4 // indirect
k8s.io/klog/v2 v2.60.1 // indirect k8s.io/klog/v2 v2.60.1 // indirect
k8s.io/kube-openapi v0.0.0-20220328201542-3ee0da9b0b42 // indirect k8s.io/kube-openapi v0.0.0-20220328201542-3ee0da9b0b42 // indirect
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
oras.land/oras-go v1.1.0 // indirect oras.land/oras-go v1.1.0 // indirect
sigs.k8s.io/kustomize/api v0.10.1 // indirect sigs.k8s.io/kustomize/api v0.10.1 // indirect
sigs.k8s.io/kustomize/kyaml v0.13.0 // indirect sigs.k8s.io/kustomize/kyaml v0.13.0 // indirect

4
go.sum
View File

@ -1373,8 +1373,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/exp v0.0.0-20220518171630-0b5c67f07fdf h1:oXVg4h2qJDd9htKxb5SCpFBHLipW6hXmL3qpUixS2jw= golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561 h1:MDc5xs78ZrZr3HMQugiXOAkSZtfTpbJLDr/lwfgO53E=
golang.org/x/exp v0.0.0-20220518171630-0b5c67f07fdf/go.mod h1:yh0Ynu2b5ZUe3MQfp2nM0ecK7wsgouWTDN0FNeJuIys= golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=

View File

@ -15,6 +15,7 @@ import (
"github.com/variantdev/vals" "github.com/variantdev/vals"
"go.uber.org/zap" "go.uber.org/zap"
"golang.org/x/exp/slices"
"github.com/helmfile/helmfile/pkg/argparser" "github.com/helmfile/helmfile/pkg/argparser"
"github.com/helmfile/helmfile/pkg/filesystem" "github.com/helmfile/helmfile/pkg/filesystem"
@ -1359,7 +1360,7 @@ Do you really want to apply?
for _, release := range releasesWithPreApply { for _, release := range releasesWithPreApply {
a.Logger.Infof("\nRunning preapply hook for %s:", release.Name) a.Logger.Infof("\nRunning preapply hook for %s:", release.Name)
if _, err := st.TriggerPreapplyEvent(&release, "apply"); err != nil { if _, err := st.TriggerPreapplyEvent(&release, "apply"); err != nil {
syncErrs = append(syncErrs, err) applyErrs = append(applyErrs, err)
continue continue
} }
} }
@ -1420,6 +1421,35 @@ Do you really want to apply?
return true, true, applyErrs return true, true, applyErrs
} }
func getReleasesWithPreApply(releases []state.ReleaseSpec) []state.ReleaseSpec {
var releasesWithPreApply []state.ReleaseSpec
for _, r := range releases {
release := r
for _, hook := range release.Hooks {
if slices.Contains(hook.Events, "preapply") {
releasesWithPreApply = append(releasesWithPreApply, release)
break
}
}
}
return releasesWithPreApply
}
func preApplyInfoMsg(releasesWithPreApply []state.ReleaseSpec, infoMsg *string) *string {
if len(releasesWithPreApply) > 0 {
msg := "Releases with preapply hooks: \n"
if infoMsg != nil {
msg = fmt.Sprintf("%s\n%s", *infoMsg, msg)
}
infoMsg = &msg
}
for _, release := range releasesWithPreApply {
tmp := fmt.Sprintf("%s %s (%s)\n", *infoMsg, release.Name, release.Chart)
infoMsg = &tmp
}
return infoMsg
}
func (a *App) delete(r *Run, purge bool, c DestroyConfigProvider) (bool, []error) { func (a *App) delete(r *Run, purge bool, c DestroyConfigProvider) (bool, []error) {
st := r.state st := r.state
helm := r.helm helm := r.helm

View File

@ -4,7 +4,6 @@ import (
"bufio" "bufio"
"bytes" "bytes"
"io" "io"
"path/filepath"
"sync" "sync"
"testing" "testing"
@ -94,8 +93,6 @@ func TestApply_hooks(t *testing.T) {
app := appWithFs(&App{ app := appWithFs(&App{
OverrideHelmBinary: DefaultHelmBinary, OverrideHelmBinary: DefaultHelmBinary,
glob: filepath.Glob,
abs: filepath.Abs,
OverrideKubeContext: "default", OverrideKubeContext: "default",
Env: "default", Env: "default",
Logger: logger, Logger: logger,

View File

@ -10,7 +10,6 @@ import (
"github.com/helmfile/helmfile/pkg/filesystem" "github.com/helmfile/helmfile/pkg/filesystem"
"github.com/helmfile/helmfile/pkg/helmexec" "github.com/helmfile/helmfile/pkg/helmexec"
"github.com/helmfile/helmfile/pkg/tmpl" "github.com/helmfile/helmfile/pkg/tmpl"
"go.uber.org/zap"
) )
type Hook struct { type Hook struct {
@ -89,7 +88,7 @@ func (bus *Bus) Trigger(evt string, evtErr error, context map[string]interface{}
} }
} }
bus.Logger.Debugf("hook[%s]: stateFilePath=%s, basePath=%s", name, bus.StateFilePath, bus.BasePath) bus.Logger.Debugf("hook[%s]: stateFilePath=%s, basePath=%s\n", name, bus.StateFilePath, bus.BasePath)
data := map[string]interface{}{ data := map[string]interface{}{
"Environment": bus.Env, "Environment": bus.Env,

View File

@ -18,10 +18,10 @@ import (
"text/template" "text/template"
"github.com/imdario/mergo" "github.com/imdario/mergo"
"github.com/variantdev/chartify"
"github.com/helmfile/helmfile/pkg/environment" "github.com/helmfile/helmfile/pkg/environment"
"github.com/helmfile/helmfile/pkg/event" "github.com/helmfile/helmfile/pkg/event"
"github.com/helmfile/helmfile/pkg/filesystem"
"github.com/helmfile/helmfile/pkg/helmexec" "github.com/helmfile/helmfile/pkg/helmexec"
"github.com/helmfile/helmfile/pkg/remote" "github.com/helmfile/helmfile/pkg/remote"
"github.com/helmfile/helmfile/pkg/tmpl" "github.com/helmfile/helmfile/pkg/tmpl"
@ -31,13 +31,6 @@ import (
"github.com/variantdev/vals" "github.com/variantdev/vals"
"go.uber.org/zap" "go.uber.org/zap"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
"github.com/helmfile/helmfile/pkg/environment"
"github.com/helmfile/helmfile/pkg/event"
"github.com/helmfile/helmfile/pkg/filesystem"
"github.com/helmfile/helmfile/pkg/helmexec"
"github.com/helmfile/helmfile/pkg/remote"
"github.com/helmfile/helmfile/pkg/tmpl"
) )
const ( const (