...
1# kubectl create namespace edit-test
2# kubectl create service clusterip svc1 --tcp 80 --namespace=edit-test --save-config
3# kubectl edit service svc1 --namespace=edit-test --save-config=true --output-patch=true
4description: edit with flag --output-patch=true should output the patch
5mode: edit
6args:
7- service
8- svc1
9saveConfig: "true"
10outputPatch: "true"
11namespace: edit-test
12expectedStdout:
13- 'Patch: {"metadata":{"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"v1\",\"kind\":\"Service\",\"metadata\":{\"annotations\":{},\"creationTimestamp\":\"2017-02-27T19:40:53Z\",\"labels\":{\"app\":\"svc1\",\"new-label\":\"new-value\"},\"name\":\"svc1\",\"namespace\":\"edit-test\",\"resourceVersion\":\"670\",\"selfLink\":\"/api/v1/namespaces/edit-test/services/svc1\",\"uid\":\"a6c11186-fd24-11e6-b53c-480fcf4a5275\"},\"spec\":{\"clusterIP\":\"10.0.0.204\",\"ports\":[{\"name\":\"80\",\"port\":80,\"protocol\":\"TCP\",\"targetPort\":80}],\"selector\":{\"app\":\"svc1\"},\"sessionAffinity\":\"None\",\"type\":\"ClusterIP\"},\"status\":{\"loadBalancer\":{}}}\n"},"labels":{"new-label":"new-value"}}}'
14- service/svc1 edited
15expectedExitCode: 0
16steps:
17- type: request
18 expectedMethod: GET
19 expectedPath: /api/v1/namespaces/edit-test/services/svc1
20 expectedInput: 0.request
21 resultingStatusCode: 200
22 resultingOutput: 0.response
23- type: edit
24 expectedInput: 1.original
25 resultingOutput: 1.edited
26- type: request
27 expectedMethod: PATCH
28 expectedPath: /api/v1/namespaces/edit-test/services/svc1
29 expectedContentType: application/strategic-merge-patch+json
30 expectedInput: 2.request
31 resultingStatusCode: 200
32 resultingOutput: 2.response
View as plain text