mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
Extract common generator args to common type.
This commit is contained in:
@@ -92,7 +92,7 @@ func TestConstructConfigMap(t *testing.T) {
|
|||||||
{
|
{
|
||||||
description: "construct config map from env",
|
description: "construct config map from env",
|
||||||
input: types.ConfigMapArgs{
|
input: types.ConfigMapArgs{
|
||||||
Name: "envConfigMap",
|
GeneratorArgs: types.GeneratorArgs{Name: "envConfigMap"},
|
||||||
DataSources: types.DataSources{
|
DataSources: types.DataSources{
|
||||||
EnvSource: "configmap/app.env",
|
EnvSource: "configmap/app.env",
|
||||||
},
|
},
|
||||||
@@ -103,7 +103,7 @@ func TestConstructConfigMap(t *testing.T) {
|
|||||||
{
|
{
|
||||||
description: "construct config map from file",
|
description: "construct config map from file",
|
||||||
input: types.ConfigMapArgs{
|
input: types.ConfigMapArgs{
|
||||||
Name: "fileConfigMap",
|
GeneratorArgs: types.GeneratorArgs{Name: "fileConfigMap"},
|
||||||
DataSources: types.DataSources{
|
DataSources: types.DataSources{
|
||||||
FileSources: []string{"configmap/app-init.ini"},
|
FileSources: []string{"configmap/app-init.ini"},
|
||||||
},
|
},
|
||||||
@@ -114,7 +114,7 @@ func TestConstructConfigMap(t *testing.T) {
|
|||||||
{
|
{
|
||||||
description: "construct config map from literal",
|
description: "construct config map from literal",
|
||||||
input: types.ConfigMapArgs{
|
input: types.ConfigMapArgs{
|
||||||
Name: "literalConfigMap",
|
GeneratorArgs: types.GeneratorArgs{Name: "literalConfigMap"},
|
||||||
DataSources: types.DataSources{
|
DataSources: types.DataSources{
|
||||||
LiteralSources: []string{"a=x", "b=y", "c=\"Hello World\"", "d='true'"},
|
LiteralSources: []string{"a=x", "b=y", "c=\"Hello World\"", "d='true'"},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ func makeConfigMapArgs(m *types.Kustomization, name string) *types.ConfigMapArgs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// config map not found, create new one and add it to the kustomization file.
|
// config map not found, create new one and add it to the kustomization file.
|
||||||
cm := &types.ConfigMapArgs{Name: name}
|
cm := &types.ConfigMapArgs{GeneratorArgs: types.GeneratorArgs{Name: name}}
|
||||||
m.ConfigMapGenerator = append(m.ConfigMapGenerator, *cm)
|
m.ConfigMapGenerator = append(m.ConfigMapGenerator, *cm)
|
||||||
return &m.ConfigMapGenerator[len(m.ConfigMapGenerator)-1]
|
return &m.ConfigMapGenerator[len(m.ConfigMapGenerator)-1]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ func TestNewFromConfigMaps(t *testing.T) {
|
|||||||
description: "construct config map from env",
|
description: "construct config map from env",
|
||||||
input: []types.ConfigMapArgs{
|
input: []types.ConfigMapArgs{
|
||||||
{
|
{
|
||||||
Name: "envConfigMap",
|
GeneratorArgs: types.GeneratorArgs{Name: "envConfigMap"},
|
||||||
DataSources: types.DataSources{
|
DataSources: types.DataSources{
|
||||||
EnvSource: "app.env",
|
EnvSource: "app.env",
|
||||||
},
|
},
|
||||||
@@ -177,7 +177,7 @@ func TestNewFromConfigMaps(t *testing.T) {
|
|||||||
{
|
{
|
||||||
description: "construct config map from file",
|
description: "construct config map from file",
|
||||||
input: []types.ConfigMapArgs{{
|
input: []types.ConfigMapArgs{{
|
||||||
Name: "fileConfigMap",
|
GeneratorArgs: types.GeneratorArgs{Name: "fileConfigMap"},
|
||||||
DataSources: types.DataSources{
|
DataSources: types.DataSources{
|
||||||
FileSources: []string{"app-init.ini"},
|
FileSources: []string{"app-init.ini"},
|
||||||
},
|
},
|
||||||
@@ -205,7 +205,7 @@ BAR=baz
|
|||||||
description: "construct config map from literal",
|
description: "construct config map from literal",
|
||||||
input: []types.ConfigMapArgs{
|
input: []types.ConfigMapArgs{
|
||||||
{
|
{
|
||||||
Name: "literalConfigMap",
|
GeneratorArgs: types.GeneratorArgs{Name: "literalConfigMap"},
|
||||||
DataSources: types.DataSources{
|
DataSources: types.DataSources{
|
||||||
LiteralSources: []string{"a=x", "b=y", "c=\"Good Morning\"", "d=\"false\""},
|
LiteralSources: []string{"a=x", "b=y", "c=\"Good Morning\"", "d=\"false\""},
|
||||||
},
|
},
|
||||||
@@ -251,7 +251,7 @@ var secret = gvk.Gvk{Version: "v1", Kind: "Secret"}
|
|||||||
func TestNewResMapFromSecretArgs(t *testing.T) {
|
func TestNewResMapFromSecretArgs(t *testing.T) {
|
||||||
secrets := []types.SecretArgs{
|
secrets := []types.SecretArgs{
|
||||||
{
|
{
|
||||||
Name: "apple",
|
GeneratorArgs: types.GeneratorArgs{Name: "apple"},
|
||||||
CommandSources: types.CommandSources{
|
CommandSources: types.CommandSources{
|
||||||
Commands: map[string]string{
|
Commands: map[string]string{
|
||||||
"DB_USERNAME": "printf admin",
|
"DB_USERNAME": "printf admin",
|
||||||
@@ -261,7 +261,7 @@ func TestNewResMapFromSecretArgs(t *testing.T) {
|
|||||||
Type: ifc.SecretTypeOpaque,
|
Type: ifc.SecretTypeOpaque,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "peanuts",
|
GeneratorArgs: types.GeneratorArgs{Name: "peanuts"},
|
||||||
CommandSources: types.CommandSources{
|
CommandSources: types.CommandSources{
|
||||||
EnvCommand: "printf \"DB_USERNAME=admin\nDB_PASSWORD=somepw\"",
|
EnvCommand: "printf \"DB_USERNAME=admin\nDB_PASSWORD=somepw\"",
|
||||||
},
|
},
|
||||||
@@ -314,7 +314,7 @@ func TestSecretTimeout(t *testing.T) {
|
|||||||
timeout := int64(1)
|
timeout := int64(1)
|
||||||
secrets := []types.SecretArgs{
|
secrets := []types.SecretArgs{
|
||||||
{
|
{
|
||||||
Name: "slow",
|
GeneratorArgs: types.GeneratorArgs{Name: "slow"},
|
||||||
TimeoutSeconds: &timeout,
|
TimeoutSeconds: &timeout,
|
||||||
CommandSources: types.CommandSources{
|
CommandSources: types.CommandSources{
|
||||||
Commands: map[string]string{
|
Commands: map[string]string{
|
||||||
|
|||||||
@@ -146,21 +146,27 @@ func (k *Kustomization) DealWithDeprecatedFields() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConfigMapArgs contains the metadata of how to generate a configmap.
|
// GeneratorArgs contains arguments common to generators.
|
||||||
type ConfigMapArgs struct {
|
type GeneratorArgs struct {
|
||||||
// Name of the configmap.
|
|
||||||
// The full name should be Kustomization.NamePrefix + Configmap.Name +
|
|
||||||
// hash(content of configmap).
|
|
||||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
|
||||||
|
|
||||||
// Namespace for the configmap, optional
|
// Namespace for the configmap, optional
|
||||||
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
|
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
|
||||||
|
|
||||||
// behavior of configmap, must be one of create, merge and replace
|
// Name - actually the partial name - of the generated resource.
|
||||||
// 'create': create a new one;
|
// The full name ends up being something like
|
||||||
// 'replace': replace the existing one;
|
// NamePrefix + this.Name + hash(content of generated resource).
|
||||||
// 'merge': merge the existing one.
|
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||||
|
|
||||||
|
// Behavior of generated resource, must be one of:
|
||||||
|
// 'create': create a new one
|
||||||
|
// 'replace': replace the existing one
|
||||||
|
// 'merge': merge with the existing one
|
||||||
Behavior string `json:"behavior,omitempty" yaml:"behavior,omitempty"`
|
Behavior string `json:"behavior,omitempty" yaml:"behavior,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ConfigMapArgs contains the metadata of how to generate a configmap.
|
||||||
|
type ConfigMapArgs struct {
|
||||||
|
// GeneratorArgs for the configmap.
|
||||||
|
GeneratorArgs `json:",inline,omitempty" yaml:",inline,omitempty"`
|
||||||
|
|
||||||
// DataSources for configmap.
|
// DataSources for configmap.
|
||||||
DataSources `json:",inline,omitempty" yaml:",inline,omitempty"`
|
DataSources `json:",inline,omitempty" yaml:",inline,omitempty"`
|
||||||
@@ -168,19 +174,8 @@ type ConfigMapArgs struct {
|
|||||||
|
|
||||||
// SecretArgs contains the metadata of how to generate a secret.
|
// SecretArgs contains the metadata of how to generate a secret.
|
||||||
type SecretArgs struct {
|
type SecretArgs struct {
|
||||||
// Name of the secret.
|
// GeneratorArgs for the secret.
|
||||||
// The full name should be Kustomization.NamePrefix + SecretGenerator.Name +
|
GeneratorArgs `json:",inline,omitempty" yaml:",inline,omitempty"`
|
||||||
// hash(content of secret).
|
|
||||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
|
||||||
|
|
||||||
// Namespace for the secret, optional
|
|
||||||
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
|
|
||||||
|
|
||||||
// behavior of secretGenerator, must be one of create, merge and replace
|
|
||||||
// 'create': create a new one;
|
|
||||||
// 'replace': replace the existing one;
|
|
||||||
// 'merge': merge the existing one.
|
|
||||||
Behavior string `json:"behavior,omitempty" yaml:"behavior,omitempty"`
|
|
||||||
|
|
||||||
// Type of the secret.
|
// Type of the secret.
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user