@@ -90,9 +90,9 @@ func (o *ClientOptions) InstallFlags(flags *pflag.FlagSet) {
9090 KeyFile : filepath .Join (dockerCertPath , DefaultKeyFile ),
9191 }
9292 tlsOptions := o .TLSOptions
93- flags .Var (opts . NewQuotedString ( & tlsOptions .CAFile ) , "tlscacert" , "Trust certs signed only by this CA" )
94- flags .Var (opts . NewQuotedString ( & tlsOptions .CertFile ) , "tlscert" , "Path to TLS certificate file" )
95- flags .Var (opts . NewQuotedString ( & tlsOptions .KeyFile ) , "tlskey" , "Path to TLS key file" )
93+ flags .Var (& quotedString { & tlsOptions .CAFile } , "tlscacert" , "Trust certs signed only by this CA" )
94+ flags .Var (& quotedString { & tlsOptions .CertFile } , "tlscert" , "Path to TLS certificate file" )
95+ flags .Var (& quotedString { & tlsOptions .KeyFile } , "tlskey" , "Path to TLS key file" )
9696
9797 // opts.ValidateHost is not used here, so as to allow connection helpers
9898 hostOpt := opts .NewNamedListOptsRef ("hosts" , & o .Hosts , nil )
@@ -146,3 +146,33 @@ func SetLogLevel(logLevel string) {
146146 logrus .SetLevel (logrus .InfoLevel )
147147 }
148148}
149+
150+ type quotedString struct {
151+ value * string
152+ }
153+
154+ func (s * quotedString ) Set (val string ) error {
155+ * s .value = trimQuotes (val )
156+ return nil
157+ }
158+
159+ func (* quotedString ) Type () string {
160+ return "string"
161+ }
162+
163+ func (s * quotedString ) String () string {
164+ return * s .value
165+ }
166+
167+ func trimQuotes (value string ) string {
168+ if len (value ) < 2 {
169+ return value
170+ }
171+ lastIndex := len (value ) - 1
172+ for _ , char := range []byte {'\'' , '"' } {
173+ if value [0 ] == char && value [lastIndex ] == char {
174+ return value [1 :lastIndex ]
175+ }
176+ }
177+ return value
178+ }
0 commit comments