Merge pull request #344 from mengqiy/namehash
appending name hash only applies to current layer
This commit is contained in:
commit
08f3abb5bc
|
|
@ -83,6 +83,16 @@ func (a *applicationImpl) Resources() (types.ResourceCollection, error) {
|
||||||
} else {
|
} else {
|
||||||
resources = append(resources, secrets...)
|
resources = append(resources, secrets...)
|
||||||
}
|
}
|
||||||
|
res, err := resourceCollectionFromResources(resources)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
// Only append hash for generated configmaps and secrets.
|
||||||
|
nht := transformers.NewNameHashTransformer()
|
||||||
|
err = nht.Transform(types.KObject(res))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
ps, err := resource.NewFromPaths(a.loader, a.manifest.Patches)
|
ps, err := resource.NewFromPaths(a.loader, a.manifest.Patches)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -98,11 +108,7 @@ func (a *applicationImpl) Resources() (types.ResourceCollection, error) {
|
||||||
return nil, errs
|
return nil, errs
|
||||||
}
|
}
|
||||||
|
|
||||||
allResources, err := resourceCollectionFromResources(resources)
|
err = types.Merge(res, raw)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
err = types.Merge(allResources, raw)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -111,11 +117,11 @@ func (a *applicationImpl) Resources() (types.ResourceCollection, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
err = t.Transform(types.KObject(allResources))
|
err = t.Transform(types.KObject(res))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return allResources, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RawResources computes and returns the raw resources from the manifest.
|
// RawResources computes and returns the raw resources from the manifest.
|
||||||
|
|
@ -164,18 +170,14 @@ func (a *applicationImpl) subAppResources() (types.ResourceCollection, *interror
|
||||||
}
|
}
|
||||||
|
|
||||||
// getTransformer generates the following transformers:
|
// getTransformer generates the following transformers:
|
||||||
// 1) append hash for configmaps ans secrets
|
// 1) apply overlay
|
||||||
// 2) apply overlay
|
// 2) name prefix
|
||||||
// 3) name prefix
|
// 3) apply labels
|
||||||
// 4) apply labels
|
// 4) apply annotations
|
||||||
// 5) apply annotations
|
// 5) update name reference
|
||||||
// 6) update name reference
|
|
||||||
func (a *applicationImpl) getTransformer(patches types.ResourceCollection) (transformers.Transformer, error) {
|
func (a *applicationImpl) getTransformer(patches types.ResourceCollection) (transformers.Transformer, error) {
|
||||||
ts := []transformers.Transformer{}
|
ts := []transformers.Transformer{}
|
||||||
|
|
||||||
nht := transformers.NewNameHashTransformer()
|
|
||||||
ts = append(ts, nht)
|
|
||||||
|
|
||||||
ot, err := transformers.NewOverlayTransformer(types.KObject(patches))
|
ot, err := transformers.NewOverlayTransformer(types.KObject(patches))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ diff -u -N /tmp/noop/apps_v1beta2_Deployment_nginx.yaml /tmp/transformed/apps_v1
|
||||||
org: example.com
|
org: example.com
|
||||||
team: foo
|
team: foo
|
||||||
spec:
|
spec:
|
||||||
@@ -30,5 +33,6 @@
|
@@ -30,8 +33,12 @@
|
||||||
- mountPath: /tmp/ps
|
- mountPath: /tmp/ps
|
||||||
name: nginx-persistent-storage
|
name: nginx-persistent-storage
|
||||||
volumes:
|
volumes:
|
||||||
|
|
@ -34,6 +34,37 @@ diff -u -N /tmp/noop/apps_v1beta2_Deployment_nginx.yaml /tmp/transformed/apps_v1
|
||||||
+ - gcePersistentDisk:
|
+ - gcePersistentDisk:
|
||||||
+ pdName: nginx-persistent-storage
|
+ pdName: nginx-persistent-storage
|
||||||
name: nginx-persistent-storage
|
name: nginx-persistent-storage
|
||||||
|
- configMap:
|
||||||
|
+ name: staging-configmap-in-overlay-h4hbb8fckf
|
||||||
|
+ name: configmap-in-overlay
|
||||||
|
+ - configMap:
|
||||||
|
name: team-foo-configmap-in-base-72t84tc949
|
||||||
|
name: configmap-in-base
|
||||||
|
diff -u -N /tmp/noop/v1_ConfigMap_configmap-in-base.yaml /tmp/transformed/v1_ConfigMap_configmap-in-base.yaml
|
||||||
|
--- /tmp/noop/v1_ConfigMap_configmap-in-base.yaml YYYY-MM-DD HH:MM:SS
|
||||||
|
+++ /tmp/transformed/v1_ConfigMap_configmap-in-base.yaml YYYY-MM-DD HH:MM:SS
|
||||||
|
@@ -8,6 +8,7 @@
|
||||||
|
creationTimestamp: null
|
||||||
|
labels:
|
||||||
|
app: mynginx
|
||||||
|
+ env: staging
|
||||||
|
org: example.com
|
||||||
|
team: foo
|
||||||
|
- name: team-foo-configmap-in-base-72t84tc949
|
||||||
|
+ name: staging-team-foo-configmap-in-base-72t84tc949
|
||||||
|
diff -u -N /tmp/noop/v1_ConfigMap_configmap-in-overlay.yaml /tmp/transformed/v1_ConfigMap_configmap-in-overlay.yaml
|
||||||
|
--- /tmp/noop/v1_ConfigMap_configmap-in-overlay.yaml YYYY-MM-DD HH:MM:SS
|
||||||
|
+++ /tmp/transformed/v1_ConfigMap_configmap-in-overlay.yaml YYYY-MM-DD HH:MM:SS
|
||||||
|
@@ -0,0 +1,9 @@
|
||||||
|
+apiVersion: v1
|
||||||
|
+data:
|
||||||
|
+ hello: world
|
||||||
|
+kind: ConfigMap
|
||||||
|
+metadata:
|
||||||
|
+ creationTimestamp: null
|
||||||
|
+ labels:
|
||||||
|
+ env: staging
|
||||||
|
+ name: staging-configmap-in-overlay-h4hbb8fckf
|
||||||
diff -u -N /tmp/noop/v1_Service_nginx.yaml /tmp/transformed/v1_Service_nginx.yaml
|
diff -u -N /tmp/noop/v1_Service_nginx.yaml /tmp/transformed/v1_Service_nginx.yaml
|
||||||
--- /tmp/noop/v1_Service_nginx.yaml YYYY-MM-DD HH:MM:SS
|
--- /tmp/noop/v1_Service_nginx.yaml YYYY-MM-DD HH:MM:SS
|
||||||
+++ /tmp/transformed/v1_Service_nginx.yaml YYYY-MM-DD HH:MM:SS
|
+++ /tmp/transformed/v1_Service_nginx.yaml YYYY-MM-DD HH:MM:SS
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,29 @@
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
foo: bar
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
note: This is a test annotation
|
||||||
|
creationTimestamp: null
|
||||||
|
labels:
|
||||||
|
app: mynginx
|
||||||
|
env: staging
|
||||||
|
org: example.com
|
||||||
|
team: foo
|
||||||
|
name: staging-team-foo-configmap-in-base-72t84tc949
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
hello: world
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
labels:
|
||||||
|
env: staging
|
||||||
|
name: staging-configmap-in-overlay-h4hbb8fckf
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
annotations:
|
annotations:
|
||||||
|
|
@ -56,3 +81,9 @@ spec:
|
||||||
- gcePersistentDisk:
|
- gcePersistentDisk:
|
||||||
pdName: nginx-persistent-storage
|
pdName: nginx-persistent-storage
|
||||||
name: nginx-persistent-storage
|
name: nginx-persistent-storage
|
||||||
|
- configMap:
|
||||||
|
name: staging-configmap-in-overlay-h4hbb8fckf
|
||||||
|
name: configmap-in-overlay
|
||||||
|
- configMap:
|
||||||
|
name: team-foo-configmap-in-base-72t84tc949
|
||||||
|
name: configmap-in-base
|
||||||
|
|
|
||||||
|
|
@ -10,3 +10,7 @@ patches:
|
||||||
- deployment.yaml
|
- deployment.yaml
|
||||||
packages:
|
packages:
|
||||||
- ../package/
|
- ../package/
|
||||||
|
configmaps:
|
||||||
|
- name: configmap-in-overlay
|
||||||
|
literals:
|
||||||
|
- hello=world
|
||||||
|
|
|
||||||
|
|
@ -10,3 +10,6 @@ spec:
|
||||||
emptyDir: null
|
emptyDir: null
|
||||||
gcePersistentDisk:
|
gcePersistentDisk:
|
||||||
pdName: nginx-persistent-storage
|
pdName: nginx-persistent-storage
|
||||||
|
- configMap:
|
||||||
|
name: configmap-in-overlay
|
||||||
|
name: configmap-in-overlay
|
||||||
|
|
|
||||||
|
|
@ -13,3 +13,7 @@ objectAnnotations:
|
||||||
resources:
|
resources:
|
||||||
- deployment.yaml
|
- deployment.yaml
|
||||||
- service.yaml
|
- service.yaml
|
||||||
|
configmaps:
|
||||||
|
- name: configmap-in-base
|
||||||
|
literals:
|
||||||
|
- foo=bar
|
||||||
|
|
|
||||||
|
|
@ -18,4 +18,7 @@ spec:
|
||||||
mountPath: /tmp/ps
|
mountPath: /tmp/ps
|
||||||
volumes:
|
volumes:
|
||||||
- name: nginx-persistent-storage
|
- name: nginx-persistent-storage
|
||||||
emptyDir: {}
|
emptyDir: {}
|
||||||
|
- configMap:
|
||||||
|
name: configmap-in-base
|
||||||
|
name: configmap-in-base
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue