Created
July 7, 2016 14:48
-
-
Save ivan4th/388dd4af13bccab41471a643f0105e75 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ivan4th@ivan4th:~/work/kubernetes/src/k8s.io/kubernetes (fix-kubectl-apply-for-init-containers *%) $ git diff | |
diff --git a/pkg/kubectl/apply.go b/pkg/kubectl/apply.go | |
index 6f183f1..7bad4ae 100644 | |
--- a/pkg/kubectl/apply.go | |
+++ b/pkg/kubectl/apply.go | |
@@ -19,6 +19,7 @@ package kubectl | |
import ( | |
"encoding/json" | |
+ "fmt" | |
"k8s.io/kubernetes/pkg/api/annotations" | |
"k8s.io/kubernetes/pkg/api/meta" | |
"k8s.io/kubernetes/pkg/kubectl/resource" | |
@@ -120,6 +121,7 @@ func GetModifiedConfiguration(info *resource.Info, annotate bool, codec runtime. | |
annots[annotations.LastAppliedConfigAnnotation] = original | |
accessor.SetAnnotations(annots) | |
} else { | |
+ fmt.Printf("info.Object: %T\n", info.Object) | |
// Otherwise, use the server side version of the object. | |
accessor := info.Mapping.MetadataAccessor | |
// Get the current annotations from the object. | |
@@ -137,11 +139,13 @@ func GetModifiedConfiguration(info *resource.Info, annotate bool, codec runtime. | |
if err := accessor.SetAnnotations(info.Object, annots); err != nil { | |
return nil, err | |
} | |
+ fmt.Printf("original: %s\n", original) | |
modified, err = runtime.Encode(codec, info.Object) | |
if err != nil { | |
return nil, err | |
} | |
+ fmt.Printf("modified: %s\n", modified) | |
if annotate { | |
annots[annotations.LastAppliedConfigAnnotation] = string(modified) | |
@@ -153,6 +157,7 @@ func GetModifiedConfiguration(info *resource.Info, annotate bool, codec runtime. | |
if err != nil { | |
return nil, err | |
} | |
+ fmt.Printf("modified2: %s\n", modified) | |
} | |
// Restore the object to its original condition. | |
diff --git a/pkg/runtime/serializer/versioning/versioning.go b/pkg/runtime/serializer/versioning/versioning.go | |
index 6e67964..b37eeee 100644 | |
--- a/pkg/runtime/serializer/versioning/versioning.go | |
+++ b/pkg/runtime/serializer/versioning/versioning.go | |
@@ -147,10 +147,13 @@ func (c *codec) Decode(data []byte, defaultGVK *unversioned.GroupVersionKind, in | |
into = versioned.Last() | |
} | |
+ fmt.Printf("data:\n%s\n---\n", data) | |
+ fmt.Printf("c.decoder=%T into=%T\n", c.decoder, into) | |
obj, gvk, err := c.decoder.Decode(data, defaultGVK, into) | |
if err != nil { | |
return nil, gvk, err | |
} | |
+ fmt.Printf("obj=%T\n", obj) | |
// if we specify a target, use generic conversion. | |
if into != nil { | |
ivan4th@ivan4th:~/work/kubernetes/src/k8s.io/kubernetes (fix-kubectl-apply-for-init-containers *%) $ (cd '/home/ivan4th/work/kubernetes/src/k8s.io/kubernetes/pkg/kubectl/cmd/' && go test -timeout 45s -run '^TestApplyMultipleObjectsAsList$') | |
data: | |
{"apiVersion":"v1","items":[{"apiVersion":"v1","kind":"Service","metadata":{"labels":{"name":"test-service"},"name":"test-service"},"spec":{"ports":[{"port":80}],"selector":{"name":"test-rc"}}},{"apiVersion":"v1","kind":"ReplicationController","metadata":{"labels":{"name":"test-rc"},"name":"test-rc"},"spec":{"replicas":1,"template":{"metadata":{"labels":{"name":"test-rc"}},"spec":{"containers":[{"image":"nginx","name":"test-rc","ports":[{"containerPort":80}]}]}}}}],"kind":"List"} | |
--- | |
c.decoder=*recognizer.decoder into=<nil> | |
obj=*v1.List | |
data: | |
{"apiVersion":"v1","kind":"Service","metadata":{"labels":{"name":"test-service"},"name":"test-service"},"spec":{"ports":[{"port":80}],"selector":{"name":"test-rc"}}} | |
--- | |
c.decoder=*recognizer.decoder into=<nil> | |
obj=*v1.Service | |
data: | |
{"apiVersion":"v1","kind":"ReplicationController","metadata":{"labels":{"name":"test-rc"},"name":"test-rc"},"spec":{"replicas":1,"template":{"metadata":{"labels":{"name":"test-rc"}},"spec":{"containers":[{"image":"nginx","name":"test-rc","ports":[{"containerPort":80}]}]}}}} | |
--- | |
c.decoder=*recognizer.decoder into=<nil> | |
obj=*v1.ReplicationController | |
info.Object: *api.Service | |
original: | |
modified: {"kind":"Service","apiVersion":"v1","metadata":{"name":"test-service","namespace":"test","creationTimestamp":null,"labels":{"name":"test-service"}},"spec":{"ports":[{"protocol":"TCP","port":80,"targetPort":80}],"selector":{"name":"test-rc"},"type":"ClusterIP","sessionAffinity":"None"},"status":{"loadBalancer":{}}} | |
modified2: {"kind":"Service","apiVersion":"v1","metadata":{"name":"test-service","namespace":"test","creationTimestamp":null,"labels":{"name":"test-service"},"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"kind\":\"Service\",\"apiVersion\":\"v1\",\"metadata\":{\"name\":\"test-service\",\"namespace\":\"test\",\"creationTimestamp\":null,\"labels\":{\"name\":\"test-service\"}},\"spec\":{\"ports\":[{\"protocol\":\"TCP\",\"port\":80,\"targetPort\":80}],\"selector\":{\"name\":\"test-rc\"},\"type\":\"ClusterIP\",\"sessionAffinity\":\"None\"},\"status\":{\"loadBalancer\":{}}}\n"}},"spec":{"ports":[{"protocol":"TCP","port":80,"targetPort":80}],"selector":{"name":"test-rc"},"type":"ClusterIP","sessionAffinity":"None"},"status":{"loadBalancer":{}}} | |
data: | |
{"kind":"Service","apiVersion":"v1","metadata":{"name":"test-service","creationTimestamp":null,"labels":{"name":"test-service"},"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"kind\":\"Service\",\"apiVersion\":\"v1\",\"metadata\":{\"name\":\"test-service\",\"creationTimestamp\":null,\"labels\":{\"DELETE_ME\":\"DELETE_ME\",\"name\":\"test-service\"}},\"spec\":{\"ports\":[{\"name\":\"\",\"protocol\":\"\",\"port\":80,\"targetPort\":0,\"nodePort\":0}],\"selector\":{\"name\":\"test-rc\"}},\"status\":{\"loadBalancer\":{}}}"}},"spec":{"ports":[{"name":"","protocol":"","port":80,"targetPort":0,"nodePort":0}],"selector":{"name":"test-rc"}},"status":{"loadBalancer":{}}} | |
--- | |
c.decoder=*recognizer.decoder into=*unversioned.Status | |
obj=*v1.Service | |
data: | |
{"kind":"Service","apiVersion":"v1","metadata":{"name":"test-service","creationTimestamp":null,"labels":{"name":"test-service"},"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"kind\":\"Service\",\"apiVersion\":\"v1\",\"metadata\":{\"name\":\"test-service\",\"creationTimestamp\":null,\"labels\":{\"DELETE_ME\":\"DELETE_ME\",\"name\":\"test-service\"}},\"spec\":{\"ports\":[{\"name\":\"\",\"protocol\":\"\",\"port\":80,\"targetPort\":0,\"nodePort\":0}],\"selector\":{\"name\":\"test-rc\"}},\"status\":{\"loadBalancer\":{}}}"}},"spec":{"ports":[{"name":"","protocol":"","port":80,"targetPort":0,"nodePort":0}],"selector":{"name":"test-rc"}},"status":{"loadBalancer":{}}} | |
--- | |
c.decoder=*recognizer.decoder into=<nil> | |
obj=*v1.Service | |
data: | |
{"kind":"Service","apiVersion":"v1","metadata":{"name":"test-service","creationTimestamp":null,"labels":{"name":"test-service"},"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"kind\":\"Service\",\"apiVersion\":\"v1\",\"metadata\":{\"name\":\"test-service\",\"creationTimestamp\":null,\"labels\":{\"DELETE_ME\":\"DELETE_ME\",\"name\":\"test-service\"}},\"spec\":{\"ports\":[{\"name\":\"\",\"protocol\":\"\",\"port\":80,\"targetPort\":0,\"nodePort\":0}],\"selector\":{\"name\":\"test-rc\"}},\"status\":{\"loadBalancer\":{}}}"}},"spec":{"ports":[{"protocol":"TCP","port":80,"targetPort":80}],"selector":{"name":"test-rc"},"type":"ClusterIP","sessionAffinity":"None"},"status":{"loadBalancer":{}}} | |
--- | |
c.decoder=*recognizer.decoder into=<nil> | |
obj=*v1.Service | |
data: | |
{"kind":"Service","apiVersion":"v1","metadata":{"name":"test-service","creationTimestamp":null,"labels":{"name":"test-service"},"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"kind\":\"Service\",\"apiVersion\":\"v1\",\"metadata\":{\"name\":\"test-service\",\"creationTimestamp\":null,\"labels\":{\"DELETE_ME\":\"DELETE_ME\",\"name\":\"test-service\"}},\"spec\":{\"ports\":[{\"name\":\"\",\"protocol\":\"\",\"port\":80,\"targetPort\":0,\"nodePort\":0}],\"selector\":{\"name\":\"test-rc\"}},\"status\":{\"loadBalancer\":{}}}"}},"spec":{"ports":[{"name":"","protocol":"","port":80,"targetPort":0,"nodePort":0}],"selector":{"name":"test-rc"}},"status":{"loadBalancer":{}}} | |
--- | |
c.decoder=*recognizer.decoder into=*unversioned.Status | |
obj=*v1.Service | |
data: | |
{"kind":"Service","apiVersion":"v1","metadata":{"name":"test-service","creationTimestamp":null,"labels":{"name":"test-service"},"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"kind\":\"Service\",\"apiVersion\":\"v1\",\"metadata\":{\"name\":\"test-service\",\"creationTimestamp\":null,\"labels\":{\"DELETE_ME\":\"DELETE_ME\",\"name\":\"test-service\"}},\"spec\":{\"ports\":[{\"name\":\"\",\"protocol\":\"\",\"port\":80,\"targetPort\":0,\"nodePort\":0}],\"selector\":{\"name\":\"test-rc\"}},\"status\":{\"loadBalancer\":{}}}"}},"spec":{"ports":[{"name":"","protocol":"","port":80,"targetPort":0,"nodePort":0}],"selector":{"name":"test-rc"}},"status":{"loadBalancer":{}}} | |
--- | |
c.decoder=*recognizer.decoder into=<nil> | |
obj=*v1.Service | |
info.Object: *api.ReplicationController | |
original: | |
modified: {"kind":"ReplicationController","apiVersion":"v1","metadata":{"name":"test-rc","namespace":"test","creationTimestamp":null,"labels":{"name":"test-rc"}},"spec":{"replicas":1,"selector":{"name":"test-rc"},"template":{"metadata":{"creationTimestamp":null,"labels":{"name":"test-rc"}},"spec":{"containers":[{"name":"test-rc","image":"nginx","ports":[{"containerPort":80,"protocol":"TCP"}],"resources":{},"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"Always"}],"restartPolicy":"Always","terminationGracePeriodSeconds":30,"dnsPolicy":"ClusterFirst","securityContext":{}}}},"status":{"replicas":0}} | |
modified2: {"kind":"ReplicationController","apiVersion":"v1","metadata":{"name":"test-rc","namespace":"test","creationTimestamp":null,"labels":{"name":"test-rc"},"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"kind\":\"ReplicationController\",\"apiVersion\":\"v1\",\"metadata\":{\"name\":\"test-rc\",\"namespace\":\"test\",\"creationTimestamp\":null,\"labels\":{\"name\":\"test-rc\"}},\"spec\":{\"replicas\":1,\"selector\":{\"name\":\"test-rc\"},\"template\":{\"metadata\":{\"creationTimestamp\":null,\"labels\":{\"name\":\"test-rc\"}},\"spec\":{\"containers\":[{\"name\":\"test-rc\",\"image\":\"nginx\",\"ports\":[{\"containerPort\":80,\"protocol\":\"TCP\"}],\"resources\":{},\"terminationMessagePath\":\"/dev/termination-log\",\"imagePullPolicy\":\"Always\"}],\"restartPolicy\":\"Always\",\"terminationGracePeriodSeconds\":30,\"dnsPolicy\":\"ClusterFirst\",\"securityContext\":{}}}},\"status\":{\"replicas\":0}}\n"}},"spec":{"replicas":1,"selector":{"name":"test-rc"},"template":{"metadata":{"creationTimestamp":null,"labels":{"name":"test-rc"}},"spec":{"containers":[{"name":"test-rc","image":"nginx","ports":[{"containerPort":80,"protocol":"TCP"}],"resources":{},"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"Always"}],"restartPolicy":"Always","terminationGracePeriodSeconds":30,"dnsPolicy":"ClusterFirst","securityContext":{}}}},"status":{"replicas":0}} | |
data: | |
{"kind":"ReplicationController","apiVersion":"v1","metadata":{"name":"test-rc","creationTimestamp":null,"labels":{"name":"test-rc"},"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"kind\":\"ReplicationController\",\"apiVersion\":\"v1\",\"metadata\":{\"name\":\"test-rc\",\"creationTimestamp\":null,\"labels\":{\"DELETE_ME\":\"DELETE_ME\",\"name\":\"test-rc\"}},\"spec\":{\"replicas\":1,\"selector\":null,\"template\":{\"metadata\":{\"creationTimestamp\":null,\"labels\":{\"name\":\"test-rc\"}},\"spec\":{\"volumes\":null,\"containers\":[{\"name\":\"test-rc\",\"image\":\"nginx\",\"ports\":[{\"containerPort\":80}],\"resources\":{},\"imagePullPolicy\":\"\"}],\"serviceAccountName\":\"\"}}},\"status\":{\"replicas\":0}}"}},"spec":{"replicas":1,"selector":null,"template":{"metadata":{"creationTimestamp":null,"labels":{"name":"test-rc"}},"spec":{"volumes":null,"containers":[{"name":"test-rc","image":"nginx","ports":[{"containerPort":80}],"resources":{},"imagePullPolicy":""}],"serviceAccountName":""}}},"status":{"replicas":0}} | |
--- | |
c.decoder=*recognizer.decoder into=*unversioned.Status | |
obj=*v1.ReplicationController | |
data: | |
{"kind":"ReplicationController","apiVersion":"v1","metadata":{"name":"test-rc","creationTimestamp":null,"labels":{"name":"test-rc"},"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"kind\":\"ReplicationController\",\"apiVersion\":\"v1\",\"metadata\":{\"name\":\"test-rc\",\"creationTimestamp\":null,\"labels\":{\"DELETE_ME\":\"DELETE_ME\",\"name\":\"test-rc\"}},\"spec\":{\"replicas\":1,\"selector\":null,\"template\":{\"metadata\":{\"creationTimestamp\":null,\"labels\":{\"name\":\"test-rc\"}},\"spec\":{\"volumes\":null,\"containers\":[{\"name\":\"test-rc\",\"image\":\"nginx\",\"ports\":[{\"containerPort\":80}],\"resources\":{},\"imagePullPolicy\":\"\"}],\"serviceAccountName\":\"\"}}},\"status\":{\"replicas\":0}}"}},"spec":{"replicas":1,"selector":null,"template":{"metadata":{"creationTimestamp":null,"labels":{"name":"test-rc"}},"spec":{"volumes":null,"containers":[{"name":"test-rc","image":"nginx","ports":[{"containerPort":80}],"resources":{},"imagePullPolicy":""}],"serviceAccountName":""}}},"status":{"replicas":0}} | |
--- | |
c.decoder=*recognizer.decoder into=<nil> | |
obj=*v1.ReplicationController | |
data: | |
{"kind":"ReplicationController","apiVersion":"v1","metadata":{"name":"test-rc","creationTimestamp":null,"labels":{"name":"test-rc"},"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"kind\":\"ReplicationController\",\"apiVersion\":\"v1\",\"metadata\":{\"name\":\"test-rc\",\"creationTimestamp\":null,\"labels\":{\"DELETE_ME\":\"DELETE_ME\",\"name\":\"test-rc\"}},\"spec\":{\"replicas\":1,\"selector\":null,\"template\":{\"metadata\":{\"creationTimestamp\":null,\"labels\":{\"name\":\"test-rc\"}},\"spec\":{\"volumes\":null,\"containers\":[{\"name\":\"test-rc\",\"image\":\"nginx\",\"ports\":[{\"containerPort\":80}],\"resources\":{},\"imagePullPolicy\":\"\"}],\"serviceAccountName\":\"\"}}},\"status\":{\"replicas\":0}}"}},"spec":{"replicas":1,"selector":{"name":"test-rc"},"template":{"metadata":{"creationTimestamp":null,"labels":{"name":"test-rc"}},"spec":{"containers":[{"name":"test-rc","image":"nginx","ports":[{"containerPort":80,"protocol":"TCP"}],"resources":{},"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"Always"}],"restartPolicy":"Always","terminationGracePeriodSeconds":30,"dnsPolicy":"ClusterFirst","securityContext":{}}}},"status":{"replicas":0}} | |
--- | |
c.decoder=*recognizer.decoder into=<nil> | |
obj=*v1.ReplicationController | |
data: | |
{"kind":"ReplicationController","apiVersion":"v1","metadata":{"name":"test-rc","creationTimestamp":null,"labels":{"name":"test-rc"},"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"kind\":\"ReplicationController\",\"apiVersion\":\"v1\",\"metadata\":{\"name\":\"test-rc\",\"creationTimestamp\":null,\"labels\":{\"DELETE_ME\":\"DELETE_ME\",\"name\":\"test-rc\"}},\"spec\":{\"replicas\":1,\"selector\":null,\"template\":{\"metadata\":{\"creationTimestamp\":null,\"labels\":{\"name\":\"test-rc\"}},\"spec\":{\"volumes\":null,\"containers\":[{\"name\":\"test-rc\",\"image\":\"nginx\",\"ports\":[{\"containerPort\":80}],\"resources\":{},\"imagePullPolicy\":\"\"}],\"serviceAccountName\":\"\"}}},\"status\":{\"replicas\":0}}"}},"spec":{"replicas":1,"selector":null,"template":{"metadata":{"creationTimestamp":null,"labels":{"name":"test-rc"}},"spec":{"volumes":null,"containers":[{"name":"test-rc","image":"nginx","ports":[{"containerPort":80}],"resources":{},"imagePullPolicy":""}],"serviceAccountName":""}}},"status":{"replicas":0}} | |
--- | |
c.decoder=*recognizer.decoder into=*unversioned.Status | |
obj=*v1.ReplicationController | |
data: | |
{"kind":"ReplicationController","apiVersion":"v1","metadata":{"name":"test-rc","creationTimestamp":null,"labels":{"name":"test-rc"},"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"kind\":\"ReplicationController\",\"apiVersion\":\"v1\",\"metadata\":{\"name\":\"test-rc\",\"creationTimestamp\":null,\"labels\":{\"DELETE_ME\":\"DELETE_ME\",\"name\":\"test-rc\"}},\"spec\":{\"replicas\":1,\"selector\":null,\"template\":{\"metadata\":{\"creationTimestamp\":null,\"labels\":{\"name\":\"test-rc\"}},\"spec\":{\"volumes\":null,\"containers\":[{\"name\":\"test-rc\",\"image\":\"nginx\",\"ports\":[{\"containerPort\":80}],\"resources\":{},\"imagePullPolicy\":\"\"}],\"serviceAccountName\":\"\"}}},\"status\":{\"replicas\":0}}"}},"spec":{"replicas":1,"selector":null,"template":{"metadata":{"creationTimestamp":null,"labels":{"name":"test-rc"}},"spec":{"volumes":null,"containers":[{"name":"test-rc","image":"nginx","ports":[{"containerPort":80}],"resources":{},"imagePullPolicy":""}],"serviceAccountName":""}}},"status":{"replicas":0}} | |
--- | |
c.decoder=*recognizer.decoder into=<nil> | |
obj=*v1.ReplicationController | |
PASS | |
ok k8s.io/kubernetes/pkg/kubectl/cmd 0.025s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment