MCPcopy Index your code
hub / github.com/helm/helm / patchResourceServerSide

Function patchResourceServerSide

pkg/kube/client.go:1212–1248  ·  view source on GitHub ↗

Patch reource using server-side apply

(target *resource.Info, dryRun bool, forceConflicts bool, fieldValidationDirective FieldValidationDirective)

Source from the content-addressed store, hash-verified

1210
1211// Patch reource using server-side apply
1212func patchResourceServerSide(target *resource.Info, dryRun bool, forceConflicts bool, fieldValidationDirective FieldValidationDirective) error {
1213 helper := resource.NewHelper(
1214 target.Client,
1215 target.Mapping).
1216 DryRun(dryRun).
1217 WithFieldManager(getManagedFieldsManager()).
1218 WithFieldValidation(string(fieldValidationDirective))
1219
1220 // Send the full object to be applied on the server side.
1221 data, err := runtime.Encode(unstructured.UnstructuredJSONScheme, target.Object)
1222 if err != nil {
1223 return fmt.Errorf("failed to encode object %s/%s %s: %w", target.Namespace, target.Name, target.Mapping.GroupVersionKind.String(), err)
1224 }
1225 options := metav1.PatchOptions{
1226 Force: &forceConflicts,
1227 }
1228 obj, err := helper.Patch(
1229 target.Namespace,
1230 target.Name,
1231 types.ApplyPatchType,
1232 data,
1233 &options,
1234 )
1235 if err != nil {
1236 if isIncompatibleServerError(err) {
1237 return fmt.Errorf("server-side apply not available on the server: %v", err)
1238 }
1239
1240 if apierrors.IsConflict(err) {
1241 return fmt.Errorf("conflict occurred while applying object %s/%s %s: %w", target.Namespace, target.Name, target.Mapping.GroupVersionKind.String(), err)
1242 }
1243
1244 return fmt.Errorf("server-side apply failed for object %s/%s %s: %w", target.Namespace, target.Name, target.Mapping.GroupVersionKind.String(), err)
1245 }
1246
1247 return target.Refresh(obj, true)
1248}
1249
1250// GetPodList uses the kubernetes interface to get the list of pods filtered by listOptions
1251func (c *Client) GetPodList(namespace string, listOptions metav1.ListOptions) (*v1.PodList, error) {

Callers 3

makeCreateApplyFuncMethod · 0.85
UpdateMethod · 0.85

Calls 5

getManagedFieldsManagerFunction · 0.85
EncodeMethod · 0.80
StringMethod · 0.45
PatchMethod · 0.45

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…