Skip to content

Commit 961c3f3

Browse files
authored
Merge pull request #639 from gianlucam76/release-0.34
Release 0.34
2 parents ea03178 + d2976f3 commit 961c3f3

31 files changed

+233
-298
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ARCH ?= $(shell go env GOARCH)
2525
OS ?= $(shell uname -s | tr A-Z a-z)
2626
K8S_LATEST_VER ?= $(shell curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)
2727
export CONTROLLER_IMG ?= $(REGISTRY)/$(IMAGE_NAME)
28-
TAG ?= v0.34.1
28+
TAG ?= v0.34.2
2929

3030
.PHONY: all
3131
all: build

config/default/manager_auth_proxy_patch.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ spec:
1515
- "--report-mode=0"
1616
- --shard-key=
1717
- "--v=5"
18-
- "--version=v0.34.1"
18+
- "--version=v0.34.2"

config/default/manager_image_patch.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ spec:
88
spec:
99
containers:
1010
# Change the value of image field below to your controller image URL
11-
- image: projectsveltos/addon-controller:v0.34.1
11+
- image: projectsveltos/addon-controller:v0.34.2
1212
name: controller

controllers/funcmap.go

Lines changed: 0 additions & 178 deletions
This file was deleted.

controllers/handlers_helm.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,29 +1634,33 @@ func getInstantiatedValues(ctx context.Context, clusterSummary *configv1beta1.Cl
16341634
}
16351635

16361636
c := getManagementClusterClient()
1637-
valuesFrom, err := getHelmChartValuesFrom(ctx, c, clusterSummary, requestedChart, logger)
1637+
templatedValuesFrom, valuesFrom, err := getHelmChartValuesFrom(ctx, c, clusterSummary, requestedChart, logger)
16381638
if err != nil {
16391639
return nil, err
16401640
}
16411641

1642-
for k := range valuesFrom {
1642+
for k := range templatedValuesFrom {
16431643
instantiatedValuesFrom, err := instantiateTemplateValues(ctx, getManagementClusterConfig(), getManagementClusterClient(),
16441644
clusterSummary.Spec.ClusterType, clusterSummary.Spec.ClusterNamespace, clusterSummary.Spec.ClusterName,
1645-
requestedChart.ChartName, valuesFrom[k], mgmtResources, logger)
1645+
requestedChart.ChartName, templatedValuesFrom[k], mgmtResources, logger)
16461646
if err != nil {
16471647
return nil, err
16481648
}
16491649
instantiatedValues += fmt.Sprintf("\n\n%s", instantiatedValuesFrom)
16501650
}
16511651

1652-
logger.V(logs.LogVerbose).Info(fmt.Sprintf("Deploying helm charts with Values %q", instantiatedValues))
1652+
for k := range valuesFrom {
1653+
instantiatedValues += fmt.Sprintf("\n\n%s", valuesFrom[k])
1654+
}
1655+
1656+
logger.V(logs.LogDebug).Info(fmt.Sprintf("Deploying helm charts with Values %q", instantiatedValues))
16531657

16541658
return chartutil.ReadValues([]byte(instantiatedValues))
16551659
}
16561660

16571661
// getHelmChartValuesFrom return key-value pair from referenced ConfigMap/Secret
16581662
func getHelmChartValuesFrom(ctx context.Context, c client.Client, clusterSummary *configv1beta1.ClusterSummary,
1659-
helmChart *configv1beta1.HelmChart, logger logr.Logger) (map[string]string, error) {
1663+
helmChart *configv1beta1.HelmChart, logger logr.Logger) (templatedValues, nonTemplatedValues map[string]string, err error) {
16601664

16611665
return getValuesFrom(ctx, c, clusterSummary, helmChart.ValuesFrom, false, logger)
16621666
}

