// PatchOrReplace uses given clientset to update the node status, either by patching or
// updating the given node object; it may return error if the object cannot be encoded as
// JSON, or if either patch or update calls fail; it will also return a second error
// whenever creating a patch has failed
PatchOrReplace uses given clientset to update the node status, either by patching or
updating the given node object; it may return error if the object cannot be encoded as
JSON, or if either patch or update calls fail; it will also return a second error
whenever creating a patch has failed
// PatchOrReplace uses given clientset to update the node status either by patching or // updating the given node object ; it may return error if the object cannot be encoded as // JSON or if either patch or update calls fail ; it will also return a second error // whenever creating a patch has failed
func (c *CordonHelper) PatchOrReplace(clientset kubernetes.Interface) (error, error) {
	client := clientset.Core().Nodes()
	oldData, err := json.Marshal(c.node)
	if err != nil {
		return err, nil
	}
	switch c.status {
	case CordonNode:
		c.node.Spec.Unschedulable = true
	case UncordonNode:
		c.node.Spec.Unschedulable = false
	}
	newData, err := json.Marshal(c.node)
	if err != nil {
		return err, nil
	}
	patchBytes, patchErr := strategicpatch.CreateTwoWayMergePatch(oldData, newData, c.node)
	if patchErr == nil {
		_, err = client.Patch(c.node.Name, types.StrategicMergePatchType, patchBytes)
	} else {
		_, err = client.Update(c.node)
	}
	return err, patchErr
}
func ( c * CordonHelper ) PatchOrReplace ( clientset kubernetes . Interface ) ( error , error ) { client := clientset . Core ( ) . Nodes ( ) oldData , err := json . Marshal ( c . node ) if err != nil { return err , nil } switch c . status { case CordonNode : c . node . Spec . Unschedulable = true case UncordonNode : c . node . Spec . Unschedulable = false } newData , err := json . Marshal ( c . node ) if err != nil { return err , nil } patchBytes , patchErr := strategicpatch . CreateTwoWayMergePatch ( oldData , newData , c . node ) if patchErr == nil { _ , err = client . Patch ( c . node . Name , types . StrategicMergePatchType , patchBytes ) } else { _ , err = client . Update ( c . node ) } return err , patchErr }
PatchOrReplace uses given clientset to update the node status, either by patching or
updating the given node object; it may return error if the object cannot be encoded as
JSON, or if either patch or update calls fail; it will also return a second error
whenever creating a patch has failed
PatchOrReplace uses given clientset to update the node status either by patching or updating the given node object ; it may return error if the object cannot be encoded as JSON or if either patch or update calls fail ; it will also return a second error whenever creating a patch has failed