Skip to content

Commit

Permalink
Use MergeMaps from lib-helm (#3)
Browse files Browse the repository at this point in the history
Signed-off-by: Rokibul Hasan <mdrokibulhasan@appscode.com>
  • Loading branch information
RokibulHasan7 authored Oct 8, 2024
1 parent 1231b99 commit 3772c1e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
6 changes: 3 additions & 3 deletions pkg/feature_installer/enable_featureset.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import (
"kubepack.dev/lib-app/pkg/editor"
"kubepack.dev/lib-app/pkg/handler"
"kubepack.dev/lib-helm/pkg/repo"
"kubepack.dev/lib-helm/pkg/values"
workv1 "open-cluster-management.io/api/work/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
Expand Down Expand Up @@ -163,8 +164,7 @@ func enableFeatureSet(ctx context.Context, kc client.Client, featureSet string,
return err
}

mergedValues := utils.MergeMaps(defaultValues, overrideValues)

mergedValues := values.MergeMaps(defaultValues, overrideValues)
if err = createHR("opscenter-features", "opscenter-core", hub.BootstrapHelmRepositoryNamespace(), profile, featureObj, fakeServer, mergedValues); err != nil {
return err
}
Expand Down Expand Up @@ -209,7 +209,7 @@ func applyFeatureSet(ctx context.Context, kc client.Client, mw *workv1.ManifestW
return err
}
}
finalValues := utils.MergeMaps(curValues, valuesMap)
finalValues := values.MergeMaps(curValues, valuesMap)
if err = unstructured.SetNestedMap(model, finalValues, "resources", featureKey, "spec", "values"); err != nil {
return err
}
Expand Down
17 changes: 0 additions & 17 deletions pkg/utils/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,3 @@ func Copy(src any, dst any) error {
}
return json.Unmarshal(jsonByte, dst)
}

// MergeMaps merges the default and override maps, with values from the override map taking precedence.
func MergeMaps(defaults, overrides map[string]interface{}) map[string]interface{} {
merged := make(map[string]interface{})

// First, copy all default values into the merged map.
for key, value := range defaults {
merged[key] = value
}

// Now, override with values from the overrides map.
for key, value := range overrides {
merged[key] = value
}

return merged
}

0 comments on commit 3772c1e

Please sign in to comment.