Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for applyJSONPatch (0.14 sec)

  1. pkg/kube/inject/inject_test.go

    		},
    	}, "")
    	var gotPod *corev1.Pod
    	// Apply the generated patch to the template.
    	if got.Patch != nil {
    		patchedPod := &corev1.Pod{}
    		patch := prettyJSON(got.Patch, t)
    		patchedTemplateJSON := applyJSONPatch(templateJSON, patch, t)
    		if err := json.Unmarshal(patchedTemplateJSON, patchedPod); err != nil {
    			t.Fatal(err)
    		}
    		gotPod = patchedPod
    	} else {
    		gotPod = inputPod
    	}
    
    Registered: Fri Jun 14 15:00:06 UTC 2024
    - Last Modified: Fri May 31 20:35:11 UTC 2024
    - 34.1K bytes
    - Viewed (0)
  2. pkg/kube/inject/webhook_test.go

    	// Pretty-print the JSON
    	var prettyBuffer bytes.Buffer
    	if err := json.Indent(&prettyBuffer, inputJSON, "", "  "); err != nil {
    		t.Fatalf(err.Error())
    	}
    	return prettyBuffer.Bytes()
    }
    
    func applyJSONPatch(input, patch []byte, t *testing.T) []byte {
    	t.Helper()
    	p, err := jsonpatch.DecodePatch(patch)
    	if err != nil {
    		t.Fatal(err)
    	}
    
    	patchedJSON, err := p.Apply(input)
    	if err != nil {
    Registered: Fri Jun 14 15:00:06 UTC 2024
    - Last Modified: Mon Jul 17 20:25:52 UTC 2023
    - 39K bytes
    - Viewed (1)
Back to top