Skip to content

Commit

Permalink
feat: update to helm v3.8.0
Browse files Browse the repository at this point in the history
Includes fix for server-dry-run validation: werf/3p-helm#138

Signed-off-by: Timofey Kirillov <timofey.kirillov@flant.com>
  • Loading branch information
distorhead committed Mar 4, 2022
1 parent 265575e commit 6fff511
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 56 deletions.
27 changes: 14 additions & 13 deletions cmd/werf/common/helm.go
Expand Up @@ -6,34 +6,35 @@ import (

helm_v3 "helm.sh/helm/v3/cmd/helm"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/registry"

"github.com/werf/kubedog/pkg/kube"
"github.com/werf/logboek"
"github.com/werf/werf/pkg/deploy/bundles/registry"
bundles_registry "github.com/werf/werf/pkg/deploy/bundles/registry"
"github.com/werf/werf/pkg/deploy/helm"
)

func NewHelmRegistryClientHandle(ctx context.Context, commonCmdData *CmdData) (*helm_v3.RegistryClientHandle, error) {
if registryClient, err := helm_v3.NewRegistryClient(logboek.Context(ctx).Debug().IsAccepted(), *commonCmdData.InsecureHelmDependencies, logboek.Context(ctx).OutStream()); err != nil {
return nil, err
} else {
return helm_v3.NewRegistryClientHandle(registryClient), nil
}
func NewHelmRegistryClientHandle(ctx context.Context, commonCmdData *CmdData) (*registry.Client, error) {
return registry.NewClient(
registry.ClientOptDebug(logboek.Context(ctx).Debug().IsAccepted()),
registry.ClientOptInsecure(*commonCmdData.InsecureHelmDependencies),
registry.ClientOptWriter(logboek.Context(ctx).OutStream()),
)
}

func NewBundlesRegistryClient(ctx context.Context, commonCmdData *CmdData) (*registry.Client, error) {
func NewBundlesRegistryClient(ctx context.Context, commonCmdData *CmdData) (*bundles_registry.Client, error) {
debug := logboek.Context(ctx).Debug().IsAccepted()
insecure := *commonCmdData.InsecureHelmDependencies
out := logboek.Context(ctx).OutStream()

return registry.NewClient(
registry.ClientOptDebug(debug),
registry.ClientOptInsecure(insecure),
registry.ClientOptWriter(out),
return bundles_registry.NewClient(
bundles_registry.ClientOptDebug(debug),
bundles_registry.ClientOptInsecure(insecure),
bundles_registry.ClientOptWriter(out),
)
}

func NewActionConfig(ctx context.Context, kubeInitializer helm.KubeInitializer, namespace string, commonCmdData *CmdData, registryClient *helm_v3.RegistryClientHandle) (*action.Configuration, error) {
func NewActionConfig(ctx context.Context, kubeInitializer helm.KubeInitializer, namespace string, commonCmdData *CmdData, registryClient *registry.Client) (*action.Configuration, error) {
actionConfig := new(action.Configuration)

if err := helm.InitActionConfig(ctx, kubeInitializer, namespace, helm_v3.Settings, registryClient, actionConfig, helm.InitActionConfigOptions{
Expand Down
7 changes: 4 additions & 3 deletions cmd/werf/converge/converge.go
Expand Up @@ -9,12 +9,13 @@ import (
"time"

"github.com/spf13/cobra"
"helm.sh/helm/v3/cmd/helm"
helm_v3 "helm.sh/helm/v3/cmd/helm"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/chart"
"helm.sh/helm/v3/pkg/chart/loader"
"helm.sh/helm/v3/pkg/cli/values"
"helm.sh/helm/v3/pkg/postrender"
"helm.sh/helm/v3/pkg/registry"

"github.com/werf/kubedog/pkg/kube"
"github.com/werf/logboek"
Expand Down Expand Up @@ -498,7 +499,7 @@ func createMaintenanceHelper(ctx context.Context, actionConfig *action.Configura
return maintenance_helper.NewMaintenanceHelper(actionConfig, maintenanceOpts)
}

func migrateHelm2ToHelm3(ctx context.Context, releaseName, namespace string, maintenanceHelper *maintenance_helper.MaintenanceHelper, chainPostRenderer func(postrender.PostRenderer) postrender.PostRenderer, valueOpts *values.Options, fullChartDir string, helmRegistryClientHandle *helm_v3.RegistryClientHandle) error {
func migrateHelm2ToHelm3(ctx context.Context, releaseName, namespace string, maintenanceHelper *maintenance_helper.MaintenanceHelper, chainPostRenderer func(postrender.PostRenderer) postrender.PostRenderer, valueOpts *values.Options, fullChartDir string, helmRegistryClient *registry.Client) error {
if helm2Exists, err := checkHelm2AvailableAndReleaseExists(ctx, releaseName, namespace, maintenanceHelper); err != nil {
return fmt.Errorf("error checking availability of helm 2 and existence of helm 2 release %q: %s", releaseName, err)
} else if !helm2Exists {
Expand All @@ -525,7 +526,7 @@ func migrateHelm2ToHelm3(ctx context.Context, releaseName, namespace string, mai

logboek.Context(ctx).Default().LogOptionalLn()
if err := logboek.Context(ctx).LogProcess("Rendering helm 3 templates for the current project state").DoError(func() error {
actionConfig, err := common.NewActionConfig(ctx, common.GetOndemandKubeInitializer(), namespace, &commonCmdData, helmRegistryClientHandle)
actionConfig, err := common.NewActionConfig(ctx, common.GetOndemandKubeInitializer(), namespace, &commonCmdData, helmRegistryClient)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/werf/helm/helm.go
Expand Up @@ -82,7 +82,7 @@ func NewCmd() *cobra.Command {
helm_v3.NewPluginCmd(os.Stdout),
helm_v3.NewPullCmd(actionConfig, os.Stdout),
helm_v3.NewSearchCmd(os.Stdout),
helm_v3.NewShowCmd(os.Stdout),
helm_v3.NewShowCmd(actionConfig, os.Stdout),
helm_v3.NewStatusCmd(actionConfig, os.Stdout),
helm_v3.NewTestCmd(actionConfig, os.Stdout),
helm_v3.NewVerifyCmd(os.Stdout),
Expand Down
23 changes: 11 additions & 12 deletions go.mod
Expand Up @@ -24,7 +24,7 @@ require (
github.com/deislabs/oras v0.12.0
github.com/djherbis/buffer v1.1.0
github.com/djherbis/nio/v3 v3.0.1
github.com/docker/cli v20.10.7+incompatible
github.com/docker/cli v20.10.11+incompatible
github.com/docker/distribution v2.8.0+incompatible
github.com/docker/docker v20.10.12+incompatible
github.com/docker/go v1.5.1-1 // indirect
Expand All @@ -37,7 +37,6 @@ require (
github.com/go-openapi/spec v0.19.5
github.com/go-openapi/strfmt v0.19.5
github.com/go-openapi/validate v0.19.8
github.com/gofrs/uuid v3.3.0+incompatible // indirect
github.com/google/go-containerregistry v0.5.1
github.com/google/uuid v1.3.0
github.com/gookit/color v1.3.7
Expand All @@ -49,7 +48,7 @@ require (
github.com/jinzhu/gorm v1.9.12 // indirect
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
github.com/minio/minio v0.0.0-20210311070216-f92b7a562103
github.com/mitchellh/copystructure v1.1.1
github.com/mitchellh/copystructure v1.2.0
github.com/moby/buildkit v0.8.2
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6
github.com/mvdan/xurls v1.1.0 // indirect
Expand Down Expand Up @@ -88,17 +87,17 @@ require (
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
helm.sh/helm/v3 v3.6.3
k8s.io/api v0.22.1
k8s.io/apimachinery v0.22.1
k8s.io/cli-runtime v0.22.1
k8s.io/client-go v0.22.1
k8s.io/api v0.23.1
k8s.io/apimachinery v0.23.1
k8s.io/cli-runtime v0.23.1
k8s.io/client-go v0.23.1
k8s.io/helm v2.17.0+incompatible
k8s.io/klog v1.0.0
k8s.io/klog/v2 v2.9.0
k8s.io/kubectl v0.22.1
k8s.io/klog/v2 v2.30.0
k8s.io/kubectl v0.23.1
mvdan.cc/xurls v1.1.0
oras.land/oras-go v0.4.0
sigs.k8s.io/yaml v1.2.1-0.20210128145534-11e43d4a8b92
oras.land/oras-go v1.1.0
sigs.k8s.io/yaml v1.3.0
)

replace github.com/jaguilar/vt100 => github.com/tonistiigi/vt100 v0.0.0-20190402012908-ad4c4a574305
Expand All @@ -107,4 +106,4 @@ replace k8s.io/helm => github.com/werf/helm v0.0.0-20210202111118-81e74d46da0f

replace github.com/deislabs/oras => github.com/werf/third-party-oras v0.9.1-0.20210927171747-6d045506f4c8

replace helm.sh/helm/v3 => github.com/werf/3p-helm/v3 v3.0.0-20220302144706-183ef12e4afb
replace helm.sh/helm/v3 => github.com/werf/3p-helm/v3 v3.0.0-20220304092913-4f412c1ef00f

0 comments on commit 6fff511

Please sign in to comment.