fix invalid managed-by label value

This commit is contained in:
Donny Xia
2020-11-16 14:00:14 -08:00
parent a25429ae3b
commit 98900c43f7
2 changed files with 10 additions and 1 deletions

View File

@@ -85,7 +85,7 @@ func (b *Kustomizer) Run(path string) (resmap.ResMap, error) {
t := builtins.LabelTransformerPlugin{ t := builtins.LabelTransformerPlugin{
Labels: map[string]string{ Labels: map[string]string{
konfig.ManagedbyLabelKey: fmt.Sprintf( konfig.ManagedbyLabelKey: fmt.Sprintf(
"kustomize-%s", provenance.GetProvenance().Version)}, "kustomize-%s", provenance.GetProvenance().Semver())},
FieldSpecs: []types.FieldSpec{{ FieldSpecs: []types.FieldSpec{{
Path: "metadata/labels", Path: "metadata/labels",
CreateIfNotPresent: true, CreateIfNotPresent: true,

View File

@@ -6,6 +6,7 @@ package provenance
import ( import (
"fmt" "fmt"
"runtime" "runtime"
"strings"
) )
var ( var (
@@ -57,3 +58,11 @@ func (v Provenance) Short() string {
BuildDate: v.BuildDate, BuildDate: v.BuildDate,
}) })
} }
// Semver returns the semantic version of kustomize.
// kustomize version is set in format "kustomize/vX.X.X" in every release.
// X.X.X is a semver. If the version string is not in this format,
// return the original version string
func (v Provenance) Semver() string {
return strings.TrimPrefix(v.Version, "kustomize/")
}