mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-13 10:00:56 +00:00
Refactor the PrefixSuffixTransformer into separate prefix- and suffix transformers (#4318)
* Refactor prefix filter into its own filter, decoupled from the prefixsuffix filter * Refactor prefix transformer into its own transformer, decoupled from the prefixsuffix transformer * Refactor suffix filter into its own filter, decoupled from the prefixsuffix filter * Refactor suffix transformer into its own transformer, decoupled from the prefixsuffix transformer * Add a default nameSuffix field spec in addition to the namePrefix * Remove the PrefixSuffixTransformer from the list of builtin transformers * Add a multi-transformer to builtinhelpers.TransformFactories * Remove the implementation of the prefixsuffixtransformer.PrefixSuffixTransformer * Resolve style and format related feedback from the pull request * Add test to test the legacy PrefixSuffixTransformer for BC purposes
This commit is contained in:
@@ -51,7 +51,8 @@ func (kt *KustTarget) configureBuiltinTransformers(
|
||||
builtinhelpers.PatchStrategicMergeTransformer,
|
||||
builtinhelpers.PatchTransformer,
|
||||
builtinhelpers.NamespaceTransformer,
|
||||
builtinhelpers.PrefixSuffixTransformer,
|
||||
builtinhelpers.PrefixTransformer,
|
||||
builtinhelpers.SuffixTransformer,
|
||||
builtinhelpers.LabelTransformer,
|
||||
builtinhelpers.AnnotationsTransformer,
|
||||
builtinhelpers.PatchJson6902Transformer,
|
||||
@@ -286,16 +287,14 @@ var transformerConfigurators = map[builtinhelpers.BuiltinPluginType]func(
|
||||
result = append(result, p)
|
||||
return
|
||||
},
|
||||
builtinhelpers.PrefixSuffixTransformer: func(
|
||||
builtinhelpers.PrefixTransformer: func(
|
||||
kt *KustTarget, bpt builtinhelpers.BuiltinPluginType, f tFactory, tc *builtinconfig.TransformerConfig) (
|
||||
result []resmap.Transformer, err error) {
|
||||
var c struct {
|
||||
Prefix string
|
||||
Suffix string
|
||||
FieldSpecs []types.FieldSpec
|
||||
Prefix string `json:"prefix,omitempty" yaml:"prefix,omitempty"`
|
||||
FieldSpecs []types.FieldSpec `json:"fieldSpecs,omitempty" yaml:"fieldSpecs,omitempty"`
|
||||
}
|
||||
c.Prefix = kt.kustomization.NamePrefix
|
||||
c.Suffix = kt.kustomization.NameSuffix
|
||||
c.FieldSpecs = tc.NamePrefix
|
||||
p := f()
|
||||
err = kt.configureBuiltinPlugin(p, c, bpt)
|
||||
@@ -305,6 +304,23 @@ var transformerConfigurators = map[builtinhelpers.BuiltinPluginType]func(
|
||||
result = append(result, p)
|
||||
return
|
||||
},
|
||||
builtinhelpers.SuffixTransformer: func(
|
||||
kt *KustTarget, bpt builtinhelpers.BuiltinPluginType, f tFactory, tc *builtinconfig.TransformerConfig) (
|
||||
result []resmap.Transformer, err error) {
|
||||
var c struct {
|
||||
Suffix string `json:"suffix,omitempty" yaml:"suffix,omitempty"`
|
||||
FieldSpecs []types.FieldSpec `json:"fieldSpecs,omitempty" yaml:"fieldSpecs,omitempty"`
|
||||
}
|
||||
c.Suffix = kt.kustomization.NameSuffix
|
||||
c.FieldSpecs = tc.NameSuffix
|
||||
p := f()
|
||||
err = kt.configureBuiltinPlugin(p, c, bpt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result = append(result, p)
|
||||
return
|
||||
},
|
||||
builtinhelpers.ImageTagTransformer: func(
|
||||
kt *KustTarget, bpt builtinhelpers.BuiltinPluginType, f tFactory, tc *builtinconfig.TransformerConfig) (
|
||||
result []resmap.Transformer, err error) {
|
||||
|
||||
Reference in New Issue
Block a user