mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-13 01:50:55 +00:00
Extract conflict detection to it's own interface.
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).
This commit is contained in:
20
api/resource/conflictdetector.go
Normal file
20
api/resource/conflictdetector.go
Normal file
@@ -0,0 +1,20 @@
|
||||
// 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)
|
||||
}
|
||||
Reference in New Issue
Block a user