Add MergeMode for toggling highlighting of merge conflicts#218
Add MergeMode for toggling highlighting of merge conflicts#218LucaBernstein wants to merge 6 commits intogardener:mainfrom
MergeMode for toggling highlighting of merge conflicts#218Conversation
Introduces `MergeMode` (Silent/Informative) and threads it through `threeWayMerge`, `threeWayMergeSection`, and `threeWayMergeSequence`. In `MergeModeInformative`, when an operator-overridden scalar value differs from the current GLK default, a `# glk default: <value> # <-- glk-managed` line comment is appended to the value node. For complex nodes (mappings/sequences), a head comment on the key node signals the divergence. `WriteComponentVectorFile`, `stripDefaultVersionComments`, and `defaultVersionCommentMarker` are deleted. Their functionality is now covered generically by `WriteObjectsToFilesystem(MergeModeInformative)``, which plain.go already calls directly. The corresponding test describe block is removed along with the now-unused imports. Operator-comments are retained.
…l-sites Existing callers pass `MergeModeSilent` (zero value, no behaviour change). plain.go passes `MergeModeInformative` so the components.yaml file gets GLK default annotations for operator-overridden component versions.
|
/assign |
| // GetMergeMode returns the configured MergeMode, defaulting to MergeModeInformative. | ||
| // It is safe to call on a nil receiver. | ||
| func (c *LandscapeKitConfiguration) GetMergeMode() MergeMode { | ||
| if c != nil && c.MergeMode != nil { | ||
| return *c.MergeMode | ||
| } | ||
| return MergeModeInformative | ||
| } |
There was a problem hiding this comment.
Use a default value assignment instead?
There was a problem hiding this comment.
Currently we are not defaulting for any option - or wdym?
There was a problem hiding this comment.
I meant in Gardener or Kubernetes APIs in general. It should belong to https://github.com/gardener/gardener-landscape-kit/blob/main/pkg/apis/config/v1alpha1/defaults.go.
pkg/utils/files/writer_test.go
Outdated
| }) | ||
| }) | ||
|
|
||
| Describe("#WriteObjectsToFilesystem - MergeModeInformative", func() { |
There was a problem hiding this comment.
Can you make use of Context to run the different modes?
There was a problem hiding this comment.
updated the tests, ptal
pkg/utils/meta/merge.go
Outdated
| resultValue = currentValue | ||
| if oldExists { | ||
| mergeNodeComments(oldValue, newValueNode, resultValue) | ||
| if mode == configv1alpha1.MergeModeInformative && !nodesEqual(newValueNode, currentValue, false) { |
There was a problem hiding this comment.
| if mode == configv1alpha1.MergeModeInformative && !nodesEqual(newValueNode, currentValue, false) { | |
| if mode == configv1alpha1.MergeModeInformative && !nodesEqual(oldValue, newValueNode, false) && !nodesEqual(newValueNode, currentValue, false) { |
Otherwise the annotation is added every time for customized values.
There was a problem hiding this comment.
reworked the merge logic w.r.t. the default comments. ptal.
pkg/utils/meta/merge.go
Outdated
|
|
||
| // GLKDefaultPrefix is the comment prefix for GLK-managed default annotations. | ||
| // It is exported so callers can use it as the strip anchor when removing annotations. | ||
| GLKDefaultPrefix = "# glk default: " |
There was a problem hiding this comment.
| GLKDefaultPrefix = "# glk default: " | |
| GLKDefaultPrefix = "# Attention - new default: " |
Something like this?
| resultValue.LineComment = annotation | ||
| } | ||
| default: | ||
| resultKeyNode.HeadComment = glkManagedHeadComment(resultKeyNode.HeadComment) |
There was a problem hiding this comment.
The comment is not added for lists. Instead, when a default values of a list item is changed, the item is completely appended to the list.
Example:
t0: Default
- apiGroups: [ "core.gardener.cloud" ]
apiVersions: [ "*" ]
resources: [ "shoots" ]
size: 750Ki
t1: Overwrite
- apiGroups: [ "core.gardener.cloud" ]
apiVersions: [ "*" ]
resources: [ "shoots" ]
size: 850Ki
t2: Default
- apiGroups: [ "core.gardener.cloud" ]
apiVersions: [ "*" ]
resources: [ "shoots" ]
size: 950Ki
t3: Result
- apiGroups: [ "core.gardener.cloud" ]
apiVersions: [ "*" ]
resources: [ "shoots" ]
size: 850Ki
- apiGroups: [ "core.gardener.cloud" ]
apiVersions: [ "*" ]
resources: [ "shoots" ]
size: 950Ki
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
How to categorize this PR?
/area usability
/kind enhancement
What this PR does / why we need it:
Currently, once a
components.yamlfile is present, its versions will not be updated anymore byresolve plain. This PR makes the glk update non-overridden versions.Also, the "default-value"-handling that until now was only applied to the
components.yaml, has been extended to all manifests by integrating it intoWriteObjectsToFilesystem/ThreeWayMergeManifest.Which issue(s) this PR fixes:
Fixes #210
Follow-up to #216
Special notes for your reviewer:
/cc @timuthy
Release note: