Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upup/pkg/fi/cloudup/ staticcheck: Fix ST1005 #8236

Merged
merged 1 commit into from
Dec 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions upup/pkg/fi/cloudup/awsup/aws_cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ func getTags(c AWSCloud, resourceID string) (map[string]string, error) {
if err != nil {
if isTagsEventualConsistencyError(err) {
if attempt > DescribeTagsMaxAttempts {
return nil, fmt.Errorf("Got retryable error while getting tags on %q, but retried too many times without success: %v", resourceID, err)
return nil, fmt.Errorf("got retryable error while getting tags on %q, but retried too many times without success: %v", resourceID, err)
}

if (attempt % DescribeTagsLogInterval) == 0 {
Expand Down Expand Up @@ -801,7 +801,7 @@ func createTags(c AWSCloud, resourceID string, tags map[string]string) error {
if err != nil {
if isTagsEventualConsistencyError(err) {
if attempt > CreateTagsMaxAttempts {
return fmt.Errorf("Got retryable error while creating tags on %q, but retried too many times without success: %v", resourceID, err)
return fmt.Errorf("got retryable error while creating tags on %q, but retried too many times without success: %v", resourceID, err)
}

if (attempt % CreateTagsLogInterval) == 0 {
Expand Down Expand Up @@ -849,7 +849,7 @@ func deleteTags(c AWSCloud, resourceID string, tags map[string]string) error {
if err != nil {
if isTagsEventualConsistencyError(err) {
if attempt > DeleteTagsMaxAttempts {
return fmt.Errorf("Got retryable error while deleting tags on %q, but retried too many times without success: %v", resourceID, err)
return fmt.Errorf("got retryable error while deleting tags on %q, but retried too many times without success: %v", resourceID, err)
}

if (attempt % DeleteTagsLogInterval) == 0 {
Expand Down Expand Up @@ -1237,7 +1237,7 @@ func ValidateZones(zones []string, cloud AWSCloud) error {
}

klog.Infof("Known zones: %q", strings.Join(knownZones, ","))
return fmt.Errorf("Zone is not a recognized AZ: %q (check you have specified a valid zone?)", zone)
return fmt.Errorf("error Zone is not a recognized AZ: %q (check you have specified a valid zone?)", zone)
}

for _, message := range z.Messages {
Expand All @@ -1255,7 +1255,7 @@ func ValidateZones(zones []string, cloud AWSCloud) error {
func (c *awsCloudImplementation) DNS() (dnsprovider.Interface, error) {
provider, err := dnsprovider.GetDnsProvider(dnsproviderroute53.ProviderName, nil)
if err != nil {
return nil, fmt.Errorf("Error building (k8s) DNS provider: %v", err)
return nil, fmt.Errorf("error building (k8s) DNS provider: %v", err)
}
return provider, nil
}
Expand Down
6 changes: 3 additions & 3 deletions upup/pkg/fi/cloudup/awsup/aws_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ func ValidateRegion(region string) error {

sess, err := session.NewSession(config)
if err != nil {
return fmt.Errorf("Error starting a new AWS session: %v", err)
return fmt.Errorf("error starting a new AWS session: %v", err)
}

client := ec2.New(sess, config)

response, err := client.DescribeRegions(request)
if err != nil {
return fmt.Errorf("Got an error while querying for valid regions (verify your AWS credentials?): %v", err)
return fmt.Errorf("got an error while querying for valid regions (verify your AWS credentials?): %v", err)
}
allRegions = response.Regions
}
Expand Down Expand Up @@ -114,7 +114,7 @@ func FindRegion(cluster *kops.Cluster) (string, error) {

zoneRegion := subnet.Zone[:len(subnet.Zone)-1]
if region != "" && zoneRegion != region {
return "", fmt.Errorf("Clusters cannot span multiple regions (found zone %q, but region is %q)", subnet.Zone, region)
return "", fmt.Errorf("error Clusters cannot span multiple regions (found zone %q, but region is %q)", subnet.Zone, region)
}

region = zoneRegion
Expand Down
2 changes: 1 addition & 1 deletion upup/pkg/fi/cloudup/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func PerformAssignments(c *kops.Cluster) error {
}
c.Spec.NetworkCIDR = vpcInfo.CIDR
if c.Spec.NetworkCIDR == "" {
return fmt.Errorf("Unable to infer NetworkCIDR from VPC ID, please specify --network-cidr")
return fmt.Errorf("unable to infer NetworkCIDR from VPC ID, please specify --network-cidr")
}
} else {
if cloud.ProviderID() == kops.CloudProviderAWS {
Expand Down
6 changes: 3 additions & 3 deletions upup/pkg/fi/cloudup/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func findZone(cluster *kops.Cluster, cloud fi.Cloud) (dnsprovider.Zone, error) {
}
}
if len(matches) == 0 {
return nil, fmt.Errorf("cannot find DNS Zone %q. Please pre-create the zone and set up NS records so that it resolves.", cluster.Spec.DNSZone)
return nil, fmt.Errorf("cannot find DNS Zone %q. Please pre-create the zone and set up NS records so that it resolves", cluster.Spec.DNSZone)
}

if len(matches) > 1 {
Expand Down Expand Up @@ -205,7 +205,7 @@ func precreateDNS(cluster *kops.Cluster, cloud fi.Cloud) error {
} else {
dnsRecords, err := rrs.Get(dnsHostname)
if err != nil {
return fmt.Errorf("Failed to get DNS record %s with error: %v", dnsHostname, err)
return fmt.Errorf("failed to get DNS record %s with error: %v", dnsHostname, err)
}
for _, dnsRecord := range dnsRecords {
if dnsRecord.Type() != "A" {
Expand Down Expand Up @@ -242,7 +242,7 @@ func precreateDNS(cluster *kops.Cluster, cloud fi.Cloud) error {
if len(created) != 0 {
err := changeset.Apply()
if err != nil {
return fmt.Errorf("Error pre-creating DNS records: %v", err)
return fmt.Errorf("error pre-creating DNS records: %v", err)
}
klog.V(2).Infof("Pre-created DNS names: %v", created)
}
Expand Down
4 changes: 2 additions & 2 deletions upup/pkg/fi/cloudup/gce/gce_cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func (c *gceCloudImplementation) ServiceAccount() (string, error) {
func (c *gceCloudImplementation) DNS() (dnsprovider.Interface, error) {
provider, err := clouddns.CreateInterface(c.project, nil)
if err != nil {
return nil, fmt.Errorf("Error building (k8s) DNS provider: %v", err)
return nil, fmt.Errorf("error building (k8s) DNS provider: %v", err)
}
return provider, nil
}
Expand Down Expand Up @@ -295,7 +295,7 @@ func (c *gceCloudImplementation) GetApiIngressStatus(cluster *kops.Cluster) ([]k

if forwardingRule != nil {
if forwardingRule.IPAddress == "" {
return nil, fmt.Errorf("Found forward rule %q, but it did not have an IPAddress", name)
return nil, fmt.Errorf("found forward rule %q, but it did not have an IPAddress", name)
}

ingresses = append(ingresses, kops.ApiIngressStatus{
Expand Down
2 changes: 1 addition & 1 deletion upup/pkg/fi/cloudup/gce/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func DecodeGCELabel(s string) (string, error) {
uriForm := strings.Replace(s, "-", "%", -1)
v, err := url.QueryUnescape(uriForm)
if err != nil {
return "", fmt.Errorf("Cannot decode GCE label: %q", s)
return "", fmt.Errorf("cannot decode GCE label: %q", s)
}
return v, nil
}
2 changes: 1 addition & 1 deletion upup/pkg/fi/cloudup/gcetasks/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (_ *Address) RenderGCE(t *gce.GCEAPITarget, a, e, changes *Address) error {
return fmt.Errorf("error waiting for IP Address: %v", err)
}
} else {
return fmt.Errorf("Cannot apply changes to IP Address: %v", changes)
return fmt.Errorf("cannot apply changes to IP Address: %v", changes)
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion upup/pkg/fi/cloudup/gcetasks/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (_ *Disk) RenderGCE(t *gce.GCEAPITarget, a, e, changes *Disk) error {
if a != nil && changes != nil {
empty := &Disk{}
if !reflect.DeepEqual(empty, changes) {
return fmt.Errorf("Cannot apply changes to Disk: %v", changes)
return fmt.Errorf("cannot apply changes to Disk: %v", changes)
}
}

Expand Down
2 changes: 1 addition & 1 deletion upup/pkg/fi/cloudup/gcetasks/forwardingrule.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (_ *ForwardingRule) RenderGCE(t *gce.GCEAPITarget, a, e, changes *Forwardin
}

} else {
return fmt.Errorf("Cannot apply changes to ForwardingRule: %v", changes)
return fmt.Errorf("cannot apply changes to ForwardingRule: %v", changes)
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion upup/pkg/fi/cloudup/gcetasks/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ func (_ *Instance) RenderGCE(t *gce.GCEAPITarget, a, e, changes *Instance) error

if !changes.isZero() {
klog.Errorf("Cannot apply changes to Instance: %v", changes)
return fmt.Errorf("Cannot apply changes to Instance: %v", changes)
return fmt.Errorf("cannot apply changes to Instance: %v", changes)
}
}

Expand Down
4 changes: 2 additions & 2 deletions upup/pkg/fi/cloudup/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ func (l *Loader) processDeferrals() error {
klog.Infof(" %s", k)
}

return fmt.Errorf("Unable to find task %q, referenced from %s:%s", typeNameForTask+"/"+*name, taskKey, path)
return fmt.Errorf("unable to find task %q, referenced from %s:%s", typeNameForTask+"/"+*name, taskKey, path)
}

klog.V(11).Infof("Replacing task %q at %s:%s", *name, taskKey, path)
Expand All @@ -317,7 +317,7 @@ func (l *Loader) processDeferrals() error {
for k := range l.Resources {
klog.Infof(" %s", k)
}
return fmt.Errorf("Unable to find resource %q, referenced from %s:%s", rh.Name, taskKey, path)
return fmt.Errorf("unable to find resource %q, referenced from %s:%s", rh.Name, taskKey, path)
}

err := l.populateResource(rh, resource, args)
Expand Down
6 changes: 3 additions & 3 deletions upup/pkg/fi/cloudup/openstack/availability_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ func (c *openstackCloud) ListAvailabilityZones(serviceClient *gophercloud.Servic
azPage, err := az.List(serviceClient).AllPages()

if err != nil {
return false, fmt.Errorf("Failed to list storage availability zones: %v", err)
return false, fmt.Errorf("failed to list storage availability zones: %v", err)
}
azList, err = az.ExtractAvailabilityZones(azPage)
if err != nil {
return false, fmt.Errorf("Failed to extract storage availability zones: %v", err)
return false, fmt.Errorf("failed to extract storage availability zones: %v", err)
}
return true, nil
})
Expand Down Expand Up @@ -65,5 +65,5 @@ func (c *openstackCloud) GetStorageAZFromCompute(computeAZ string) (*az.Availabi
if len(azList) == 1 {
return &azList[0], nil
}
return nil, fmt.Errorf("No decernable storage availability zone could be mapped to compute availability zone %s", computeAZ)
return nil, fmt.Errorf("no decernable storage availability zone could be mapped to compute availability zone %s", computeAZ)
}
12 changes: 6 additions & 6 deletions upup/pkg/fi/cloudup/openstack/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ func NewOpenstackCloud(tags map[string]string, spec *kops.ClusterSpec) (Openstac
Name: fi.StringValue(spec.CloudConfig.Openstack.Loadbalancer.FloatingNetwork),
})
if err != nil || len(lbNet) != 1 {
return c, fmt.Errorf("could not establish floating network id.")
return c, fmt.Errorf("could not establish floating network id")
}
spec.CloudConfig.Openstack.Loadbalancer.FloatingNetworkID = fi.String(lbNet[0].ID)
}
Expand Down Expand Up @@ -515,7 +515,7 @@ func (c *openstackCloud) ProviderID() kops.CloudProviderID {
func (c *openstackCloud) DNS() (dnsprovider.Interface, error) {
provider, err := dnsprovider.GetDnsProvider(designate.ProviderName, nil)
if err != nil {
return nil, fmt.Errorf("Error building (Designate) DNS provider: %v", err)
return nil, fmt.Errorf("error building (Designate) DNS provider: %v", err)
}
return provider, nil
}
Expand All @@ -526,7 +526,7 @@ func (c *openstackCloud) FindVPCInfo(id string) (*fi.VPCInfo, error) {
// Find subnets in the network
{
if len(c.zones) == 0 {
return nil, fmt.Errorf("Could not initialize zones")
return nil, fmt.Errorf("could not initialize zones")
}
klog.V(2).Infof("Calling ListSubnets for subnets in Network %q", id)
opt := subnets.ListOpts{
Expand Down Expand Up @@ -557,7 +557,7 @@ func (c *openstackCloud) DeleteGroup(g *cloudinstances.CloudInstanceGroup) error
for _, id := range grp.Members {
err := c.DeleteInstanceWithID(id)
if err != nil {
return fmt.Errorf("Could not delete instance %q: %v", id, err)
return fmt.Errorf("could not delete instance %q: %v", id, err)
}
}

Expand All @@ -570,14 +570,14 @@ func (c *openstackCloud) DeleteGroup(g *cloudinstances.CloudInstanceGroup) error
if strings.Contains(port.Name, grp.Name) {
err := c.DeletePort(port.ID)
if err != nil {
return fmt.Errorf("Could not delete port %q: %v", port.ID, err)
return fmt.Errorf("could not delete port %q: %v", port.ID, err)
}
}
}

err = c.DeleteServerGroup(grp.ID)
if err != nil {
return fmt.Errorf("Could not server group %q: %v", grp.ID, err)
return fmt.Errorf("could not server group %q: %v", grp.ID, err)
}

return nil
Expand Down
12 changes: 6 additions & 6 deletions upup/pkg/fi/cloudup/openstack/floatingip.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ func (c *openstackCloud) ListFloatingIPs() (fips []floatingips.FloatingIP, err e
done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) {
pages, err := floatingips.List(c.ComputeClient()).AllPages()
if err != nil {
return false, fmt.Errorf("Failed to list floating ip: %v", err)
return false, fmt.Errorf("failed to list floating ip: %v", err)
}
fips, err = floatingips.ExtractFloatingIPs(pages)
if err != nil {
return false, fmt.Errorf("Failed to extract floating ip: %v", err)
return false, fmt.Errorf("failed to extract floating ip: %v", err)
}
return true, nil
})
Expand All @@ -121,11 +121,11 @@ func (c *openstackCloud) ListL3FloatingIPs(opts l3floatingip.ListOpts) (fips []l
done, err := vfs.RetryWithBackoff(readBackoff, func() (bool, error) {
page, err := l3floatingip.List(c.NetworkingClient(), opts).AllPages()
if err != nil {
return false, fmt.Errorf("Failed to list L3 floating ip: %v", err)
return false, fmt.Errorf("failed to list L3 floating ip: %v", err)
}
fips, err = l3floatingip.ExtractFloatingIPs(page)
if err != nil {
return false, fmt.Errorf("Failed to extract L3 floating ip: %v", err)
return false, fmt.Errorf("failed to extract L3 floating ip: %v", err)
}
return true, nil
})
Expand All @@ -143,7 +143,7 @@ func (c *openstackCloud) DeleteFloatingIP(id string) (err error) {
done, err := vfs.RetryWithBackoff(writeBackoff, func() (bool, error) {
err = l3floatingip.Delete(c.ComputeClient(), id).ExtractErr()
if err != nil && !isNotFound(err) {
return false, fmt.Errorf("Failed to delete floating ip %s: %v", id, err)
return false, fmt.Errorf("failed to delete floating ip %s: %v", id, err)
}
return true, nil
})
Expand All @@ -158,7 +158,7 @@ func (c *openstackCloud) DeleteL3FloatingIP(id string) (err error) {
done, err := vfs.RetryWithBackoff(writeBackoff, func() (bool, error) {
err = l3floatingip.Delete(c.NetworkingClient(), id).ExtractErr()
if err != nil && !isNotFound(err) {
return false, fmt.Errorf("Failed to delete L3 floating ip %s: %v", id, err)
return false, fmt.Errorf("failed to delete L3 floating ip %s: %v", id, err)
}
return true, nil
})
Expand Down
4 changes: 2 additions & 2 deletions upup/pkg/fi/cloudup/openstack/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (c *openstackCloud) ListServerFloatingIPs(instanceID string) ([]*string, er
_, err := vfs.RetryWithBackoff(floatingBackoff, func() (bool, error) {
server, err := c.GetInstance(instanceID)
if err != nil {
return true, fmt.Errorf("Failed to find server with id (\"%s\"): %v", instanceID, err)
return true, fmt.Errorf("failed to find server with id (\"%s\"): %v", instanceID, err)
}

var addresses map[string][]Address
Expand All @@ -96,7 +96,7 @@ func (c *openstackCloud) ListServerFloatingIPs(instanceID string) ([]*string, er
return false, nil
})
if len(result) == 0 || err != nil {
return result, fmt.Errorf("Could not find floating ip associated to server (\"%s\") %v", instanceID, err)
return result, fmt.Errorf("could not find floating ip associated to server (\"%s\") %v", instanceID, err)
}
return result, nil
}
Expand Down
Loading