mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-12 01:14:22 +00:00
support krm spec v1 and legacy path, index, and id annotations
This commit is contained in:
@@ -165,6 +165,10 @@ func (f *FileSetter) Filter(input []*yaml.RNode) ([]*yaml.RNode, error) {
|
||||
|
||||
resources := map[string][]*yaml.RNode{}
|
||||
for i := range input {
|
||||
if err := kioutil.CopyLegacyAnnotations(input[i]); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
m, err := input[i].GetMeta()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -178,6 +182,9 @@ func (f *FileSetter) Filter(input []*yaml.RNode) ([]*yaml.RNode, error) {
|
||||
if _, err := input[i].Pipe(yaml.SetAnnotation(kioutil.PathAnnotation, file)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if _, err := input[i].Pipe(yaml.SetAnnotation(kioutil.LegacyPathAnnotation, file)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
resources[file] = append(resources[file], input[i])
|
||||
}
|
||||
@@ -192,6 +199,10 @@ func (f *FileSetter) Filter(input []*yaml.RNode) ([]*yaml.RNode, error) {
|
||||
yaml.SetAnnotation(kioutil.IndexAnnotation, fmt.Sprintf("%d", j))); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if _, err := resources[i][j].Pipe(
|
||||
yaml.SetAnnotation(kioutil.LegacyIndexAnnotation, fmt.Sprintf("%d", j))); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
output = append(output, resources[i][j])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ metadata:
|
||||
name: foo1
|
||||
namespace: bar
|
||||
annotations:
|
||||
internal.config.kubernetes.io/path: 'foo1_deployment.yaml'
|
||||
config.kubernetes.io/path: 'foo1_deployment.yaml'
|
||||
---
|
||||
apiVersion: v1
|
||||
@@ -60,6 +61,7 @@ kind: Service
|
||||
metadata:
|
||||
name: foo1
|
||||
annotations:
|
||||
internal.config.kubernetes.io/path: 'foo1_service.yaml'
|
||||
config.kubernetes.io/path: 'foo1_service.yaml'
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
@@ -67,6 +69,7 @@ kind: Deployment
|
||||
metadata:
|
||||
name: foo2
|
||||
annotations:
|
||||
internal.config.kubernetes.io/path: 'foo2_deployment.yaml'
|
||||
config.kubernetes.io/path: 'foo2_deployment.yaml'
|
||||
---
|
||||
apiVersion: v1
|
||||
@@ -75,6 +78,7 @@ metadata:
|
||||
name: foo2
|
||||
namespace: bar
|
||||
annotations:
|
||||
internal.config.kubernetes.io/path: 'foo2_service.yaml'
|
||||
config.kubernetes.io/path: 'foo2_service.yaml'
|
||||
`, out.String())
|
||||
}
|
||||
@@ -97,6 +101,7 @@ kind: Service
|
||||
metadata:
|
||||
name: foo1
|
||||
annotations:
|
||||
internal.config.kubernetes.io/path: 'foo1__service.yaml'
|
||||
config.kubernetes.io/path: 'foo1__service.yaml'
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
@@ -105,6 +110,7 @@ metadata:
|
||||
name: foo1
|
||||
namespace: bar
|
||||
annotations:
|
||||
internal.config.kubernetes.io/path: 'foo1_bar_deployment.yaml'
|
||||
config.kubernetes.io/path: 'foo1_bar_deployment.yaml'
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
@@ -112,6 +118,7 @@ kind: Deployment
|
||||
metadata:
|
||||
name: foo2
|
||||
annotations:
|
||||
internal.config.kubernetes.io/path: 'foo2__deployment.yaml'
|
||||
config.kubernetes.io/path: 'foo2__deployment.yaml'
|
||||
---
|
||||
apiVersion: v1
|
||||
@@ -120,6 +127,7 @@ metadata:
|
||||
name: foo2
|
||||
namespace: bar
|
||||
annotations:
|
||||
internal.config.kubernetes.io/path: 'foo2_bar_service.yaml'
|
||||
config.kubernetes.io/path: 'foo2_bar_service.yaml'
|
||||
`, out.String())
|
||||
}
|
||||
@@ -143,6 +151,7 @@ metadata:
|
||||
name: foo1
|
||||
namespace: bar
|
||||
annotations:
|
||||
internal.config.kubernetes.io/path: 'resource.yaml'
|
||||
config.kubernetes.io/path: 'resource.yaml'
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
@@ -150,6 +159,7 @@ kind: Deployment
|
||||
metadata:
|
||||
name: foo2
|
||||
annotations:
|
||||
internal.config.kubernetes.io/path: 'resource.yaml'
|
||||
config.kubernetes.io/path: 'resource.yaml'
|
||||
---
|
||||
apiVersion: v1
|
||||
@@ -158,6 +168,7 @@ metadata:
|
||||
name: foo2
|
||||
namespace: bar
|
||||
annotations:
|
||||
internal.config.kubernetes.io/path: 'resource.yaml'
|
||||
config.kubernetes.io/path: 'resource.yaml'
|
||||
---
|
||||
apiVersion: v1
|
||||
@@ -165,6 +176,7 @@ kind: Service
|
||||
metadata:
|
||||
name: foo1
|
||||
annotations:
|
||||
internal.config.kubernetes.io/path: 'resource.yaml'
|
||||
config.kubernetes.io/path: 'resource.yaml'
|
||||
`, out.String())
|
||||
}
|
||||
|
||||
@@ -173,6 +173,12 @@ func (dm *DefaultGVKNNMatcher) IsSameResource(node1, node2 *yaml.RNode) bool {
|
||||
if node1 == nil || node2 == nil {
|
||||
return false
|
||||
}
|
||||
if err := kioutil.CopyLegacyAnnotations(node1); err != nil {
|
||||
return false
|
||||
}
|
||||
if err := kioutil.CopyLegacyAnnotations(node2); err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
meta1, err := node1.GetMeta()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user