mirror of
https://github.com/openziti/ziti.git
synced 2026-10-12 15:28:05 +00:00
add create config environment --no-shell option to suppress shell variable declarations for generic env assignments usable with Docker Compose and systemd; fixed #1858
This commit is contained in:
@@ -2,5 +2,9 @@
|
||||
{{ $varDeclare := .OSVarDeclare }}
|
||||
{{- range .EnvVars}}
|
||||
{{ $commentPrefix }} {{ .Description }}
|
||||
{{- if $varDeclare }}
|
||||
{{ $varDeclare }} {{ .Name }}={{ .Value }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{ .Name }}={{ .Value }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
@@ -69,11 +69,18 @@ var environmentOptions *CreateConfigEnvironmentOptions
|
||||
type CreateConfigEnvironmentOptions struct {
|
||||
CreateConfigOptions
|
||||
EnvVariableTemplateData
|
||||
|
||||
DisableOSVarDeclare bool
|
||||
}
|
||||
|
||||
func (options *CreateConfigEnvironmentOptions) addFlags(cmd *cobra.Command) {
|
||||
cmd.Flags().BoolVar(&options.DisableOSVarDeclare, "no-shell", false, "Disable printing assignments prefixed with 'SET' (Windows) or 'export' (Unix)")
|
||||
}
|
||||
|
||||
// NewCmdCreateConfigEnvironment creates a command object for the "environment" command
|
||||
func NewCmdCreateConfigEnvironment() *cobra.Command {
|
||||
environmentOptions = &CreateConfigEnvironmentOptions{}
|
||||
|
||||
data := &ConfigTemplateValues{}
|
||||
|
||||
cmd := &cobra.Command{
|
||||
@@ -138,10 +145,14 @@ func NewCmdCreateConfigEnvironment() *cobra.Command {
|
||||
// Figure out the correct comment prefix and variable declaration command
|
||||
if runtime.GOOS == "windows" {
|
||||
environmentOptions.OSCommentPrefix = "rem"
|
||||
environmentOptions.OSVarDeclare = "SET"
|
||||
if ! environmentOptions.DisableOSVarDeclare {
|
||||
environmentOptions.OSVarDeclare = "SET"
|
||||
}
|
||||
} else {
|
||||
environmentOptions.OSCommentPrefix = "#"
|
||||
environmentOptions.OSVarDeclare = "export"
|
||||
if ! environmentOptions.DisableOSVarDeclare {
|
||||
environmentOptions.OSVarDeclare = "export"
|
||||
}
|
||||
}
|
||||
if environmentOptions.Verbose {
|
||||
logrus.SetLevel(logrus.DebugLevel)
|
||||
@@ -212,6 +223,7 @@ func NewCmdCreateConfigEnvironment() *cobra.Command {
|
||||
|
||||
cmd.Long = sb.String()
|
||||
|
||||
environmentOptions.addFlags(cmd)
|
||||
environmentOptions.addCreateFlags(cmd)
|
||||
|
||||
return cmd
|
||||
|
||||
Reference in New Issue
Block a user