mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
Merge pull request #3795 from jlandowner/master
Support immutable attribute on generators
This commit is contained in:
@@ -15,6 +15,9 @@ type GeneratorOptions struct {
|
||||
// suffix to the names of generated resources that is a hash of the
|
||||
// resource contents.
|
||||
DisableNameSuffixHash bool `json:"disableNameSuffixHash,omitempty" yaml:"disableNameSuffixHash,omitempty"`
|
||||
|
||||
// Immutable if true add to all generated resources.
|
||||
Immutable bool `json:"immutable,omitempty" yaml:"immutable,omitempty"`
|
||||
}
|
||||
|
||||
// MergeGlobalOptionsIntoLocal merges two instances of GeneratorOptions.
|
||||
@@ -42,6 +45,9 @@ func MergeGlobalOptionsIntoLocal(
|
||||
if globalOpts.DisableNameSuffixHash {
|
||||
localOpts.DisableNameSuffixHash = true
|
||||
}
|
||||
if globalOpts.Immutable {
|
||||
localOpts.Immutable = true
|
||||
}
|
||||
return localOpts
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ func TestMergeGlobalOptionsIntoLocal(t *testing.T) {
|
||||
Labels: map[string]string{"pet": "dog"},
|
||||
Annotations: map[string]string{"fruit": "apple"},
|
||||
DisableNameSuffixHash: false,
|
||||
Immutable: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -47,6 +48,7 @@ func TestMergeGlobalOptionsIntoLocal(t *testing.T) {
|
||||
Labels: map[string]string{"pet": "dog"},
|
||||
Annotations: map[string]string{"fruit": "apple"},
|
||||
DisableNameSuffixHash: false,
|
||||
Immutable: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -76,42 +78,52 @@ func TestMergeGlobalOptionsIntoLocal(t *testing.T) {
|
||||
"tesla": "Y",
|
||||
},
|
||||
DisableNameSuffixHash: false,
|
||||
Immutable: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "global disable trumps local",
|
||||
local: &GeneratorOptions{
|
||||
DisableNameSuffixHash: false,
|
||||
Immutable: false,
|
||||
},
|
||||
global: &GeneratorOptions{
|
||||
DisableNameSuffixHash: true,
|
||||
Immutable: true,
|
||||
},
|
||||
expected: &GeneratorOptions{
|
||||
DisableNameSuffixHash: true,
|
||||
Immutable: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "local disable works",
|
||||
local: &GeneratorOptions{
|
||||
DisableNameSuffixHash: true,
|
||||
Immutable: true,
|
||||
},
|
||||
global: &GeneratorOptions{
|
||||
DisableNameSuffixHash: false,
|
||||
Immutable: false,
|
||||
},
|
||||
expected: &GeneratorOptions{
|
||||
DisableNameSuffixHash: true,
|
||||
Immutable: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "everyone wants disable",
|
||||
local: &GeneratorOptions{
|
||||
DisableNameSuffixHash: true,
|
||||
Immutable: true,
|
||||
},
|
||||
global: &GeneratorOptions{
|
||||
DisableNameSuffixHash: true,
|
||||
Immutable: true,
|
||||
},
|
||||
expected: &GeneratorOptions{
|
||||
DisableNameSuffixHash: true,
|
||||
Immutable: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user