@@ -165,12 +165,19 @@ func tokenFromCli(cmd *cobra.Command) (storage.Token, error) {
165165 nvc := cobrautil .MustGetBool (cmd , "no-verify-ca" )
166166 notVerifyCA = & nvc
167167 }
168+
169+ var hostnameOverride string
170+ if cmd .Flags ().Changed ("hostname-override" ) {
171+ hostnameOverride = cobrautil .MustGetString (cmd , "hostname-override" )
172+ }
173+
168174 overrideToken := storage.Token {
169- APIToken : cobrautil .MustGetString (cmd , "token" ),
170- Endpoint : cobrautil .MustGetString (cmd , "endpoint" ),
171- Insecure : notSecure ,
172- NoVerifyCA : notVerifyCA ,
173- CACert : certBytes ,
175+ APIToken : cobrautil .MustGetString (cmd , "token" ),
176+ Endpoint : cobrautil .MustGetString (cmd , "endpoint" ),
177+ Insecure : notSecure ,
178+ NoVerifyCA : notVerifyCA ,
179+ CACert : certBytes ,
180+ HostnameOverride : hostnameOverride ,
174181 }
175182 return overrideToken , nil
176183}
@@ -278,9 +285,8 @@ func DialOptsFromFlags(cmd *cobra.Command, token storage.Token) ([]grpc.DialOpti
278285 opts = append (opts , certOpt )
279286 }
280287
281- hostnameOverride := cobrautil .MustGetString (cmd , "hostname-override" )
282- if hostnameOverride != "" {
283- opts = append (opts , grpc .WithAuthority (hostnameOverride ))
288+ if token .HostnameOverride != "" {
289+ opts = append (opts , grpc .WithAuthority (token .HostnameOverride ))
284290 }
285291
286292 maxMessageSize := cobrautil .MustGetInt (cmd , "max-message-size" )
0 commit comments