mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-09-15 12:18:57 +00:00
Manage name changes (prefix/suffix) via YAML annotations rather than via in-memory-only fields.
This commit is contained in:
@@ -6,7 +6,6 @@ package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"sigs.k8s.io/kustomize/api/filters/prefixsuffix"
|
||||
"sigs.k8s.io/kustomize/api/resid"
|
||||
"sigs.k8s.io/kustomize/api/resmap"
|
||||
@@ -70,8 +69,12 @@ func (p *plugin) Transform(m resmap.ResMap) error {
|
||||
// this will add a prefix and a suffix
|
||||
// to the resource even if those are
|
||||
// empty
|
||||
|
||||
r.AddNamePrefix(p.Prefix)
|
||||
r.AddNameSuffix(p.Suffix)
|
||||
if p.Prefix != "" || p.Suffix != "" {
|
||||
r.SetOriginalName(r.GetName(), false)
|
||||
}
|
||||
}
|
||||
err := r.ApplyFilter(prefixsuffix.Filter{
|
||||
Prefix: p.Prefix,
|
||||
|
||||
@@ -62,6 +62,10 @@ metadata:
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
annotations:
|
||||
config.kubernetes.io/originalName: apple
|
||||
config.kubernetes.io/prefixes: baked-
|
||||
config.kubernetes.io/suffixes: -pie
|
||||
name: baked-apple-pie
|
||||
spec:
|
||||
ports:
|
||||
@@ -80,6 +84,10 @@ metadata:
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
annotations:
|
||||
config.kubernetes.io/originalName: cm
|
||||
config.kubernetes.io/prefixes: baked-
|
||||
config.kubernetes.io/suffixes: -pie
|
||||
name: baked-cm-pie
|
||||
`)
|
||||
|
||||
@@ -126,6 +134,10 @@ metadata:
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
annotations:
|
||||
config.kubernetes.io/originalName: deployment
|
||||
config.kubernetes.io/prefixes: test-
|
||||
config.kubernetes.io/suffixes: null
|
||||
name: test-deployment
|
||||
spec:
|
||||
template:
|
||||
|
||||
Reference in New Issue
Block a user