mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-13 01:50:55 +00:00
Add kustomize build flag --enable_managedby_label
This commit is contained in:
@@ -30,4 +30,10 @@ const (
|
||||
|
||||
// A program name, for use in help, finding the XDG_CONFIG_DIR, etc.
|
||||
ProgramName = "kustomize"
|
||||
|
||||
// Label key that indicates the resources are built from Kustomize
|
||||
ManagedbyLabelKey = "app.kubernetes.io/managed-by"
|
||||
|
||||
// An environment variable to turn on/off adding the ManagedByLabelKey
|
||||
EnableManagedbyLabelEnv = "KUSTOMIZE_ENABLE_MANAGEDBY_LABEL"
|
||||
)
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"sigs.k8s.io/kustomize/api/internal/target"
|
||||
"sigs.k8s.io/kustomize/api/k8sdeps/kunstruct"
|
||||
"sigs.k8s.io/kustomize/api/k8sdeps/validator"
|
||||
"sigs.k8s.io/kustomize/api/konfig"
|
||||
fLdr "sigs.k8s.io/kustomize/api/loader"
|
||||
"sigs.k8s.io/kustomize/api/provenance"
|
||||
"sigs.k8s.io/kustomize/api/resmap"
|
||||
@@ -20,10 +21,6 @@ import (
|
||||
"sigs.k8s.io/kustomize/api/types"
|
||||
)
|
||||
|
||||
const (
|
||||
managedbyLabelKey = "app.kubernetes.io/managed-by"
|
||||
)
|
||||
|
||||
// Kustomizer performs kustomizations. It's meant to behave
|
||||
// similarly to the kustomize CLI, and can be used instead of
|
||||
// performing an exec to a kustomize CLI subprocess.
|
||||
@@ -87,7 +84,7 @@ func (b *Kustomizer) Run(path string) (resmap.ResMap, error) {
|
||||
}
|
||||
if b.options.AddManagedbyLabel {
|
||||
t := builtins.LabelTransformerPlugin{
|
||||
Labels: map[string]string{managedbyLabelKey: fmt.Sprintf("kustomize-%s", provenance.GetProvenance().Version)},
|
||||
Labels: map[string]string{konfig.ManagedbyLabelKey: fmt.Sprintf("kustomize-%s", provenance.GetProvenance().Version)},
|
||||
FieldSpecs: []types.FieldSpec{{
|
||||
Path: "metadata/labels",
|
||||
CreateIfNotPresent: true,
|
||||
|
||||
Reference in New Issue
Block a user