MCPcopy Index your code
hub / github.com/docker/cli / SetDefaultOptions

Method SetDefaultOptions

cli/flags/options.go:137–165  ·  view source on GitHub ↗

SetDefaultOptions sets default values for options after flag parsing is complete

(flags *pflag.FlagSet)

Source from the content-addressed store, hash-verified

135// SetDefaultOptions sets default values for options after flag parsing is
136// complete
137func (o *ClientOptions) SetDefaultOptions(flags *pflag.FlagSet) {
138 // Regardless of whether the user sets it to true or false, if they
139 // specify --tlsverify at all then we need to turn on TLS
140 // TLSVerify can be true even if not set due to DOCKER_TLS_VERIFY env var, so we need
141 // to check that here as well
142 if flags.Changed(FlagTLSVerify) || o.TLSVerify {
143 o.TLS = true
144 }
145
146 if !o.TLS {
147 o.TLSOptions = nil
148 } else {
149 tlsOptions := o.TLSOptions
150 tlsOptions.InsecureSkipVerify = !o.TLSVerify
151
152 // Reset CertFile and KeyFile to empty string if the user did not specify
153 // the respective flags and the respective default files were not found.
154 if !flags.Changed("tlscert") {
155 if _, err := os.Stat(tlsOptions.CertFile); os.IsNotExist(err) {
156 tlsOptions.CertFile = ""
157 }
158 }
159 if !flags.Changed("tlskey") {
160 if _, err := os.Stat(tlsOptions.KeyFile); os.IsNotExist(err) {
161 tlsOptions.KeyFile = ""
162 }
163 }
164 }
165}
166
167// SetLogLevel sets the logrus logging level
168func SetLogLevel(logLevel string) {

Callers 2

NewRootCmdFunction · 0.95
InitializeMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected