mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 10:15:22 +00:00
This PR - defines a patch conflict detector interface, - extracts implementations of the interface from the merginator code, making the merginator code independent of --enable_kyaml. - injects those implementations into kustomize as a function of --enable_kyaml. So, instead of using different merginators to combine resmaps, this pr allows the use of a single patch merge code path that uses different conflict detectors. So instead of debating how to merge, we're now only considering whether to warn on conflict detection in one transformer. This PR is in service of #3304, eliminating seven instances where --enable_kyaml was consulted. These were cases where conflict detection wasn't an issue (but merging patches was).
21 lines
668 B
Go
21 lines
668 B
Go
// Copyright 2019 The Kubernetes Authors.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package resource
|
|
|
|
import "sigs.k8s.io/kustomize/api/resid"
|
|
|
|
// ConflictDetector detects conflicts between resources.
|
|
type ConflictDetector interface {
|
|
// HasConflict returns true if the given resources have a conflict.
|
|
HasConflict(patch1, patch2 *Resource) (bool, error)
|
|
// Merge two resources into one.
|
|
MergePatches(patch1, patch2 *Resource) (*Resource, error)
|
|
}
|
|
|
|
// ConflictDetectorFactory makes instances of ConflictDetector that know
|
|
// how to handle the given Group, Version, Kind tuple.
|
|
type ConflictDetectorFactory interface {
|
|
New(gvk resid.Gvk) (ConflictDetector, error)
|
|
}
|