def patch_obj(cls, config, values, strategy: V1PatchStrategy = None): strategy = strategy or V1PatchStrategy.POST_MERGE result = super().patch_obj(config, values, strategy) value = getattr(values, "run_patch", None) if value is None: return result current_value = getattr(config, "run_patch", None) if current_value is None: setattr(result, "run_patch", value) return result if (not config.component or not config.component.run or not config.component.run.kind): # We don't have a kind, we don't do anything if strategy == V1PatchStrategy.ISNULL: return result if strategy == V1PatchStrategy.REPLACE: setattr(result, "run_patch", value) return result return result kind = config.component.run.kind value = validate_run_patch(value, kind) current_value = validate_run_patch(current_value, kind) run_patch = current_value.patch(value, strategy) run_patch = run_patch.to_dict() run_patch.pop("kind") result.run_patch = run_patch return result
def validate_run_patch(self, data, **kwargs): component = data.get("component") run_patch = data.get("run_patch") if not component or not run_patch: return validate_run_patch(run_patch=run_patch, kind=component.run.kind)