@@ -40,10 +40,10 @@ type Options struct {
4040 Kubeconfig string
4141 // KubectlOverrides stores the extra client connection fields, such as context, user, etc.
4242 KubectlOverrides * clientcmd.ConfigOverrides
43- // Server is the kube-bind server name to use (overrides kube-bind config current server)
44- Server string
45- // Cluster is the kube-bind cluster name to use (overrides kube-bind config current cluster)
46- Cluster string
43+ // ServerName is the kube-bind server name to use (overrides kube-bind config current server)
44+ ServerName string
45+ // ClusterName is the kube-bind cluster name to use (overrides kube-bind config current cluster)
46+ ClusterName string
4747 // SkipInsecure skips TLS verification (for development)
4848 SkipInsecure bool
4949 // ConfigFile is the path to the kube-bind configuration file
@@ -87,8 +87,8 @@ func (o *Options) BindFlags(cmd *cobra.Command) {
8787 clientcmd .BindOverrideFlags (o .KubectlOverrides , cmd .PersistentFlags (), kubectlConfigOverrideFlags )
8888
8989 // Add common kube-bind flags
90- cmd .Flags ().StringVar (& o .Server , "server" , o .Server , "The kube-bind server name to use (overrides kube-bind config current server)" )
91- cmd .Flags ().StringVar (& o .Cluster , "cluster" , o .Cluster , "The kube-bind cluster name to use (overrides kube-bind config current cluster)" )
90+ cmd .Flags ().StringVar (& o .ServerName , "server" , o .ServerName , "The kube-bind server name to use (overrides kube-bind config current server)" )
91+ cmd .Flags ().StringVar (& o .ClusterName , "cluster" , o .ClusterName , "The kube-bind cluster name to use (overrides kube-bind config current cluster)" )
9292 cmd .Flags ().BoolVar (& o .SkipInsecure , "insecure-skip-tls-verify" , false , "Skip TLS certificate verification (not recommended)" )
9393 cmd .Flags ().StringVar (& o .ConfigFile , "config-file" , "" , "Path to the kube-bind configuration file" )
9494}
@@ -123,16 +123,16 @@ func (o *Options) Complete(skipValidate bool) error {
123123 }
124124
125125 switch {
126- case o .Server != "" && o .Cluster != "" :
126+ case o .ServerName != "" && o .ClusterName != "" :
127127 // Both server and cluster specified separately - do nothing
128- case o .Server != "" && strings .Contains (o .Server , "@" ):
128+ case o .ServerName != "" && strings .Contains (o .ServerName , "@" ):
129129 // Server specified in server@cluster format
130- parts := strings .SplitN (o .Server , "@" , 2 )
131- o .Server = parts [0 ]
132- o .Cluster = parts [1 ]
133- case o .Server != "" && o .Cluster == "" :
130+ parts := strings .SplitN (o .ServerName , "@" , 2 )
131+ o .ServerName = parts [0 ]
132+ o .ClusterName = parts [1 ]
133+ case o .ServerName != "" && o .ClusterName == "" :
134134 // Only server specified - do nothing. Cluster is empty
135- case o .Server == "" :
135+ case o .ServerName == "" :
136136 // No server specified - do nothing. Will be resolved from config
137137 }
138138
@@ -141,7 +141,7 @@ func (o *Options) Complete(skipValidate bool) error {
141141 // So if its empty here, we need to resolve it.
142142 var s * config.Server
143143 var c * config.Config
144- if o .Server == "" {
144+ if o .ServerName == "" {
145145 c , err = config .LoadConfigFromFile (o .ConfigFile )
146146 if err != nil {
147147 return fmt .Errorf ("failed to load config: %w" , err )
@@ -159,11 +159,11 @@ func (o *Options) Complete(skipValidate bool) error {
159159 }
160160
161161 var exists bool
162- s , exists = c .Get (o .Server , o .Cluster )
162+ s , exists = c .Get (o .ServerName , o .ClusterName )
163163 if ! exists && ! skipValidate {
164- err := fmt .Errorf ("server %q not found in config" , o .Server )
165- if o .Cluster != "" {
166- err = fmt .Errorf ("server %q with cluster %q not found in config" , o .Server , o .Cluster )
164+ err := fmt .Errorf ("server %q not found in config" , o .ServerName )
165+ if o .ClusterName != "" {
166+ err = fmt .Errorf ("server %q with cluster %q not found in config" , o .ServerName , o .ClusterName )
167167 }
168168 return err
169169 }
@@ -174,8 +174,8 @@ func (o *Options) Complete(skipValidate bool) error {
174174 }
175175
176176 if s != nil {
177- o .Server = s .URL
178- o .Cluster = s .Cluster
177+ o .ServerName = s .URL
178+ o .ClusterName = s .Cluster
179179 }
180180 o .server = s
181181 o .config = c
@@ -185,14 +185,14 @@ func (o *Options) Complete(skipValidate bool) error {
185185
186186// Validate validates the configured options.
187187func (o * Options ) Validate () error {
188- if o .Server != "" && strings .Contains (o .Server , "@" ) && o .Cluster != "" {
188+ if o .ServerName != "" && strings .Contains (o .ServerName , "@" ) && o .ClusterName != "" {
189189 return fmt .Errorf ("cannot specify both server in 'server@cluster' format and --cluster flag" )
190190 }
191191
192- if o .Cluster != "" && o .Server == "" {
192+ if o .ClusterName != "" && o .ServerName == "" {
193193 return fmt .Errorf ("cannot specify --cluster without --server" )
194194 }
195- if _ , err := url .Parse (o .Server ); err != nil {
195+ if _ , err := url .Parse (o .ServerName ); err != nil {
196196 return fmt .Errorf ("invalid server URL: %w" , err )
197197 }
198198
0 commit comments