diff --git a/dnsprovider/pkg/dnsprovider/providers/openstack/designate/rrchangeset.go b/dnsprovider/pkg/dnsprovider/providers/openstack/designate/rrchangeset.go index 96249793c1..f29574e874 100644 --- a/dnsprovider/pkg/dnsprovider/providers/openstack/designate/rrchangeset.go +++ b/dnsprovider/pkg/dnsprovider/providers/openstack/designate/rrchangeset.go @@ -56,11 +56,11 @@ func (c *ResourceRecordChangeset) Apply() error { for _, removal := range c.removals { rrID, err := c.nameToID(removal.Name()) if err != nil { - + return err } err = recordsets.Delete(c.zone.zones.iface.sc, zoneID, rrID).ExtractErr() if err != nil { - + return err } } @@ -73,14 +73,14 @@ func (c *ResourceRecordChangeset) Apply() error { } _, err := recordsets.Create(c.zone.zones.iface.sc, zoneID, opts).Extract() if err != nil { - + return err } } for _, upsert := range c.upserts { rrID, err := c.nameToID(upsert.Name()) if err != nil { - + return err } uopts := recordsets.UpdateOpts{ TTL: int(upsert.Ttl()), @@ -96,7 +96,7 @@ func (c *ResourceRecordChangeset) Apply() error { } _, err := recordsets.Create(c.zone.zones.iface.sc, zoneID, copts).Extract() if err != nil { - + return err } } } diff --git a/nodeup/pkg/model/context.go b/nodeup/pkg/model/context.go index a374e634b7..a11c6ca5b6 100644 --- a/nodeup/pkg/model/context.go +++ b/nodeup/pkg/model/context.go @@ -398,13 +398,13 @@ func (c *NodeupModelContext) UseSecureKubelet() bool { // @check if we have anything specific to master kubelet if c.IsMaster { - if cluster.MasterKubelet != nil && cluster.MasterKubelet.AnonymousAuth != nil && *cluster.MasterKubelet.AnonymousAuth == false { + if cluster.MasterKubelet != nil && cluster.MasterKubelet.AnonymousAuth != nil && !*cluster.MasterKubelet.AnonymousAuth { return true } } // @check the default settings for master and kubelet - if cluster.Kubelet != nil && cluster.Kubelet.AnonymousAuth != nil && *cluster.Kubelet.AnonymousAuth == false { + if cluster.Kubelet != nil && cluster.Kubelet.AnonymousAuth != nil && !*cluster.Kubelet.AnonymousAuth { return true } diff --git a/pkg/kubemanifest/visitor.go b/pkg/kubemanifest/visitor.go index 9d025037c6..25c6d1f2dd 100644 --- a/pkg/kubemanifest/visitor.go +++ b/pkg/kubemanifest/visitor.go @@ -48,9 +48,9 @@ type Visitor interface { } func visit(visitor Visitor, data interface{}, path []string, mutator func(interface{})) error { - switch data.(type) { + switch data := data.(type) { case string: - err := visitor.VisitString(path, data.(string), func(v string) { + err := visitor.VisitString(path, data, func(v string) { mutator(v) }) if err != nil { @@ -58,7 +58,7 @@ func visit(visitor Visitor, data interface{}, path []string, mutator func(interf } case bool: - err := visitor.VisitBool(path, data.(bool), func(v bool) { + err := visitor.VisitBool(path, data, func(v bool) { mutator(v) }) if err != nil { @@ -66,7 +66,7 @@ func visit(visitor Visitor, data interface{}, path []string, mutator func(interf } case float64: - err := visitor.VisitFloat64(path, data.(float64), func(v float64) { + err := visitor.VisitFloat64(path, data, func(v float64) { mutator(v) }) if err != nil { @@ -74,7 +74,7 @@ func visit(visitor Visitor, data interface{}, path []string, mutator func(interf } case map[string]interface{}: - m := data.(map[string]interface{}) + m := data for k, v := range m { path = append(path, k) @@ -88,7 +88,7 @@ func visit(visitor Visitor, data interface{}, path []string, mutator func(interf } case []interface{}: - s := data.([]interface{}) + s := data for i, v := range s { path = append(path, fmt.Sprintf("[%d]", i)) diff --git a/pkg/model/components/kubelet.go b/pkg/model/components/kubelet.go index abb0f1a19c..1d014c4988 100644 --- a/pkg/model/components/kubelet.go +++ b/pkg/model/components/kubelet.go @@ -69,7 +69,7 @@ func (b *KubeletOptionsBuilder) BuildOptions(o interface{}) error { if clusterSpec.Kubelet.AllowPrivileged != nil { // If it is explicitly set to false, return an error, because this // behavior is no longer supported in v1.14 (the default was true, prior). - if *clusterSpec.Kubelet.AllowPrivileged == false { + if !*clusterSpec.Kubelet.AllowPrivileged { klog.Warningf("Kubelet's --allow-privileged flag is no longer supported in v1.14.") } // Explicitly set it to nil, so it won't be passed on the command line. diff --git a/pkg/model/context.go b/pkg/model/context.go index 1667ca0905..efd85cc1d8 100644 --- a/pkg/model/context.go +++ b/pkg/model/context.go @@ -307,7 +307,7 @@ func (m *KopsModelContext) UseLoadBalancerForAPI() bool { // HA - see https://github.com/kubernetes/kops/issues/4252 func (m *KopsModelContext) UseLoadBalancerForInternalAPI() bool { return m.UseLoadBalancerForAPI() && - m.Cluster.Spec.API.LoadBalancer.UseForInternalApi == true + m.Cluster.Spec.API.LoadBalancer.UseForInternalApi } // UsePrivateDNS checks if we are using private DNS diff --git a/pkg/resources/aws/aws.go b/pkg/resources/aws/aws.go index 33673172d6..aaa0cb7637 100644 --- a/pkg/resources/aws/aws.go +++ b/pkg/resources/aws/aws.go @@ -230,7 +230,7 @@ func addUntaggedRouteTables(cloud awsup.AWSCloud, clusterName string, resources isMain := false for _, a := range rt.Associations { - if aws.BoolValue(a.Main) == true { + if aws.BoolValue(a.Main) { isMain = true } } diff --git a/protokube/pkg/protokube/etcd_manifest.go b/protokube/pkg/protokube/etcd_manifest.go index d38993a401..e93cd8baf0 100644 --- a/protokube/pkg/protokube/etcd_manifest.go +++ b/protokube/pkg/protokube/etcd_manifest.go @@ -244,7 +244,7 @@ func buildCertificateDirectories(c *EtcdCluster) []string { tracked := make(map[string]bool, 0) for _, x := range []string{c.TLSCA, c.TLSCert, c.TLSKey, c.PeerCA, c.PeerKey, c.PeerKey} { - if x == "" || tracked[filepath.Dir(x)] == true { + if x == "" || tracked[filepath.Dir(x)] { continue } tracked[filepath.Dir(x)] = true diff --git a/upup/pkg/fi/cloudup/gce/op.go b/upup/pkg/fi/cloudup/gce/op.go index 93248a3af9..49ecc0d68e 100644 --- a/upup/pkg/fi/cloudup/gce/op.go +++ b/upup/pkg/fi/cloudup/gce/op.go @@ -102,7 +102,7 @@ func waitForOp(op *compute.Operation, getOperation func(operationName string) (* return wait.Poll(operationPollInterval, operationPollTimeoutDuration, func() (bool, error) { start := time.Now() //gce.operationPollRateLimiter.Accept() - duration := time.Now().Sub(start) + duration := time.Since(start) if duration > 5*time.Second { klog.Infof("pollOperation: throttled %v for %v", duration, opName) } @@ -112,7 +112,7 @@ func waitForOp(op *compute.Operation, getOperation func(operationName string) (* } done := opIsDone(pollOp) if done { - duration := time.Now().Sub(opStart) + duration := time.Since(opStart) if duration > 1*time.Minute { // Log the JSON. It's cleaner than the %v structure. enc, err := pollOp.MarshalJSON() diff --git a/upup/pkg/fi/cloudup/spotinsttasks/elastigroup.go b/upup/pkg/fi/cloudup/spotinsttasks/elastigroup.go index 9bcf69a4ac..9cdd36a1c5 100644 --- a/upup/pkg/fi/cloudup/spotinsttasks/elastigroup.go +++ b/upup/pkg/fi/cloudup/spotinsttasks/elastigroup.go @@ -803,9 +803,7 @@ func (_ *Elastigroup) update(cloud awsup.AWSCloud, a, e, changes *Elastigroup) e } types := make([]string, len(e.SpotInstanceTypes)) - for i, typ := range e.SpotInstanceTypes { - types[i] = typ - } + copy(types, e.SpotInstanceTypes) group.Compute.InstanceTypes.SetSpot(types) changes.SpotInstanceTypes = nil diff --git a/upup/pkg/fi/cloudup/terraform/hcl_printer.go b/upup/pkg/fi/cloudup/terraform/hcl_printer.go index da18c2d9d0..4b177d6b5e 100644 --- a/upup/pkg/fi/cloudup/terraform/hcl_printer.go +++ b/upup/pkg/fi/cloudup/terraform/hcl_printer.go @@ -69,7 +69,7 @@ func (v *astSanitizer) visitObjectItem(o *ast.ObjectItem) { v := text[1 : len(text)-1] safe := true for _, c := range v { - if strings.IndexRune(safeChars, c) == -1 { + if !strings.ContainsRune(safeChars, c) { safe = false break } diff --git a/upup/pkg/fi/utils/sanitize.go b/upup/pkg/fi/utils/sanitize.go index b9c0c9a055..ed3b756c0d 100644 --- a/upup/pkg/fi/utils/sanitize.go +++ b/upup/pkg/fi/utils/sanitize.go @@ -28,14 +28,14 @@ func SanitizeString(s string) string { var out bytes.Buffer allowed := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-" for _, c := range s { - if strings.IndexRune(allowed, c) != -1 { + if strings.ContainsRune(allowed, c) { out.WriteRune(c) } else { out.WriteRune('_') } } - return string(out.Bytes()) + return out.String() } // ExpandPath replaces common path aliases: ~ -> $HOME