fix: mixed patch formats - #1909
Merged
Merged
Conversation
`drift-detection-config` supports both legacy bare patches and structured `libsveltosv1beta1.Patch` documents, but the two formats couldn't be mixed in one ConfigMap. `getPatchesFromConfigMap` parsed the whole ConfigMap as structured `Patch` documents. A single legacy-formatted entry caused that parse to fail for the **entire** ConfigMap. That caused **every** entry including already structured ones, as a raw legacy patch. This PR fixes that by making the legacy/structured fallback happen per ConfigMap entry instead of per ConfigMap.
Member
Author
|
Locally tried with this ConfigMap apiVersion: v1
kind: ConfigMap
metadata:
name: drift-detection-config
namespace: projectsveltos
data:
# Legacy bare-patch format: raw StrategicMerge patch, no "patch:" wrapper.
# Adds label fv-legacy-patch=applied to the drift-detection-manager Deployment.
legacy-patch: |-
apiVersion: apps/v1
kind: Deployment
metadata:
name: drift-detection-manager
labels:
fv-legacy-patch: applied
# Structured libsveltosv1beta1.Patch format: JSON6902 under "patch:", with
# optional explicit "target:". Adds label fv-structured-patch=applied.
structured-patch: |-
patch: |-
- op: add
path: /metadata/labels/fv-structured-patch
value: applied
target:
kind: Deployment
group: apps
name: drift-detection-managerThe drift-detection deployment is - apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "1"
creationTimestamp: "2026-08-08T15:10:41Z"
generation: 1
labels:
control-plane: drift-detection-manager
fv-legacy-patch: applied
fv-structured-patch: applied
name: drift-detection-manager
namespace: projectsveltos |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
drift-detection-configsupports both legacy bare patches and structuredlibsveltosv1beta1.Patchdocuments, but the two formats couldn't be mixed in one ConfigMap.getPatchesFromConfigMapparsed the whole ConfigMap as structuredPatchdocuments. A single legacy-formatted entry caused that parse to fail for the entire ConfigMap. That caused every entry including already structured ones, as a raw legacy patch.This PR fixes that by making the legacy/structured fallback happen per ConfigMap entry instead of per ConfigMap.
Fixes #1908