@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
1414limitations under the License.
1515*/
1616
17+ // Package options contains implemention for SubcommandOptions.
1718package options
1819
1920import (
@@ -42,7 +43,7 @@ const (
4243 APIServerNameSuffix = "apiserver"
4344 CredentialSuffix = "credentials"
4445
45- apiserverAdvertiseAddressFlag = "api-server-advertise-address"
46+ APIServerAdvertiseAddressFlag = "api-server-advertise-address"
4647 APIServerServiceTypeFlag = "api-server-service-type"
4748 apiserverPortFlag = "api-server-port"
4849)
@@ -65,12 +66,12 @@ type SubcommandOptions struct {
6566 EtcdPVStorageClass string
6667 EtcdPersistentStorage bool
6768 DryRun bool
68- ApiServerOverridesString string
69- ApiServerOverrides map [string ]string
70- ApiServerServiceType v1.ServiceType
71- ApiServerAdvertiseAddress string
72- ApiServerNodePortPort int32
73- ApiServerNodePortPortPtr * int32
69+ APIServerOverridesString string
70+ APIServerOverrides map [string ]string
71+ APIServerServiceType v1.ServiceType
72+ APIServerAdvertiseAddress string
73+ APIServerNodePortPort int32
74+ APIServerNodePortPortPtr * int32
7475}
7576
7677// BindCommon adds the common options that are shared by different
@@ -95,11 +96,11 @@ func (o *SubcommandOptions) BindCommon(flags *pflag.FlagSet, defaultServerImage,
9596 "Use a persistent volume for etcd. Defaults to 'true'." )
9697 flags .BoolVar (& o .DryRun , "dry-run" , false ,
9798 "Run the command in dry-run mode, without making any server requests." )
98- flags .StringVar (& o .ApiServerOverridesString , "apiserver-arg-overrides" , "" ,
99+ flags .StringVar (& o .APIServerOverridesString , "apiserver-arg-overrides" , "" ,
99100 "Comma-separated list of cluster registry API server arguments to override, e.g., \" --arg1=value1,--arg2=value2...\" " )
100- flags .StringVar (& o .ApiServerAdvertiseAddress , apiserverAdvertiseAddressFlag , "" ,
101+ flags .StringVar (& o .APIServerAdvertiseAddress , APIServerAdvertiseAddressFlag , "" ,
101102 "Preferred address at which to advertise the cluster registry API server NodePort service. Valid only if '" + APIServerServiceTypeFlag + "=NodePort'." )
102- flags .Int32Var (& o .ApiServerNodePortPort , apiserverPortFlag , 0 ,
103+ flags .Int32Var (& o .APIServerNodePortPort , apiserverPortFlag , 0 ,
103104 "Preferred port to use for the cluster registry API server NodePort service. Set to 0 to randomly assign a port. Valid only if '" + APIServerServiceTypeFlag + "=NodePort'." )
104105}
105106
@@ -118,36 +119,36 @@ func (o *SubcommandOptions) ValidateCommonOptions() error {
118119 serverName = fmt .Sprintf ("%s-%s" , o .Name , APIServerNameSuffix )
119120 serverCredName = fmt .Sprintf ("%s-%s" , serverName , CredentialSuffix )
120121
121- if o .ApiServerServiceType != v1 .ServiceTypeLoadBalancer &&
122- o .ApiServerServiceType != v1 .ServiceTypeNodePort {
122+ if o .APIServerServiceType != v1 .ServiceTypeLoadBalancer &&
123+ o .APIServerServiceType != v1 .ServiceTypeNodePort {
123124 return fmt .Errorf ("invalid %s: %s, should be either %s or %s" ,
124- APIServerServiceTypeFlag , o .ApiServerServiceType ,
125+ APIServerServiceTypeFlag , o .APIServerServiceType ,
125126 v1 .ServiceTypeLoadBalancer , v1 .ServiceTypeNodePort )
126127 }
127128
128- if o .ApiServerAdvertiseAddress != "" {
129- ip := net .ParseIP (o .ApiServerAdvertiseAddress )
129+ if o .APIServerAdvertiseAddress != "" {
130+ ip := net .ParseIP (o .APIServerAdvertiseAddress )
130131 if ip == nil {
131132 return fmt .Errorf ("invalid %s: %s, should be a valid ip address" ,
132- apiserverAdvertiseAddressFlag , o .ApiServerAdvertiseAddress )
133+ APIServerAdvertiseAddressFlag , o .APIServerAdvertiseAddress )
133134 }
134- if o .ApiServerServiceType != v1 .ServiceTypeNodePort {
135+ if o .APIServerServiceType != v1 .ServiceTypeNodePort {
135136 return fmt .Errorf ("%s should be passed only with '%s=NodePort'" ,
136- apiserverAdvertiseAddressFlag , APIServerServiceTypeFlag )
137+ APIServerAdvertiseAddressFlag , APIServerServiceTypeFlag )
137138 }
138139 }
139140
140- if o .ApiServerNodePortPort != 0 {
141- if o .ApiServerServiceType != v1 .ServiceTypeNodePort {
141+ if o .APIServerNodePortPort != 0 {
142+ if o .APIServerServiceType != v1 .ServiceTypeNodePort {
142143 return fmt .Errorf ("%s should be passed only with '%s=NodePort'" ,
143144 apiserverPortFlag , APIServerServiceTypeFlag )
144145 }
145- o .ApiServerNodePortPortPtr = & o .ApiServerNodePortPort
146+ o .APIServerNodePortPortPtr = & o .APIServerNodePortPort
146147 } else {
147- o .ApiServerNodePortPortPtr = nil
148+ o .APIServerNodePortPortPtr = nil
148149 }
149150
150- if o .ApiServerNodePortPort < 0 || o .ApiServerNodePortPort > 65535 {
151+ if o .APIServerNodePortPort < 0 || o .APIServerNodePortPort > 65535 {
151152 return fmt .Errorf ("Please provide a valid port number for %s" , apiserverPortFlag )
152153 }
153154
@@ -156,12 +157,12 @@ func (o *SubcommandOptions) ValidateCommonOptions() error {
156157
157158// marshalOptions marshals options if necessary.
158159func (o * SubcommandOptions ) MarshalOptions () error {
159- if o .ApiServerOverridesString == "" {
160+ if o .APIServerOverridesString == "" {
160161 return nil
161162 }
162163
163164 argsMap := make (map [string ]string )
164- overrideArgs := strings .Split (o .ApiServerOverridesString , "," )
165+ overrideArgs := strings .Split (o .APIServerOverridesString , "," )
165166 for _ , overrideArg := range overrideArgs {
166167 splitArg := strings .SplitN (overrideArg , "=" , 2 )
167168 if len (splitArg ) != 2 {
@@ -175,7 +176,7 @@ func (o *SubcommandOptions) MarshalOptions() error {
175176 argsMap [key ] = val
176177 }
177178
178- o .ApiServerOverrides = argsMap
179+ o .APIServerOverrides = argsMap
179180
180181 return nil
181182}
@@ -208,8 +209,8 @@ func (o *SubcommandOptions) CreateService(cmdOut io.Writer,
208209 glog .V (4 ).Info ("Creating cluster registry API server service" )
209210
210211 svc , ips , hostnames , err := common .CreateService (cmdOut , clientset ,
211- o .ClusterRegistryNamespace , o .Name , o .ApiServerAdvertiseAddress ,
212- o .ApiServerNodePortPortPtr , o .ApiServerServiceType , o .DryRun )
212+ o .ClusterRegistryNamespace , o .Name , o .APIServerAdvertiseAddress ,
213+ o .APIServerNodePortPortPtr , o .APIServerServiceType , o .DryRun )
213214
214215 if err != nil {
215216 return nil , nil , nil , err
@@ -245,7 +246,7 @@ func (o *SubcommandOptions) GenerateCredentials(cmdOut io.Writer, svcName string
245246// CreateAPIServerCredentialsSecret creates the secret containing the
246247// apiserver credentials passed in.
247248func (o * SubcommandOptions ) CreateAPIServerCredentialsSecret (clientset client.Interface ,
248- credentials common.Credentials ) error {
249+ credentials * common.Credentials ) error {
249250
250251 _ , err := common .CreateAPIServerCredentialsSecret (clientset ,
251252 o .ClusterRegistryNamespace , serverCredName , credentials , o .DryRun )
@@ -285,8 +286,8 @@ func (o *SubcommandOptions) CreateAPIServer(cmdOut io.Writer, clientset client.I
285286 pvc * v1.PersistentVolumeClaim , serviceAccountName string ) error {
286287 // Since only one IP address can be specified as advertise address,
287288 // we arbitrarily pick the first available IP address.
288- // Pick user provided apiserverAdvertiseAddress over other available IP addresses.
289- advertiseAddress := o .ApiServerAdvertiseAddress
289+ // Pick user provided APIServerAdvertiseAddress over other available IP addresses.
290+ advertiseAddress := o .APIServerAdvertiseAddress
290291 if advertiseAddress == "" && len (ips ) > 0 {
291292 advertiseAddress = ips [0 ]
292293 }
@@ -297,7 +298,7 @@ func (o *SubcommandOptions) CreateAPIServer(cmdOut io.Writer, clientset client.I
297298 _ , err := common .CreateAPIServer (clientset , o .ClusterRegistryNamespace ,
298299 serverName , o .ServerImage , o .EtcdImage , advertiseAddress , serverCredName ,
299300 serviceAccountName , apiServerEnableHTTPBasicAuth , apiServerEnableTokenAuth ,
300- o .ApiServerOverrides , pvc , aggregated , o .DryRun )
301+ o .APIServerOverrides , pvc , aggregated , o .DryRun )
301302
302303 if err != nil {
303304 glog .V (4 ).Infof ("Failed to create API server: %v" , err )
@@ -331,7 +332,7 @@ func (o *SubcommandOptions) UpdateKubeconfig(cmdOut io.Writer,
331332
332333 // If the service is nodeport, need to append the port to endpoint as it is
333334 // non-standard port.
334- if o .ApiServerServiceType == v1 .ServiceTypeNodePort {
335+ if o .APIServerServiceType == v1 .ServiceTypeNodePort {
335336 endpoint = endpoint + ":" + strconv .Itoa (int (svc .Spec .Ports [0 ].NodePort ))
336337 }
337338
0 commit comments