Merge pull request #356 from liuhuiping2013/master

remove metadata.creationTimestamp field from configMapGenerator
This commit is contained in:
k8s-ci-robot
2018-09-21 09:46:02 -07:00
committed by GitHub
12 changed files with 12 additions and 25 deletions

1
.gitignore vendored
View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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