@@ -74,7 +74,7 @@ func NewFromConfig(environment interfaces.Environment, conf *clusterv1alpha1.Clu
7474 }
7575
7676 // setup instance pools
77- var result error
77+ var result * multierror. Error
7878 for pos , _ := range cluster .conf .InstancePools {
7979 instancePool := cluster .conf .InstancePools [pos ]
8080 // create instance pools
@@ -86,7 +86,7 @@ func NewFromConfig(environment interfaces.Environment, conf *clusterv1alpha1.Clu
8686 cluster .instancePools = append (cluster .instancePools , pool )
8787 }
8888
89- return cluster , result
89+ return cluster , result . ErrorOrNil ()
9090}
9191
9292func (c * Cluster ) InstancePools () []interfaces.InstancePool {
@@ -357,7 +357,7 @@ func (c *Cluster) verifyHubState() error {
357357}
358358
359359// Verify instance pools
360- func (c * Cluster ) VerifyInstancePools () ( result error ) {
360+ func (c * Cluster ) VerifyInstancePools () error {
361361 imageIDs , err := c .ImageIDs ()
362362 if err != nil {
363363 return fmt .Errorf ("error getting image IDs: %s]" , err )
@@ -370,6 +370,7 @@ func (c *Cluster) VerifyInstancePools() (result error) {
370370 return fmt .Errorf ("error getting the image ID of %s" , instancePool .TFName ())
371371 }
372372 }
373+
373374 return nil
374375}
375376
@@ -416,7 +417,7 @@ func (c *Cluster) Validate() error {
416417}
417418
418419// validate network configuration
419- func (c * Cluster ) validateNetwork () ( result error ) {
420+ func (c * Cluster ) validateNetwork () error {
420421 // make the choice between deploying into existing VPC or creating a new one
421422 if _ , ok := c .Config ().Network .ObjectMeta .Annotations [clusterv1alpha1 .ExistingVPCAnnotationKey ]; ok {
422423 // TODO: handle existing vpc
@@ -437,7 +438,7 @@ func (c *Cluster) validateNetwork() (result error) {
437438}
438439
439440// validate logging configuration
440- func (c * Cluster ) validateLoggingSinks () ( result error ) {
441+ func (c * Cluster ) validateLoggingSinks () error {
441442
442443 if c .Config ().LoggingSinks != nil {
443444 for index , loggingSink := range c .Config ().LoggingSinks {
@@ -459,7 +460,7 @@ func (c *Cluster) validateLoggingSinks() (result error) {
459460}
460461
461462// validate overprovisioning
462- func (c * Cluster ) validateClusterAutoscaler () ( result error ) {
463+ func (c * Cluster ) validateClusterAutoscaler () error {
463464
464465 if c .Config ().Kubernetes != nil && c .Config ().Kubernetes .ClusterAutoscaler != nil && c .Config ().Kubernetes .ClusterAutoscaler .Overprovisioning != nil {
465466 if ! c .Config ().Kubernetes .ClusterAutoscaler .Overprovisioning .Enabled {
@@ -490,20 +491,20 @@ func (c *Cluster) validateClusterAutoscaler() (result error) {
490491}
491492
492493// Validate APIServer
493- func (c * Cluster ) validateAPIServer () (result error ) {
494+ func (c * Cluster ) validateAPIServer () error {
495+ var result * multierror.Error
496+
494497 for _ , cidr := range c .Config ().Kubernetes .APIServer .AllowCIDRs {
495498 _ , _ , err := net .ParseCIDR (cidr )
496499 if err != nil {
497500 result = multierror .Append (result , fmt .Errorf ("%s is not a valid CIDR format" , cidr ))
498501 }
499502 }
500503
501- return result
504+ return result . ErrorOrNil ()
502505}
503506
504507func (c * Cluster ) validatePrometheusMode () error {
505- var result error
506-
507508 allowedModes := sets .NewString (
508509 clusterv1alpha1 .PrometheusModeFull ,
509510 clusterv1alpha1 .PrometheusModeExternalScrapeTargetsOnly ,
@@ -517,7 +518,7 @@ func (c *Cluster) validatePrometheusMode() error {
517518 }
518519 }
519520
520- return result
521+ return nil
521522}
522523
523524// Determine if this Cluster is a cluster or hub, single or multi environment
0 commit comments