@@ -15,18 +15,19 @@ import (
15
15
)
16
16
17
17
type Configuration struct {
18
- EnvRegex string `mapstructure:"env-regex"`
19
- RootDirectory string `mapstructure:"root-dir"`
20
- FileRegex string `mapstructure:"file-regex"`
21
- SecretName string `mapstructure:"secret-name"`
22
- SecretNamespace string `mapstructure:"secret-namespace"`
23
- EjsonKey []string `mapstructure:"ejson-key"`
24
- SkipDecrypt bool `mapstructure:"skip-decrypt"`
25
- MustDecrypt bool `mapstructure:"must-decrypt"`
26
- KubectlTimeout time.Duration `mapstructure:"kubectl-timeout"`
27
- Kubeconfig string `mapstructure:"kubeconfig"`
28
- KubeAPI string `mapstructure:"kube-api"`
29
- Output string `mapstructure:"output"`
18
+ EnvRegex string `mapstructure:"env-regex"`
19
+ RootDirectory string `mapstructure:"root-dir"`
20
+ FileRegex string `mapstructure:"file-regex"`
21
+ SecretName string `mapstructure:"secret-name"`
22
+ SecretNamespace string `mapstructure:"secret-namespace"`
23
+ EjsonKey []string `mapstructure:"ejson-key"`
24
+ SkipDecrypt bool `mapstructure:"skip-decrypt"`
25
+ MustDecrypt bool `mapstructure:"must-decrypt"`
26
+ KubectlTimeout time.Duration `mapstructure:"kubectl-timeout"`
27
+ Kubeconfig string `mapstructure:"kubeconfig"`
28
+ KubeAPI string `mapstructure:"kube-api"`
29
+ Output string `mapstructure:"output"`
30
+ ConvertSecretname bool `mapstructure:"convert-secret-name"`
30
31
}
31
32
32
33
var (
@@ -82,8 +83,17 @@ func LoadConfiguration(cfgFile string, cmd *cobra.Command, directory string) (*C
82
83
}
83
84
84
85
if cfg .SecretName != "" {
85
- regex := regexp .MustCompile (`[^a-zA-Z0-9]+` )
86
- cfg .SecretName = regex .ReplaceAllString (cfg .SecretName , "-" )
86
+ if cfg .ConvertSecretname {
87
+ cfg .SecretName = getValueAfterUnderscore (cfg .SecretName )
88
+
89
+ } else {
90
+ regex := regexp .MustCompile (`[^a-zA-Z0-9]+` )
91
+ cfg .SecretName = regex .ReplaceAllString (cfg .SecretName , "-" )
92
+ }
93
+ }
94
+
95
+ if cfg .SecretNamespace == "" {
96
+ cfg .SecretNamespace = os .Getenv ("ARGOCD_APP_NAMESPACE" )
87
97
}
88
98
89
99
if cfg .SecretName != "" && cfg .SecretNamespace == "" {
0 commit comments