SetDefaultOptions sets default values for options after flag parsing is complete
(flags *pflag.FlagSet)
| 135 | // SetDefaultOptions sets default values for options after flag parsing is |
| 136 | // complete |
| 137 | func (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 |
| 168 | func SetLogLevel(logLevel string) { |
no outgoing calls
no test coverage detected