mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-21 14:32:03 +00:00
Merge pull request #609 from monopole/typeFix
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",
|
||||
input: types.ConfigMapArgs{
|
||||
Name: "envConfigMap",
|
||||
GeneratorArgs: types.GeneratorArgs{Name: "envConfigMap"},
|
||||
DataSources: types.DataSources{
|
||||
EnvSource: "configmap/app.env",
|
||||
},
|
||||
@@ -103,7 +103,7 @@ func TestConstructConfigMap(t *testing.T) {
|
||||
{
|
||||
description: "construct config map from file",
|
||||
input: types.ConfigMapArgs{
|
||||
Name: "fileConfigMap",
|
||||
GeneratorArgs: types.GeneratorArgs{Name: "fileConfigMap"},
|
||||
DataSources: types.DataSources{
|
||||
FileSources: []string{"configmap/app-init.ini"},
|
||||
},
|
||||
@@ -114,7 +114,7 @@ func TestConstructConfigMap(t *testing.T) {
|
||||
{
|
||||
description: "construct config map from literal",
|
||||
input: types.ConfigMapArgs{
|
||||
Name: "literalConfigMap",
|
||||
GeneratorArgs: types.GeneratorArgs{Name: "literalConfigMap"},
|
||||
DataSources: types.DataSources{
|
||||
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.
|
||||
cm := &types.ConfigMapArgs{Name: name}
|
||||
cm := &types.ConfigMapArgs{GeneratorArgs: types.GeneratorArgs{Name: name}}
|
||||
m.ConfigMapGenerator = append(m.ConfigMapGenerator, *cm)
|
||||
return &m.ConfigMapGenerator[len(m.ConfigMapGenerator)-1]
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ func TestNewFromConfigMaps(t *testing.T) {
|
||||
description: "construct config map from env",
|
||||
input: []types.ConfigMapArgs{
|
||||
{
|
||||
Name: "envConfigMap",
|
||||
GeneratorArgs: types.GeneratorArgs{Name: "envConfigMap"},
|
||||
DataSources: types.DataSources{
|
||||
EnvSource: "app.env",
|
||||
},
|
||||
@@ -177,7 +177,7 @@ func TestNewFromConfigMaps(t *testing.T) {
|
||||
{
|
||||
description: "construct config map from file",
|
||||
input: []types.ConfigMapArgs{{
|
||||
Name: "fileConfigMap",
|
||||
GeneratorArgs: types.GeneratorArgs{Name: "fileConfigMap"},
|
||||
DataSources: types.DataSources{
|
||||
FileSources: []string{"app-init.ini"},
|
||||
},
|
||||
@@ -205,7 +205,7 @@ BAR=baz
|
||||
description: "construct config map from literal",
|
||||
input: []types.ConfigMapArgs{
|
||||
{
|
||||
Name: "literalConfigMap",
|
||||
GeneratorArgs: types.GeneratorArgs{Name: "literalConfigMap"},
|
||||
DataSources: types.DataSources{
|
||||
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) {
|
||||
secrets := []types.SecretArgs{
|
||||
{
|
||||
Name: "apple",
|
||||
GeneratorArgs: types.GeneratorArgs{Name: "apple"},
|
||||
CommandSources: types.CommandSources{
|
||||
Commands: map[string]string{
|
||||
"DB_USERNAME": "printf admin",
|
||||
@@ -261,7 +261,7 @@ func TestNewResMapFromSecretArgs(t *testing.T) {
|
||||
Type: ifc.SecretTypeOpaque,
|
||||
},
|
||||
{
|
||||
Name: "peanuts",
|
||||
GeneratorArgs: types.GeneratorArgs{Name: "peanuts"},
|
||||
CommandSources: types.CommandSources{
|
||||
EnvCommand: "printf \"DB_USERNAME=admin\nDB_PASSWORD=somepw\"",
|
||||
},
|
||||
@@ -314,7 +314,7 @@ func TestSecretTimeout(t *testing.T) {
|
||||
timeout := int64(1)
|
||||
secrets := []types.SecretArgs{
|
||||
{
|
||||
Name: "slow",
|
||||
GeneratorArgs: types.GeneratorArgs{Name: "slow"},
|
||||
TimeoutSeconds: &timeout,
|
||||
CommandSources: types.CommandSources{
|
||||
Commands: map[string]string{
|
||||
|
||||
@@ -146,21 +146,27 @@ func (k *Kustomization) DealWithDeprecatedFields() {
|
||||
}
|
||||
}
|
||||
|
||||
// ConfigMapArgs contains the metadata of how to generate a configmap.
|
||||
type ConfigMapArgs 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"`
|
||||
|
||||
// GeneratorArgs contains arguments common to generators.
|
||||
type GeneratorArgs struct {
|
||||
// Namespace for the configmap, optional
|
||||
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
|
||||
|
||||
// behavior of configmap, must be one of create, merge and replace
|
||||
// 'create': create a new one;
|
||||
// 'replace': replace the existing one;
|
||||
// 'merge': merge the existing one.
|
||||
// Name - actually the partial name - of the generated resource.
|
||||
// The full name ends up being something like
|
||||
// NamePrefix + this.Name + hash(content of generated resource).
|
||||
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"`
|
||||
}
|
||||
|
||||
// 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 `json:",inline,omitempty" yaml:",inline,omitempty"`
|
||||
@@ -168,19 +174,8 @@ type ConfigMapArgs struct {
|
||||
|
||||
// SecretArgs contains the metadata of how to generate a secret.
|
||||
type SecretArgs struct {
|
||||
// Name of the secret.
|
||||
// The full name should be Kustomization.NamePrefix + SecretGenerator.Name +
|
||||
// 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"`
|
||||
// GeneratorArgs for the secret.
|
||||
GeneratorArgs `json:",inline,omitempty" yaml:",inline,omitempty"`
|
||||
|
||||
// Type of the secret.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user