Skip to content

Commit

Permalink
fix(bundles): --secret-values option for bundle-render command
Browse files Browse the repository at this point in the history
+ Fix panic when null-value in secret-values.yaml exist.

Refs #4600

Signed-off-by: Timofey Kirillov <timofey.kirillov@flant.com>
  • Loading branch information
distorhead committed Jul 13, 2022
1 parent 28ee542 commit f722ec9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion cmd/werf/bundle/render/render.go
Expand Up @@ -21,6 +21,7 @@ import (
"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/storage"
"github.com/werf/werf/pkg/util"
"github.com/werf/werf/pkg/werf"
Expand Down Expand Up @@ -85,6 +86,8 @@ func NewCmd(ctx context.Context) *cobra.Command {
common.SetupSetString(&commonCmdData, cmd)
common.SetupSetFile(&commonCmdData, cmd)
common.SetupValues(&commonCmdData, cmd)
common.SetupSecretValues(&commonCmdData, cmd)
common.SetupIgnoreSecretKey(&commonCmdData, cmd)

common.SetupRelease(&commonCmdData, cmd)
common.SetupNamespace(&commonCmdData, cmd)
Expand Down Expand Up @@ -184,7 +187,10 @@ func runRender(ctx context.Context) error {
userExtraAnnotations["project.werf.io/env"] = *commonCmdData.Environment
}

bundle, err := chart_extender.NewBundle(ctx, bundleDir, helm_v3.Settings, helmRegistryClientHandle, nil, chart_extender.BundleOptions{
secretsManager := secrets_manager.NewSecretsManager(secrets_manager.SecretsManagerOptions{DisableSecretsDecryption: *commonCmdData.IgnoreSecretKey})

bundle, err := chart_extender.NewBundle(ctx, bundleDir, helm_v3.Settings, helmRegistryClientHandle, secretsManager, chart_extender.BundleOptions{
SecretValueFiles: common.GetSecretValues(&commonCmdData),
BuildChartDependenciesOpts: command_helpers.BuildChartDependenciesOptions{IgnoreInvalidAnnotationsAndLabels: false},
IgnoreInvalidAnnotationsAndLabels: false,
ExtraAnnotations: userExtraAnnotations,
Expand Down
7 changes: 6 additions & 1 deletion pkg/util/secretvalues/mask.go
Expand Up @@ -15,7 +15,12 @@ func ExtractSecretValuesFromMap(data map[string]interface{}) []string {
var elemI interface{}
elemI, queue = queue[0], queue[1:]

switch reflect.TypeOf(elemI).Kind() {
elemType := reflect.TypeOf(elemI)
if elemType == nil {
continue
}

switch elemType.Kind() {
case reflect.Slice, reflect.Array:
elem := reflect.ValueOf(elemI)
for i := 0; i < elem.Len(); i++ {
Expand Down

0 comments on commit f722ec9

Please sign in to comment.