Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feat: added flag to skip helm repo index fetching
For example 'werf render --skip-dependencies-repo-refresh|-L' will disable repo index refreshing while autodownloading chart deps.

Refs #5255

Signed-off-by: Timofey Kirillov <timofey.kirillov@flant.com>
  • Loading branch information
distorhead committed Jan 20, 2023
1 parent de5526f commit 39d004a
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/werf/bundle/export/export.go
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/werf/werf/pkg/config"
"github.com/werf/werf/pkg/deploy/helm/chart_extender"
"github.com/werf/werf/pkg/deploy/helm/chart_extender/helpers"
"github.com/werf/werf/pkg/deploy/helm/command_helpers"
"github.com/werf/werf/pkg/git_repo"
"github.com/werf/werf/pkg/git_repo/gitdata"
"github.com/werf/werf/pkg/image"
Expand Down Expand Up @@ -123,6 +124,7 @@ func NewCmd(ctx context.Context) *cobra.Command {
common.SetupValues(&commonCmdData, cmd)

commonCmdData.SetupDisableDefaultValues(cmd)
commonCmdData.SetupSkipDependenciesRepoRefresh(cmd)

common.SetupReportPath(&commonCmdData, cmd)
common.SetupReportFormat(&commonCmdData, cmd)
Expand Down Expand Up @@ -321,6 +323,7 @@ func runExport(ctx context.Context, imagesToProcess build.ImagesToProcess) error
}

wc := chart_extender.NewWerfChart(ctx, giterminismManager, nil, chartDir, helm_v3.Settings, helmRegistryClient, chart_extender.WerfChartOptions{
BuildChartDependenciesOpts: command_helpers.BuildChartDependenciesOptions{SkipUpdate: *commonCmdData.SkipDependenciesRepoRefresh},
ExtraAnnotations: userExtraAnnotations,
ExtraLabels: userExtraLabels,
IgnoreInvalidAnnotationsAndLabels: true,
Expand Down
3 changes: 3 additions & 0 deletions cmd/werf/bundle/publish/publish.go
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/werf/werf/pkg/deploy/bundles"
"github.com/werf/werf/pkg/deploy/helm/chart_extender"
"github.com/werf/werf/pkg/deploy/helm/chart_extender/helpers"
"github.com/werf/werf/pkg/deploy/helm/command_helpers"
"github.com/werf/werf/pkg/git_repo"
"github.com/werf/werf/pkg/git_repo/gitdata"
"github.com/werf/werf/pkg/image"
Expand Down Expand Up @@ -112,6 +113,7 @@ func NewCmd(ctx context.Context) *cobra.Command {
common.SetupValues(&commonCmdData, cmd)

commonCmdData.SetupDisableDefaultValues(cmd)
commonCmdData.SetupSkipDependenciesRepoRefresh(cmd)

common.SetupReportPath(&commonCmdData, cmd)
common.SetupReportFormat(&commonCmdData, cmd)
Expand Down Expand Up @@ -328,6 +330,7 @@ func runPublish(ctx context.Context, imagesToProcess build.ImagesToProcess) erro
}

wc := chart_extender.NewWerfChart(ctx, giterminismManager, nil, chartDir, helm_v3.Settings, helmRegistryClient, chart_extender.WerfChartOptions{
BuildChartDependenciesOpts: command_helpers.BuildChartDependenciesOptions{SkipUpdate: *commonCmdData.SkipDependenciesRepoRefresh},
ExtraAnnotations: userExtraAnnotations,
ExtraLabels: userExtraLabels,
IgnoreInvalidAnnotationsAndLabels: true,
Expand Down
7 changes: 7 additions & 0 deletions cmd/werf/common/cmd_data.go
Expand Up @@ -16,6 +16,8 @@ type CmdData struct {
HomeDir *string
SSHKeys *[]string

SkipDependenciesRepoRefresh *bool

HelmChartDir *string
Environment *string
Release *string
Expand Down Expand Up @@ -116,3 +118,8 @@ func (cmdData *CmdData) SetupDisableDefaultSecretValues(cmd *cobra.Command) {
cmdData.DisableDefaultSecretValues = new(bool)
cmd.Flags().BoolVarP(cmdData.DisableDefaultSecretValues, "disable-default-secret-values", "", util.GetBoolEnvironmentDefaultFalse("WERF_DISABLE_DEFAULT_SECRET_VALUES"), `Do not use secret values from the default .helm/secret-values.yaml file (default $WERF_DISABLE_DEFAULT_SECRET_VALUES or false)`)
}

func (cmdData *CmdData) SetupSkipDependenciesRepoRefresh(cmd *cobra.Command) {
cmdData.SkipDependenciesRepoRefresh = new(bool)
cmd.Flags().BoolVarP(cmdData.SkipDependenciesRepoRefresh, "skip-dependencies-repo-refresh", "L", util.GetBoolEnvironmentDefaultFalse("WERF_SKIP_DEPENDENCIES_REPO_REFRESH"), `Do not refresh helm chart repositories locally cached index`)
}
2 changes: 2 additions & 0 deletions cmd/werf/converge/converge.go
Expand Up @@ -157,6 +157,7 @@ werf converge --repo registry.mydomain.com/web --env production`,

commonCmdData.SetupDisableDefaultValues(cmd)
commonCmdData.SetupDisableDefaultSecretValues(cmd)
commonCmdData.SetupSkipDependenciesRepoRefresh(cmd)

common.SetupReportPath(&commonCmdData, cmd)
common.SetupReportFormat(&commonCmdData, cmd)
Expand Down Expand Up @@ -404,6 +405,7 @@ func run(ctx context.Context, containerBackend container_backend.ContainerBacken
}

wc := chart_extender.NewWerfChart(ctx, giterminismManager, secretsManager, chartDir, helm_v3.Settings, helmRegistryClient, chart_extender.WerfChartOptions{
BuildChartDependenciesOpts: command_helpers.BuildChartDependenciesOptions{SkipUpdate: *commonCmdData.SkipDependenciesRepoRefresh},
SecretValueFiles: common.GetSecretValues(&commonCmdData),
ExtraAnnotations: userExtraAnnotations,
ExtraLabels: userExtraLabels,
Expand Down
3 changes: 3 additions & 0 deletions cmd/werf/render/render.go
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/werf/werf/pkg/deploy/helm"
"github.com/werf/werf/pkg/deploy/helm/chart_extender"
"github.com/werf/werf/pkg/deploy/helm/chart_extender/helpers"
"github.com/werf/werf/pkg/deploy/helm/command_helpers"
"github.com/werf/werf/pkg/deploy/secrets_manager"
"github.com/werf/werf/pkg/git_repo"
"github.com/werf/werf/pkg/git_repo/gitdata"
Expand Down Expand Up @@ -134,6 +135,7 @@ func NewCmd(ctx context.Context) *cobra.Command {

commonCmdData.SetupDisableDefaultValues(cmd)
commonCmdData.SetupDisableDefaultSecretValues(cmd)
commonCmdData.SetupSkipDependenciesRepoRefresh(cmd)

common.SetupReportPath(&commonCmdData, cmd)
common.SetupReportFormat(&commonCmdData, cmd)
Expand Down Expand Up @@ -373,6 +375,7 @@ func runRender(ctx context.Context, imagesToProcess build.ImagesToProcess) error
}

wc := chart_extender.NewWerfChart(ctx, giterminismManager, secretsManager, chartDir, helm_v3.Settings, helmRegistryClient, chart_extender.WerfChartOptions{
BuildChartDependenciesOpts: command_helpers.BuildChartDependenciesOptions{SkipUpdate: *commonCmdData.SkipDependenciesRepoRefresh},
SecretValueFiles: common.GetSecretValues(&commonCmdData),
ExtraAnnotations: userExtraAnnotations,
ExtraLabels: userExtraLabels,
Expand Down
1 change: 1 addition & 0 deletions pkg/deploy/helm/chart_extender/werf_chart.go
Expand Up @@ -56,6 +56,7 @@ func NewWerfChart(ctx context.Context, giterminismManager giterminism_manager.In

DisableDefaultValues: opts.DisableDefaultValues,
DisableDefaultSecretValues: opts.DisableDefaultSecretValues,
BuildChartDependenciesOpts: opts.BuildChartDependenciesOpts,
}

wc.extraAnnotationsAndLabelsPostRenderer.Add(opts.ExtraAnnotations, opts.ExtraLabels)
Expand Down

0 comments on commit 39d004a

Please sign in to comment.