mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-13 10:00:56 +00:00
refactor the strategic merge patch transformer toward moving it to a plugin (#1340)
This commit is contained in:
@@ -14,11 +14,12 @@ import (
|
||||
// Factory makes instances of ResMap.
|
||||
type Factory struct {
|
||||
resF *resource.Factory
|
||||
tf PatchFactory
|
||||
}
|
||||
|
||||
// NewFactory returns a new resmap.Factory.
|
||||
func NewFactory(rf *resource.Factory) *Factory {
|
||||
return &Factory{resF: rf}
|
||||
func NewFactory(rf *resource.Factory, tf PatchFactory) *Factory {
|
||||
return &Factory{resF: rf, tf: tf}
|
||||
}
|
||||
|
||||
// RF returns a resource.Factory.
|
||||
@@ -118,6 +119,11 @@ func (rmF *Factory) FromSecretArgs(
|
||||
return rmF.FromResource(res), nil
|
||||
}
|
||||
|
||||
func (rmF *Factory) MergePatches(patches []*resource.Resource) (
|
||||
ResMap, error) {
|
||||
return rmF.tf.MergePatches(patches, rmF.resF)
|
||||
}
|
||||
|
||||
func newResMapFromResourceSlice(resources []*resource.Resource) (ResMap, error) {
|
||||
result := New()
|
||||
for _, res := range resources {
|
||||
|
||||
15
pkg/resmap/patchfactory.go
Normal file
15
pkg/resmap/patchfactory.go
Normal file
@@ -0,0 +1,15 @@
|
||||
/// Copyright 2019 The Kubernetes Authors.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Package patch holds miscellaneous interfaces used by kustomize.
|
||||
package resmap
|
||||
|
||||
import (
|
||||
"sigs.k8s.io/kustomize/v3/pkg/resource"
|
||||
)
|
||||
|
||||
// PatchFactory makes transformers that require k8sdeps.
|
||||
type PatchFactory interface {
|
||||
MergePatches(patches []*resource.Resource,
|
||||
rf *resource.Factory) (ResMap, error)
|
||||
}
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
|
||||
var rf = resource.NewFactory(
|
||||
kunstruct.NewKunstructuredFactoryImpl())
|
||||
var rmF = NewFactory(rf)
|
||||
var rmF = NewFactory(rf, nil)
|
||||
|
||||
func doAppend(t *testing.T, w ResMap, r *resource.Resource) {
|
||||
err := w.Append(r)
|
||||
|
||||
Reference in New Issue
Block a user