remove metadata.creationTimestamp field from configMapGenerator

This commit is contained in:
liuhuiping
2018-09-18 18:10:45 +08:00
committed by levis.liu
parent 58492e2d83
commit 6c5a75bf73
12 changed files with 12 additions and 25 deletions

1
.gitignore vendored
View File

@@ -4,6 +4,7 @@
*.dll
*.so
*.dylib
kustomize
# Test binary, build with `go test -c`
*.test

View File

@@ -159,7 +159,6 @@ func TestResources1(t *testing.T) {
"annotations": map[string]interface{}{
"note": "This is a test annotation",
},
"creationTimestamp": nil,
},
"data": map[string]interface{}{
"DB_USERNAME": "admin",
@@ -179,7 +178,6 @@ func TestResources1(t *testing.T) {
"annotations": map[string]interface{}{
"note": "This is a test annotation",
},
"creationTimestamp": nil,
},
"type": string(corev1.SecretTypeOpaque),
"data": map[string]interface{}{

View File

@@ -6,7 +6,6 @@ data:
kind: ConfigMap
metadata:
annotations: {}
creationTimestamp: null
labels: {}
name: p1-com1-dhbbm922gd
---
@@ -16,6 +15,5 @@ data:
kind: ConfigMap
metadata:
annotations: {}
creationTimestamp: null
labels: {}
name: p2-com2-c4b8md75k9

View File

@@ -5,7 +5,6 @@ kind: ConfigMap
metadata:
annotations:
note: This is a test annotation
creationTimestamp: null
labels:
app: mynginx
env: staging
@@ -18,7 +17,6 @@ data:
hello: world
kind: ConfigMap
metadata:
creationTimestamp: null
labels:
env: staging
name: staging-configmap-in-overlay-k7cbc75tg8

View File

@@ -7,7 +7,6 @@ kind: ConfigMap
metadata:
annotations:
note: This is a test annotation
creationTimestamp: null
labels:
app: mungebot
org: kubernetes
@@ -22,7 +21,6 @@ kind: ConfigMap
metadata:
annotations:
note: This is a test annotation
creationTimestamp: null
labels:
app: mungebot
org: kubernetes
@@ -37,7 +35,6 @@ kind: Secret
metadata:
annotations:
note: This is a test annotation
creationTimestamp: null
labels:
app: mungebot
org: kubernetes

View File

@@ -5,7 +5,6 @@ kind: ConfigMap
metadata:
annotations:
note: This is a test annotation
creationTimestamp: null
labels:
app: mynginx
env: staging
@@ -18,7 +17,6 @@ data:
hello: world
kind: ConfigMap
metadata:
creationTimestamp: null
labels:
env: staging
team: override-foo
@@ -33,7 +31,6 @@ kind: Secret
metadata:
annotations:
note: This is a test annotation
creationTimestamp: null
labels:
app: mynginx
env: staging

View File

@@ -72,7 +72,6 @@ data:
foo: bar
kind: ConfigMap
metadata:
creationTimestamp: null
name: dev-base-test-config-map-b2g2dmd64b
---
apiVersion: v1

View File

@@ -26,6 +26,7 @@ import (
"github.com/pkg/errors"
"k8s.io/api/core/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation"
@@ -70,6 +71,7 @@ func objectToUnstructured(in runtime.Object) (*unstructured.Unstructured, error)
}
var out unstructured.Unstructured
err = out.UnmarshalJSON(marshaled)
out.SetCreationTimestamp(metav1.Time{})
return &out, err
}

View File

@@ -50,8 +50,7 @@ func makeUnstructuredEnvConfigMap(name string) *unstructured.Unstructured {
"apiVersion": "v1",
"kind": "ConfigMap",
"metadata": map[string]interface{}{
"name": name,
"creationTimestamp": nil,
"name": name,
},
"data": map[string]interface{}{
"DB_USERNAME": "admin",

View File

@@ -60,8 +60,7 @@ func TestNewFromConfigMaps(t *testing.T) {
"apiVersion": "v1",
"kind": "ConfigMap",
"metadata": map[string]interface{}{
"name": "envConfigMap",
"creationTimestamp": nil,
"name": "envConfigMap",
},
"data": map[string]interface{}{
"DB_USERNAME": "admin",
@@ -87,8 +86,7 @@ func TestNewFromConfigMaps(t *testing.T) {
"apiVersion": "v1",
"kind": "ConfigMap",
"metadata": map[string]interface{}{
"name": "fileConfigMap",
"creationTimestamp": nil,
"name": "fileConfigMap",
},
"data": map[string]interface{}{
"app-init.ini": `FOO=bar
@@ -114,8 +112,7 @@ BAR=baz
"apiVersion": "v1",
"kind": "ConfigMap",
"metadata": map[string]interface{}{
"name": "literalConfigMap",
"creationTimestamp": nil,
"name": "literalConfigMap",
},
"data": map[string]interface{}{
"a": "x",

View File

@@ -66,8 +66,7 @@ func TestNewResMapFromSecretArgs(t *testing.T) {
"apiVersion": "v1",
"kind": "Secret",
"metadata": map[string]interface{}{
"name": "apple",
"creationTimestamp": nil,
"name": "apple",
},
"type": string(corev1.SecretTypeOpaque),
"data": map[string]interface{}{
@@ -80,8 +79,7 @@ func TestNewResMapFromSecretArgs(t *testing.T) {
"apiVersion": "v1",
"kind": "Secret",
"metadata": map[string]interface{}{
"name": "peanuts",
"creationTimestamp": nil,
"name": "peanuts",
},
"type": string(corev1.SecretTypeOpaque),
"data": map[string]interface{}{

View File

@@ -23,6 +23,7 @@ import (
"strings"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
)
@@ -43,6 +44,8 @@ func NewResourceWithBehavior(obj runtime.Object, b GenerationBehavior) (*Resourc
}
var u unstructured.Unstructured
err = u.UnmarshalJSON(marshaled)
// creationTimestamp always 'null', remove it
u.SetCreationTimestamp(metav1.Time{})
return &Resource{Unstructured: u, b: b}, err
}