diff --git a/kubeactions/jsonschema/KubeAction.json b/kubeactions/jsonschema/KubeAction.json index 459c4858..db2f74a3 100644 --- a/kubeactions/jsonschema/KubeAction.json +++ b/kubeactions/jsonschema/KubeAction.json @@ -100,15 +100,19 @@ "properties": { "patch": { "type": "string", - "description": "Patch is the raw JSON strategic merge patch to apply to the deployment. The patch is applied as-is using the Kubernetes strategic merge patch strategy. Example: {\"spec\": {\"replicas\": 3}} to scale, or {\"spec\": {\"template\": {\"spec\": {\"containers\": [{\"name\": \"app\", \"image\": \"app:v2\"}]}}}} to update an image.", + "description": "Patch is the raw JSON patch to apply to the deployment. Example: {\"spec\": {\"replicas\": 3}} to scale, or {\"spec\": {\"template\": {\"spec\": {\"containers\": [{\"name\": \"app\", \"image\": \"app:v2\"}]}}}} to update an image.", "format": "binary", "binaryEncoding": "base64" + }, + "patch_strategy": { + "type": "string", + "description": "PatchStrategy specifies the Kubernetes patch strategy to use. Supported values: \"strategic-merge\" (default) - Strategic merge patch, understands K8s resource structure (e.g. merges lists by key) \"merge\" - RFC 7386 JSON merge patch, simple merge that replaces arrays entirely \"json\" - RFC 6902 JSON patch, explicit add/remove/replace operations at specific paths If not specified, defaults to \"strategic-merge\"." } }, "additionalProperties": true, "type": "object", "title": "Patch Deployment Params", - "description": "PatchDeploymentParams contains parameters for the patch_deployment action. Applies a strategic merge patch to a deployment." + "description": "PatchDeploymentParams contains parameters for the patch_deployment action. Applies a patch to a deployment using the specified strategy." }, "RestartDeploymentParams": { "additionalProperties": false, diff --git a/kubeactions/jsonschema/KubeActionsList.json b/kubeactions/jsonschema/KubeActionsList.json index b652b4cd..8f76fc6a 100644 --- a/kubeactions/jsonschema/KubeActionsList.json +++ b/kubeactions/jsonschema/KubeActionsList.json @@ -118,15 +118,19 @@ "properties": { "patch": { "type": "string", - "description": "Patch is the raw JSON strategic merge patch to apply to the deployment. The patch is applied as-is using the Kubernetes strategic merge patch strategy. Example: {\"spec\": {\"replicas\": 3}} to scale, or {\"spec\": {\"template\": {\"spec\": {\"containers\": [{\"name\": \"app\", \"image\": \"app:v2\"}]}}}} to update an image.", + "description": "Patch is the raw JSON patch to apply to the deployment. Example: {\"spec\": {\"replicas\": 3}} to scale, or {\"spec\": {\"template\": {\"spec\": {\"containers\": [{\"name\": \"app\", \"image\": \"app:v2\"}]}}}} to update an image.", "format": "binary", "binaryEncoding": "base64" + }, + "patch_strategy": { + "type": "string", + "description": "PatchStrategy specifies the Kubernetes patch strategy to use. Supported values: \"strategic-merge\" (default) - Strategic merge patch, understands K8s resource structure (e.g. merges lists by key) \"merge\" - RFC 7386 JSON merge patch, simple merge that replaces arrays entirely \"json\" - RFC 6902 JSON patch, explicit add/remove/replace operations at specific paths If not specified, defaults to \"strategic-merge\"." } }, "additionalProperties": true, "type": "object", "title": "Patch Deployment Params", - "description": "PatchDeploymentParams contains parameters for the patch_deployment action. Applies a strategic merge patch to a deployment." + "description": "PatchDeploymentParams contains parameters for the patch_deployment action. Applies a patch to a deployment using the specified strategy." }, "RestartDeploymentParams": { "additionalProperties": false, diff --git a/kubeactions/jsonschema/PatchDeploymentParams.json b/kubeactions/jsonschema/PatchDeploymentParams.json index 9651faad..eadd512c 100644 --- a/kubeactions/jsonschema/PatchDeploymentParams.json +++ b/kubeactions/jsonschema/PatchDeploymentParams.json @@ -9,15 +9,19 @@ "properties": { "patch": { "type": "string", - "description": "Patch is the raw JSON strategic merge patch to apply to the deployment. The patch is applied as-is using the Kubernetes strategic merge patch strategy. Example: {\"spec\": {\"replicas\": 3}} to scale, or {\"spec\": {\"template\": {\"spec\": {\"containers\": [{\"name\": \"app\", \"image\": \"app:v2\"}]}}}} to update an image.", + "description": "Patch is the raw JSON patch to apply to the deployment. Example: {\"spec\": {\"replicas\": 3}} to scale, or {\"spec\": {\"template\": {\"spec\": {\"containers\": [{\"name\": \"app\", \"image\": \"app:v2\"}]}}}} to update an image.", "format": "binary", "binaryEncoding": "base64" + }, + "patch_strategy": { + "type": "string", + "description": "PatchStrategy specifies the Kubernetes patch strategy to use. Supported values: \"strategic-merge\" (default) - Strategic merge patch, understands K8s resource structure (e.g. merges lists by key) \"merge\" - RFC 7386 JSON merge patch, simple merge that replaces arrays entirely \"json\" - RFC 6902 JSON patch, explicit add/remove/replace operations at specific paths If not specified, defaults to \"strategic-merge\"." } }, "additionalProperties": true, "type": "object", "title": "Patch Deployment Params", - "description": "PatchDeploymentParams contains parameters for the patch_deployment action. Applies a strategic merge patch to a deployment." + "description": "PatchDeploymentParams contains parameters for the patch_deployment action. Applies a patch to a deployment using the specified strategy." } } } \ No newline at end of file diff --git a/kubeactions/kubeactions.pb.go b/kubeactions/kubeactions.pb.go index 36fa8779..afdb6899 100644 --- a/kubeactions/kubeactions.pb.go +++ b/kubeactions/kubeactions.pb.go @@ -303,18 +303,26 @@ func (*RestartDeploymentParams) Descriptor() ([]byte, []int) { } // PatchDeploymentParams contains parameters for the patch_deployment action. -// Applies a strategic merge patch to a deployment. +// Applies a patch to a deployment using the specified strategy. type PatchDeploymentParams struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // Patch is the raw JSON strategic merge patch to apply to the deployment. - // The patch is applied as-is using the Kubernetes strategic merge patch strategy. + // Patch is the raw JSON patch to apply to the deployment. // Example: {"spec": {"replicas": 3}} to scale, or // // {"spec": {"template": {"spec": {"containers": [{"name": "app", "image": "app:v2"}]}}}} to update an image. Patch []byte `protobuf:"bytes,1,opt,name=patch,proto3" json:"patch,omitempty"` + // PatchStrategy specifies the Kubernetes patch strategy to use. + // Supported values: + // + // "strategic-merge" (default) - Strategic merge patch, understands K8s resource structure (e.g. merges lists by key) + // "merge" - RFC 7386 JSON merge patch, simple merge that replaces arrays entirely + // "json" - RFC 6902 JSON patch, explicit add/remove/replace operations at specific paths + // + // If not specified, defaults to "strategic-merge". + PatchStrategy string `protobuf:"bytes,2,opt,name=patch_strategy,json=patchStrategy,proto3" json:"patch_strategy,omitempty"` } func (x *PatchDeploymentParams) Reset() { @@ -356,6 +364,13 @@ func (x *PatchDeploymentParams) GetPatch() []byte { return nil } +func (x *PatchDeploymentParams) GetPatchStrategy() string { + if x != nil { + return x.PatchStrategy + } + return "" +} + // KubeResource represents a Kubernetes resource to act on type KubeResource struct { state protoimpl.MessageState @@ -585,42 +600,44 @@ var file_github_com_DataDog_agent_payload_v5_proto_kubeactions_kubeactions_proto 0x63, 0x65, 0x5f, 0x70, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x5f, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x22, 0x20, 0x0a, 0x17, 0x52, 0x65, 0x73, 0x74, 0x61, 0x72, 0x74, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x3a, 0x05, 0xba, 0x46, - 0x02, 0x20, 0x01, 0x22, 0x34, 0x0a, 0x15, 0x50, 0x61, 0x74, 0x63, 0x68, 0x44, 0x65, 0x70, 0x6c, + 0x02, 0x20, 0x01, 0x22, 0x5b, 0x0a, 0x15, 0x50, 0x61, 0x74, 0x63, 0x68, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x1b, 0x0a, 0x05, 0x70, 0x61, 0x74, 0x63, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x05, 0xaa, 0x46, 0x02, - 0x10, 0x01, 0x52, 0x05, 0x70, 0x61, 0x74, 0x63, 0x68, 0x22, 0xb9, 0x01, 0x0a, 0x0c, 0x4b, 0x75, - 0x62, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x70, - 0x69, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0a, 0x61, 0x70, 0x69, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x19, 0x0a, 0x04, 0x6b, - 0x69, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x05, 0xaa, 0x46, 0x02, 0x10, 0x01, - 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x23, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, - 0x61, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x05, 0xaa, 0x46, 0x02, 0x10, 0x01, - 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x19, 0x0a, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x05, 0xaa, 0x46, 0x02, 0x10, 0x01, - 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x26, 0x0a, 0x0b, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x42, 0x05, 0xaa, 0x46, 0x02, - 0x10, 0x01, 0x52, 0x0a, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x3a, 0x05, - 0xba, 0x46, 0x02, 0x20, 0x01, 0x22, 0xfe, 0x01, 0x0a, 0x10, 0x4b, 0x75, 0x62, 0x65, 0x41, 0x63, - 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x22, 0x0a, 0x09, 0x61, 0x63, - 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x05, 0xaa, - 0x46, 0x02, 0x10, 0x01, 0x52, 0x08, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1f, - 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x42, - 0x05, 0xaa, 0x46, 0x02, 0x10, 0x01, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, - 0x26, 0x0a, 0x0b, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x42, 0x05, 0xaa, 0x46, 0x02, 0x10, 0x01, 0x52, 0x0a, 0x61, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1d, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x05, 0xaa, 0x46, 0x02, 0x10, 0x01, 0x52, 0x06, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x12, 0x3b, 0x0a, 0x0b, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, - 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x52, 0x0a, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x64, 0x41, 0x74, 0x3a, 0x07, 0xba, - 0x46, 0x04, 0x08, 0x01, 0x20, 0x01, 0x42, 0x31, 0x5a, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x44, 0x61, 0x74, 0x61, 0x44, 0x6f, 0x67, 0x2f, 0x61, 0x67, 0x65, - 0x6e, 0x74, 0x2d, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2f, 0x76, 0x35, 0x2f, 0x6b, 0x75, - 0x62, 0x65, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x10, 0x01, 0x52, 0x05, 0x70, 0x61, 0x74, 0x63, 0x68, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x61, 0x74, + 0x63, 0x68, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0d, 0x70, 0x61, 0x74, 0x63, 0x68, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, + 0x22, 0xb9, 0x01, 0x0a, 0x0c, 0x4b, 0x75, 0x62, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x70, 0x69, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x70, 0x69, 0x56, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x12, 0x19, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x42, 0x05, 0xaa, 0x46, 0x02, 0x10, 0x01, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x23, 0x0a, + 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x42, 0x05, 0xaa, 0x46, 0x02, 0x10, 0x01, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x12, 0x19, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, + 0x42, 0x05, 0xaa, 0x46, 0x02, 0x10, 0x01, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x26, 0x0a, + 0x0b, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x09, 0x42, 0x05, 0xaa, 0x46, 0x02, 0x10, 0x01, 0x52, 0x0a, 0x72, 0x65, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x49, 0x64, 0x3a, 0x05, 0xba, 0x46, 0x02, 0x20, 0x01, 0x22, 0xfe, 0x01, 0x0a, + 0x10, 0x4b, 0x75, 0x62, 0x65, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x75, 0x6c, + 0x74, 0x12, 0x22, 0x0a, 0x09, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x42, 0x05, 0xaa, 0x46, 0x02, 0x10, 0x01, 0x52, 0x08, 0x61, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x42, 0x05, 0xaa, 0x46, 0x02, 0x10, 0x01, 0x52, 0x07, 0x76, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x26, 0x0a, 0x0b, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x05, 0xaa, 0x46, 0x02, + 0x10, 0x01, 0x52, 0x0a, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1d, + 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x05, + 0xaa, 0x46, 0x02, 0x10, 0x01, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x18, 0x0a, + 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x3b, 0x0a, 0x0b, 0x65, 0x78, 0x65, 0x63, 0x75, + 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, + 0x65, 0x64, 0x41, 0x74, 0x3a, 0x07, 0xba, 0x46, 0x04, 0x08, 0x01, 0x20, 0x01, 0x42, 0x31, 0x5a, + 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x44, 0x61, 0x74, 0x61, + 0x44, 0x6f, 0x67, 0x2f, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x2d, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, + 0x64, 0x2f, 0x76, 0x35, 0x2f, 0x6b, 0x75, 0x62, 0x65, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proto/kubeactions/kubeactions.proto b/proto/kubeactions/kubeactions.proto index 0798928f..110954e7 100644 --- a/proto/kubeactions/kubeactions.proto +++ b/proto/kubeactions/kubeactions.proto @@ -69,13 +69,20 @@ message RestartDeploymentParams { } // PatchDeploymentParams contains parameters for the patch_deployment action. -// Applies a strategic merge patch to a deployment. +// Applies a patch to a deployment using the specified strategy. message PatchDeploymentParams { - // Patch is the raw JSON strategic merge patch to apply to the deployment. - // The patch is applied as-is using the Kubernetes strategic merge patch strategy. + // Patch is the raw JSON patch to apply to the deployment. // Example: {"spec": {"replicas": 3}} to scale, or // {"spec": {"template": {"spec": {"containers": [{"name": "app", "image": "app:v2"}]}}}} to update an image. bytes patch = 1 [(protoc.gen.jsonschema.field_options).required = true]; + + // PatchStrategy specifies the Kubernetes patch strategy to use. + // Supported values: + // "strategic-merge" (default) - Strategic merge patch, understands K8s resource structure (e.g. merges lists by key) + // "merge" - RFC 7386 JSON merge patch, simple merge that replaces arrays entirely + // "json" - RFC 6902 JSON patch, explicit add/remove/replace operations at specific paths + // If not specified, defaults to "strategic-merge". + string patch_strategy = 2; } // KubeResource represents a Kubernetes resource to act on