func TestApplyRemovesEmptyManagedFields(t *testing.T) {
	defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, genericfeatures.ServerSideApply, true)()

	_, client, closeFn := setup(t)
	defer closeFn()

	obj := []byte(`{
		"apiVersion": "v1",
		"kind": "ConfigMap",
		"metadata": {
			"name": "test-cm",
			"namespace": "default"
		}
	}`)

	_, err := client.CoreV1().RESTClient().Patch(types.ApplyPatchType).
		Namespace("default").
		Resource("configmaps").
		Name("test-cm").
		Param("fieldManager", "apply_test").
		Body(obj).
		Do(context.TODO()).
		Get()
	if err != nil {
		t.Fatalf("Failed to create object using Apply patch: %v", err)
	}

	_, err = client.CoreV1().RESTClient().Patch(types.ApplyPatchType).
		Namespace("default").
		Resource("configmaps").
		Name("test-cm").
		Param("fieldManager", "apply_test").
		Body(obj).Do(context.TODO()).Get()
	if err != nil {
		t.Fatalf("Failed to patch object: %v", err)
	}

	object, err := client.CoreV1().RESTClient().Get().Namespace("default").Resource("configmaps").Name("test-cm").Do(context.TODO()).Get()
	if err != nil {
		t.Fatalf("Failed to retrieve object: %v", err)
	}

	accessor, err := meta.Accessor(object)
	if err != nil {
		t.Fatalf("Failed to get meta accessor: %v", err)
	}

	if managed := accessor.GetManagedFields(); managed != nil {
		t.Fatalf("Object contains unexpected managedFields: %v", managed)
	}
}
// TestApplyRemovesEmptyManagedFields there are no empty managers in managedFields
TestApplyRemovesEmptyManagedFields there are no empty managers in managedFields
// TestApplyRemovesEmptyManagedFields there are no empty managers in managedFields
func TestApplyRemovesEmptyManagedFields(t *testing.T) {
	defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, genericfeatures.ServerSideApply, true)()
	_, client, closeFn := setup(t)
	defer closeFn()
	obj := []byte(`{
		"apiVersion": "v1",
		"kind": "ConfigMap",
		"metadata": {
			"name": "test-cm",
			"namespace": "default"
		}
	}`)
	_, err := client.CoreV1().RESTClient().Patch(types.ApplyPatchType).
		Namespace("default").
		Resource("configmaps").
		Name("test-cm").
		Param("fieldManager", "apply_test").
		Body(obj).
		Do(context.TODO()).
		Get()
	if err != nil {
		t.Fatalf("Failed to create object using Apply patch: %v", err)
	}
	_, err = client.CoreV1().RESTClient().Patch(types.ApplyPatchType).
		Namespace("default").
		Resource("configmaps").
		Name("test-cm").
		Param("fieldManager", "apply_test").
		Body(obj).Do(context.TODO()).Get()
	if err != nil {
		t.Fatalf("Failed to patch object: %v", err)
	}
	object, err := client.CoreV1().RESTClient().Get().Namespace("default").Resource("configmaps").Name("test-cm").Do(context.TODO()).Get()
	if err != nil {
		t.Fatalf("Failed to retrieve object: %v", err)
	}
	accessor, err := meta.Accessor(object)
	if err != nil {
		t.Fatalf("Failed to get meta accessor: %v", err)
	}
	if managed := accessor.GetManagedFields(); managed != nil {
		t.Fatalf("Object contains unexpected managedFields: %v", managed)
	}
}
func TestApplyRemovesEmptyManagedFields ( t * testing . T ) { defer featuregatetesting . SetFeatureGateDuringTest ( t , utilfeature . DefaultFeatureGate , genericfeatures . ServerSideApply , true ) ( ) _ , client , closeFn := setup ( t ) defer closeFn ( ) obj := [ ] byte ( `{
		"apiVersion": "v1",
		"kind": "ConfigMap",
		"metadata": {
			"name": "test-cm",
			"namespace": "default"
		}
	}` ) _ , err := client . CoreV1 ( ) . RESTClient ( ) . Patch ( types . ApplyPatchType ) . Namespace ( " " ) . Resource ( " " ) . Name ( " " ) . Param ( " " , " " ) . Body ( obj ) . Do ( context . TODO ( ) ) . Get ( ) if err != nil { t . Fatalf ( " " , err ) } _ , err = client . CoreV1 ( ) . RESTClient ( ) . Patch ( types . ApplyPatchType ) . Namespace ( " " ) . Resource ( " " ) . Name ( " " ) . Param ( " " , " " ) . Body ( obj ) . Do ( context . TODO ( ) ) . Get ( ) if err != nil { t . Fatalf ( " " , err ) } object , err := client . CoreV1 ( ) . RESTClient ( ) . Get ( ) . Namespace ( " " ) . Resource ( " " ) . Name ( " " ) . Do ( context . TODO ( ) ) . Get ( ) if err != nil { t . Fatalf ( " " , err ) } accessor , err := meta . Accessor ( object ) if err != nil { t . Fatalf ( " " , err ) } if managed := accessor . GetManagedFields ( ) ; managed != nil { t . Fatalf ( " " , managed ) } }
TestApplyRemovesEmptyManagedFields there are no empty managers in managedFields
TestApplyRemovesEmptyManagedFields there are no empty managers in managedFields