@@ -110,22 +110,20 @@ func (o *ClientOptions) InstallFlags(flags *pflag.FlagSet) {
110110 if dockerCertPath == "" {
111111 dockerCertPath = configDir
112112 }
113+ o .TLSOptions = & tlsconfig.Options {
114+ CAFile : filepath .Join (dockerCertPath , DefaultCaFile ),
115+ CertFile : filepath .Join (dockerCertPath , DefaultCertFile ),
116+ KeyFile : filepath .Join (dockerCertPath , DefaultKeyFile ),
117+ }
113118
114119 flags .StringVar (& o .ConfigDir , "config" , configDir , "Location of client config files" )
115120 flags .BoolVarP (& o .Debug , "debug" , "D" , false , "Enable debug mode" )
116121 flags .StringVarP (& o .LogLevel , "log-level" , "l" , "info" , `Set the logging level ("debug", "info", "warn", "error", "fatal")` )
117122 flags .BoolVar (& o .TLS , "tls" , dockerTLS , "Use TLS; implied by --tlsverify" )
118123 flags .BoolVar (& o .TLSVerify , FlagTLSVerify , dockerTLSVerify , "Use TLS and verify the remote" )
119-
120- o .TLSOptions = & tlsconfig.Options {
121- CAFile : filepath .Join (dockerCertPath , DefaultCaFile ),
122- CertFile : filepath .Join (dockerCertPath , DefaultCertFile ),
123- KeyFile : filepath .Join (dockerCertPath , DefaultKeyFile ),
124- }
125- tlsOptions := o .TLSOptions
126- flags .Var (& quotedString {& tlsOptions .CAFile }, "tlscacert" , "Trust certs signed only by this CA" )
127- flags .Var (& quotedString {& tlsOptions .CertFile }, "tlscert" , "Path to TLS certificate file" )
128- flags .Var (& quotedString {& tlsOptions .KeyFile }, "tlskey" , "Path to TLS key file" )
124+ flags .StringVar (& o .TLSOptions .CAFile , "tlscacert" , o .TLSOptions .CAFile , "Trust certs signed only by this CA" )
125+ flags .StringVar (& o .TLSOptions .CertFile , "tlscert" , o .TLSOptions .CertFile , "Path to TLS certificate file" )
126+ flags .StringVar (& o .TLSOptions .KeyFile , "tlskey" , o .TLSOptions .KeyFile , "Path to TLS key file" )
129127
130128 // TODO(thaJeztah): show the default host.
131129 // TODO(thaJeztah): this should be a string, not an "array" as we only allow a single host.
@@ -179,33 +177,3 @@ func SetLogLevel(logLevel string) {
179177 logrus .SetLevel (logrus .InfoLevel )
180178 }
181179}
182-
183- type quotedString struct {
184- value * string
185- }
186-
187- func (s * quotedString ) Set (val string ) error {
188- * s .value = trimQuotes (val )
189- return nil
190- }
191-
192- func (* quotedString ) Type () string {
193- return "string"
194- }
195-
196- func (s * quotedString ) String () string {
197- return * s .value
198- }
199-
200- func trimQuotes (value string ) string {
201- if len (value ) < 2 {
202- return value
203- }
204- lastIndex := len (value ) - 1
205- for _ , char := range []byte {'\'' , '"' } {
206- if value [0 ] == char && value [lastIndex ] == char {
207- return value [1 :lastIndex ]
208- }
209- }
210- return value
211- }
0 commit comments