SSA: prevent usage of Extract calls via forbidigo

Client-side extract calls depend on `managedFields`, which might not be
available. Therefore they should not be used in production code.

They are okay in test files (because the API has to be tested), in the
generated code (because the various type specific APIs still need to be
provided) and in unstructured.go (same reason).

Kubernetes-commit: 4bc9434f99d9a87dd5b63e738b6b1b16693f10e4
This commit is contained in:
Patrick Ohly 2023-08-02 10:57:51 +02:00 committed by Kubernetes Publisher
parent 9a5370b1ef
commit ed2b4f0fcb

View File

@ -125,7 +125,7 @@ func (e *extractor) extractUnstructured(object *unstructured.Unstructured, field
return nil, fmt.Errorf("failed to fetch the objectType: %v", err)
}
result := &unstructured.Unstructured{}
err = managedfields.ExtractInto(object, *objectType, fieldManager, result, subresource)
err = managedfields.ExtractInto(object, *objectType, fieldManager, result, subresource) //nolint:forbidigo
if err != nil {
return nil, fmt.Errorf("failed calling ExtractInto for unstructured: %v", err)
}