Skip to content

Commit

Permalink
feat(values): env WERF_EXPERIMENT_NO_GLOBAL_SERVICE_VALUES=1 will dis…
Browse files Browse the repository at this point in the history
…able global service values

Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
  • Loading branch information
ilya-lesikov committed May 20, 2024
1 parent 97fa211 commit 3949b70
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions pkg/deploy/helm/chart_extender/helpers/service_values.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

"github.com/werf/logboek"
"github.com/werf/werf/v2/pkg/image"
"github.com/werf/werf/v2/pkg/util"
"github.com/werf/werf/v2/pkg/werf"
)

Expand Down Expand Up @@ -47,10 +48,15 @@ type ServiceValuesOptions struct {
}

func GetEnvServiceValues(env string) map[string]interface{} {
return map[string]interface{}{
"werf": map[string]interface{}{"env": env},
"global": map[string]interface{}{"env": env},
result := map[string]interface{}{
"werf": map[string]interface{}{"env": env},
}

if exposeGlobalServiceValues() {
result["global"] = map[string]interface{}{"env": env}
}

return result
}

func GetServiceValues(ctx context.Context, projectName, repo string, imageInfoGetters []*image.InfoGetter, opts ServiceValuesOptions) (map[string]interface{}, error) {
Expand Down Expand Up @@ -114,8 +120,11 @@ func GetServiceValues(ctx context.Context, projectName, repo string, imageInfoGe
}

res := map[string]interface{}{
"werf": werfInfo,
"global": globalInfo,
"werf": werfInfo,
}

if exposeGlobalServiceValues() {
res["global"] = globalInfo
}

if opts.SetDockerConfigJsonValue {
Expand Down Expand Up @@ -151,8 +160,11 @@ func GetBundleServiceValues(ctx context.Context, opts ServiceValuesOptions) (map
}

res := map[string]interface{}{
"werf": werfInfo,
"global": globalInfo,
"werf": werfInfo,
}

if exposeGlobalServiceValues() {
res["global"] = globalInfo
}

if opts.SetDockerConfigJsonValue {
Expand Down Expand Up @@ -193,3 +205,8 @@ func writeDockerConfigJsonValue(ctx context.Context, values map[string]interface

return nil
}

// TODO(3.0): remove global service values completely
func exposeGlobalServiceValues() bool {
return !util.GetBoolEnvironmentDefaultFalse("WERF_EXPERIMENT_NO_GLOBAL_SERVICE_VALUES")
}

0 comments on commit 3949b70

Please sign in to comment.