mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-13 01:50:55 +00:00
Refactored resource to store all previous names and namespaces
This commit is contained in:
@@ -32,7 +32,7 @@ func (p *plugin) Transform(m resmap.ResMap) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
res.SetOriginalName(res.GetName(), false)
|
||||
res.StorePreviousId()
|
||||
res.SetName(fmt.Sprintf("%s-%s", res.GetName(), h))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ func (p *plugin) Transform(m resmap.ResMap) error {
|
||||
// Don't mutate empty objects?
|
||||
continue
|
||||
}
|
||||
r.SetOriginalNs(r.GetNamespace(), false)
|
||||
r.StorePreviousId()
|
||||
err := r.ApplyFilter(namespace.Filter{
|
||||
Namespace: p.Namespace,
|
||||
FsSlice: p.FieldSpecs,
|
||||
|
||||
@@ -108,7 +108,7 @@ func (p *plugin) transformJson6902(m resmap.ResMap, patch jsonpatch.Patch) error
|
||||
return err
|
||||
}
|
||||
for _, res := range resources {
|
||||
res.SetOriginalName(res.GetName(), false)
|
||||
res.StorePreviousId()
|
||||
err = res.ApplyFilter(patchjson6902.Filter{
|
||||
Patch: p.Patch,
|
||||
})
|
||||
|
||||
@@ -73,7 +73,7 @@ func (p *plugin) Transform(m resmap.ResMap) error {
|
||||
r.AddNamePrefix(p.Prefix)
|
||||
r.AddNameSuffix(p.Suffix)
|
||||
if p.Prefix != "" || p.Suffix != "" {
|
||||
r.SetOriginalName(r.GetName(), false)
|
||||
r.StorePreviousId()
|
||||
}
|
||||
}
|
||||
err := r.ApplyFilter(prefixsuffix.Filter{
|
||||
|
||||
@@ -64,6 +64,7 @@ kind: Service
|
||||
metadata:
|
||||
annotations:
|
||||
config.kubernetes.io/originalName: apple
|
||||
config.kubernetes.io/originalNs: default
|
||||
config.kubernetes.io/prefixes: baked-
|
||||
config.kubernetes.io/suffixes: -pie
|
||||
name: baked-apple-pie
|
||||
@@ -86,6 +87,7 @@ kind: ConfigMap
|
||||
metadata:
|
||||
annotations:
|
||||
config.kubernetes.io/originalName: cm
|
||||
config.kubernetes.io/originalNs: default
|
||||
config.kubernetes.io/prefixes: baked-
|
||||
config.kubernetes.io/suffixes: -pie
|
||||
name: baked-cm-pie
|
||||
@@ -136,6 +138,7 @@ kind: Deployment
|
||||
metadata:
|
||||
annotations:
|
||||
config.kubernetes.io/originalName: deployment
|
||||
config.kubernetes.io/originalNs: default
|
||||
config.kubernetes.io/prefixes: test-
|
||||
name: test-deployment
|
||||
spec:
|
||||
|
||||
@@ -35,9 +35,7 @@ func (p *plugin) Transform(m resmap.ResMap) error {
|
||||
found := false
|
||||
for _, fs := range p.FieldSpecs {
|
||||
matcher := p.createMatcher(fs)
|
||||
matchOriginal := m.GetMatchingResourcesByOriginalId(matcher)
|
||||
resList := append(
|
||||
matchOriginal, m.GetMatchingResourcesByCurrentId(matcher)...)
|
||||
resList := m.GetMatchingResourcesByAnyId(matcher)
|
||||
if len(resList) > 0 {
|
||||
found = true
|
||||
for _, r := range resList {
|
||||
|
||||
Reference in New Issue
Block a user