controllers/handlers_kustomize.go

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import (
5151
libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1"
5252
"github.com/projectsveltos/libsveltos/lib/clusterproxy"
5353
"github.com/projectsveltos/libsveltos/lib/deployer"
54+
"github.com/projectsveltos/libsveltos/lib/funcmap"
5455
logs "github.com/projectsveltos/libsveltos/lib/logsettings"
5556
libsveltostemplate "github.com/projectsveltos/libsveltos/lib/template"
5657
"github.com/projectsveltos/libsveltos/lib/utils"
@@ -415,27 +416,30 @@ func instantiateKustomizeSubstituteValues(ctx context.Context, clusterSummary *c
415416

416417
// getKustomizeSubstituteValues returns all key-value pair looking at both Values and ValuesFrom
417418
func getKustomizeSubstituteValues(ctx context.Context, c client.Client, clusterSummary *configv1beta1.ClusterSummary,
418-
kustomizationRef *configv1beta1.KustomizationRef, logger logr.Logger) (map[string]string, error) {
419+
kustomizationRef *configv1beta1.KustomizationRef, logger logr.Logger) (templatedValues, nonTemplatedValues map[string]string, err error) {
419420

420421
values := make(map[string]string)
421422
for k := range kustomizationRef.Values {
422423
values[k] = kustomizationRef.Values[k]
423424
}
425+
424426
// Get key-value pairs from ValuesFrom
425-
valuesFrom, err := getKustomizeSubstituteValuesFrom(ctx, c, clusterSummary, kustomizationRef, logger)
427+
templatedValues, nonTemplatedValues, err = getKustomizeSubstituteValuesFrom(ctx, c, clusterSummary, kustomizationRef, logger)
426428
if err != nil {
427-
return nil, err
429+
return nil, nil, err
428430
}
429-
for k := range valuesFrom {
430-
values[k] = valuesFrom[k]
431+
432+
// Values are always treated as templates. So copy the templated values here
433+
for k := range templatedValues {
434+
values[k] = templatedValues[k]
431435
}
432436

433-
return values, nil
437+
return values, nonTemplatedValues, nil
434438
}
435439

436440
// getKustomizeSubstituteValuesFrom return key-value pair from referenced ConfigMap/Secret
437441
func getKustomizeSubstituteValuesFrom(ctx context.Context, c client.Client, clusterSummary *configv1beta1.ClusterSummary,
438-
kustomizationRef *configv1beta1.KustomizationRef, logger logr.Logger) (map[string]string, error) {
442+
kustomizationRef *configv1beta1.KustomizationRef, logger logr.Logger) (templatedValues, nonTemplatedValues map[string]string, err error) {
439443

440444
return getValuesFrom(ctx, c, clusterSummary, kustomizationRef.ValuesFrom, true, logger)
441445
}
@@ -615,18 +619,21 @@ func getKustomizedResources(ctx context.Context, c client.Client, clusterSummary
615619
}
616620

617621
// Get key-value pairs from ValuesFrom
618-
values, err := getKustomizeSubstituteValues(ctx, c, clusterSummary, kustomizationRef, logger)
622+
templatedValues, nonTemplatedValues, err := getKustomizeSubstituteValues(ctx, c, clusterSummary, kustomizationRef, logger)
619623
if err != nil {
620624
return nil, nil, nil, err
621625
}
622626

623627
// Get substitute values. Those are collected from Data sections of referenced ConfigMap/Secret instances.
624-
// Those values can be expressed as template. This method collects them and instantiate those using resources in
628+
// Those values can be expressed as template. This method instantiates those using resources in
625629
// the managemenet cluster
626-
instantiateSubstituteValues, err := instantiateKustomizeSubstituteValues(ctx, clusterSummary, mgmtResources, values, logger)
630+
instantiatedSubstituteValues, err := instantiateKustomizeSubstituteValues(ctx, clusterSummary, mgmtResources, templatedValues, logger)
627631
if err != nil {
628632
return nil, nil, nil, err
629633
}
634+
for k := range nonTemplatedValues {
635+
instantiatedSubstituteValues[k] = nonTemplatedValues[k]
636+
}
630637

631638
resources := resMap.Resources()
632639
for i := range resources {
@@ -638,11 +645,11 @@ func getKustomizedResources(ctx context.Context, c client.Client, clusterSummary
638645
}
639646

640647
// Assume it is a template only if there are values to substitute
641-
if len(instantiateSubstituteValues) > 0 {
648+
if len(instantiatedSubstituteValues) > 0 {
642649
// All objects coming from Kustomize output can be expressed as template. Those will be instantiated using
643650
// substitute values first, and the resource in the management cluster later.
644651
templateName := fmt.Sprintf("%s-substitutevalues", clusterSummary.Name)
645-
yaml, err = instantiateResourceWithSubstituteValues(templateName, yaml, instantiateSubstituteValues, logger)
652+
yaml, err = instantiateResourceWithSubstituteValues(templateName, yaml, instantiatedSubstituteValues, logger)
646653
if err != nil {
647654
msg := fmt.Sprintf("failed to instantiate resource with substitute values: %v", err)
648655
logger.V(logs.LogInfo).Info(msg)
@@ -882,7 +889,7 @@ func extractTarGz(src, dest string) error {
882889
func instantiateResourceWithSubstituteValues(templateName string, resource []byte,
883890
substituteValues map[string]string, logger logr.Logger) ([]byte, error) {
884891

885-
tmpl, err := template.New(templateName).Option("missingkey=error").Funcs(ExtraFuncMap()).Parse(string(resource))
892+
tmpl, err := template.New(templateName).Option("missingkey=error").Funcs(funcmap.SveltosFuncMap()).Parse(string(resource))
886893
if err != nil {
887894
return nil, err
888895
}

0 commit comments

Comments
 (0)