From 37bdb3952e090e50f44207ad0e54b1f2a4ef1055 Mon Sep 17 00:00:00 2001 From: chentao1596 Date: Fri, 6 Jan 2017 16:12:25 +0800 Subject: [PATCH] fix all go style mistakes about fmt.Errorf --- controllers/gce/backends/backends.go | 2 +- controllers/gce/backends/fakes.go | 6 +++--- controllers/gce/controller/controller.go | 6 +++--- controllers/gce/controller/tls.go | 6 +++--- controllers/gce/controller/utils.go | 12 ++++++------ controllers/gce/firewalls/fakes.go | 6 +++--- controllers/gce/healthchecks/fakes.go | 6 +++--- controllers/gce/instances/fakes.go | 4 ++-- controllers/gce/loadbalancers/fakes.go | 14 +++++++------- controllers/gce/loadbalancers/loadbalancers.go | 16 ++++++++-------- controllers/gce/main.go | 2 +- controllers/gce/storage/configmaps.go | 6 +++--- controllers/gce/utils/utils.go | 4 ++-- controllers/nginx/pkg/cmd/controller/nginx.go | 2 +- controllers/nginx/pkg/metric/collector/status.go | 2 +- core/pkg/net/ssl/ssl.go | 14 +++++++------- hack/e2e.go | 2 +- 17 files changed, 55 insertions(+), 55 deletions(-) diff --git a/controllers/gce/backends/backends.go b/controllers/gce/backends/backends.go index 07f0b3fae..81edc32e3 100644 --- a/controllers/gce/backends/backends.go +++ b/controllers/gce/backends/backends.go @@ -119,7 +119,7 @@ func NewBackendPool( func(i interface{}) (string, error) { bs := i.(*compute.BackendService) if !namer.NameBelongsToCluster(bs.Name) { - return "", fmt.Errorf("Unrecognized name %v", bs.Name) + return "", fmt.Errorf("unrecognized name %v", bs.Name) } port, err := namer.BePort(bs.Name) if err != nil { diff --git a/controllers/gce/backends/fakes.go b/controllers/gce/backends/fakes.go index bb2b031f0..6ad7460f5 100644 --- a/controllers/gce/backends/fakes.go +++ b/controllers/gce/backends/fakes.go @@ -47,7 +47,7 @@ func (f *FakeBackendServices) GetBackendService(name string) (*compute.BackendSe f.calls = append(f.calls, utils.Get) obj, exists, err := f.backendServices.GetByKey(name) if !exists { - return nil, fmt.Errorf("Backend service %v not found", name) + return nil, fmt.Errorf("backend service %v not found", name) } if err != nil { return nil, err @@ -57,7 +57,7 @@ func (f *FakeBackendServices) GetBackendService(name string) (*compute.BackendSe if name == svc.Name { return svc, nil } - return nil, fmt.Errorf("Backend service %v not found", name) + return nil, fmt.Errorf("backend service %v not found", name) } // CreateBackendService fakes backend service creation. @@ -77,7 +77,7 @@ func (f *FakeBackendServices) DeleteBackendService(name string) error { f.calls = append(f.calls, utils.Delete) svc, exists, err := f.backendServices.GetByKey(name) if !exists { - return fmt.Errorf("Backend service %v not found", name) + return fmt.Errorf("backend service %v not found", name) } if err != nil { return err diff --git a/controllers/gce/controller/controller.go b/controllers/gce/controller/controller.go index 69f6a2533..3a039222b 100644 --- a/controllers/gce/controller/controller.go +++ b/controllers/gce/controller/controller.go @@ -290,7 +290,7 @@ func (lbc *LoadBalancerController) storesSynced() bool { func (lbc *LoadBalancerController) sync(key string) (err error) { if !lbc.hasSynced() { time.Sleep(storeSyncPollPeriod) - return fmt.Errorf("Waiting for stores to sync") + return fmt.Errorf("waiting for stores to sync") } glog.V(3).Infof("Syncing %v", key) @@ -326,7 +326,7 @@ func (lbc *LoadBalancerController) sync(key string) (err error) { defer func() { if deferErr := lbc.CloudClusterManager.GC(lbNames, nodePorts); deferErr != nil { - err = fmt.Errorf("Error during sync %v, error during GC %v", err, deferErr) + err = fmt.Errorf("error during sync %v, error during GC %v", err, deferErr) } glog.V(3).Infof("Finished syncing %v", key) }() @@ -343,7 +343,7 @@ func (lbc *LoadBalancerController) sync(key string) (err error) { if ingExists { lbc.recorder.Eventf(obj.(*extensions.Ingress), api.EventTypeWarning, eventMsg, err.Error()) } else { - err = fmt.Errorf("%v Error: %v", eventMsg, err) + err = fmt.Errorf("%v, error: %v", eventMsg, err) } syncError = err } diff --git a/controllers/gce/controller/tls.go b/controllers/gce/controller/tls.go index b8cb7a2e7..70bf7e00c 100644 --- a/controllers/gce/controller/tls.go +++ b/controllers/gce/controller/tls.go @@ -65,11 +65,11 @@ func (t *apiServerTLSLoader) load(ing *extensions.Ingress) (*loadbalancers.TLSCe } cert, ok := secret.Data[api.TLSCertKey] if !ok { - return nil, fmt.Errorf("Secret %v has no private key", secretName) + return nil, fmt.Errorf("secret %v has no private key", secretName) } key, ok := secret.Data[api.TLSPrivateKeyKey] if !ok { - return nil, fmt.Errorf("Secret %v has no cert", secretName) + return nil, fmt.Errorf("secret %v has no cert", secretName) } certs := &loadbalancers.TLSCerts{Key: string(key), Cert: string(cert)} if err := t.validate(certs); err != nil { @@ -95,5 +95,5 @@ func (f *fakeTLSSecretLoader) load(ing *extensions.Ingress) (*loadbalancers.TLSC return cert, nil } } - return nil, fmt.Errorf("Couldn't find secret for ingress %v", ing.Name) + return nil, fmt.Errorf("couldn't find secret for ingress %v", ing.Name) } diff --git a/controllers/gce/controller/utils.go b/controllers/gce/controller/utils.go index b57020cc3..7efc6cd56 100644 --- a/controllers/gce/controller/utils.go +++ b/controllers/gce/controller/utils.go @@ -233,7 +233,7 @@ func (s *StoreToIngressLister) GetServiceIngress(svc *api.Service) (ings []exten } } if len(ings) == 0 { - err = fmt.Errorf("No ingress for service %v", svc.Name) + err = fmt.Errorf("no ingress for service %v", svc.Name) } return } @@ -315,7 +315,7 @@ func (t *GCETranslator) toGCEBackend(be *extensions.IngressBackend, ns string) ( backend, err := t.CloudClusterManager.backendPool.Get(int64(port)) if err != nil { return nil, fmt.Errorf( - "No GCE backend exists for port %v, kube backend %+v", port, be) + "no GCE backend exists for port %v, kube backend %+v", port, be) } return backend, nil } @@ -332,7 +332,7 @@ func (t *GCETranslator) getServiceNodePort(be extensions.IngressBackend, namespa }) if !exists { return invalidPort, errorNodePortNotFound{be, fmt.Errorf( - "Service %v/%v not found in store", namespace, be.ServiceName)} + "service %v/%v not found in store", namespace, be.ServiceName)} } if err != nil { return invalidPort, errorNodePortNotFound{be, err} @@ -356,7 +356,7 @@ func (t *GCETranslator) getServiceNodePort(be extensions.IngressBackend, namespa return nodePort, nil } return invalidPort, errorNodePortNotFound{be, fmt.Errorf( - "Could not find matching nodeport from service.")} + "could not find matching nodeport from service")} } // toNodePorts converts a pathlist to a flat list of nodeports. @@ -374,7 +374,7 @@ func (t *GCETranslator) toNodePorts(ings *extensions.IngressList) []int64 { } for _, rule := range ing.Spec.Rules { if rule.HTTP == nil { - glog.Errorf("Ignoring non http Ingress rule.") + glog.Errorf("ignoring non http Ingress rule") continue } for _, path := range rule.HTTP.Paths { @@ -411,7 +411,7 @@ func (t *GCETranslator) GetZoneForNode(name string) (string, error) { return getZone(n), nil } } - return "", fmt.Errorf("Node not found %v", name) + return "", fmt.Errorf("node not found %v", name) } // ListZones returns a list of zones this Kubernetes cluster spans. diff --git a/controllers/gce/firewalls/fakes.go b/controllers/gce/firewalls/fakes.go index 3479d83d1..71c90c321 100644 --- a/controllers/gce/firewalls/fakes.go +++ b/controllers/gce/firewalls/fakes.go @@ -35,7 +35,7 @@ func (f *fakeFirewallRules) GetFirewall(name string) (*compute.Firewall, error) return rule, nil } } - return nil, fmt.Errorf("Firewall rule %v not found.", name) + return nil, fmt.Errorf("firewall rule %v not found", name) } func (f *fakeFirewallRules) CreateFirewall(name, msgTag string, srcRange netset.IPNet, ports []int64, hosts []string) error { @@ -66,7 +66,7 @@ func (f *fakeFirewallRules) DeleteFirewall(name string) error { firewalls = append(firewalls, rule) } if !exists { - return fmt.Errorf("Failed to find health check %v", name) + return fmt.Errorf("failed to find health check %v", name) } f.fw = firewalls return nil @@ -95,7 +95,7 @@ func (f *fakeFirewallRules) UpdateFirewall(name, msgTag string, srcRange netset. if exists { return nil } - return fmt.Errorf("Update failed for rule %v, srcRange %v ports %v, rule not found", name, srcRange, ports) + return fmt.Errorf("update failed for rule %v, srcRange %v ports %v, rule not found", name, srcRange, ports) } // NewFakeFirewallRules creates a fake for firewall rules. diff --git a/controllers/gce/healthchecks/fakes.go b/controllers/gce/healthchecks/fakes.go index 900b73023..18984d122 100644 --- a/controllers/gce/healthchecks/fakes.go +++ b/controllers/gce/healthchecks/fakes.go @@ -60,7 +60,7 @@ func (f *FakeHealthChecks) GetHttpHealthCheck(name string) (*compute.HttpHealthC return h, nil } } - return nil, fmt.Errorf("Health check %v not found.", name) + return nil, fmt.Errorf("health check %v not found", name) } // DeleteHttpHealthCheck fakes out deleting a http health check. @@ -75,7 +75,7 @@ func (f *FakeHealthChecks) DeleteHttpHealthCheck(name string) error { healthChecks = append(healthChecks, h) } if !exists { - return fmt.Errorf("Failed to find health check %v", name) + return fmt.Errorf("failed to find health check %v", name) } f.hc = healthChecks return nil @@ -94,7 +94,7 @@ func (f *FakeHealthChecks) UpdateHttpHealthCheck(hc *compute.HttpHealthCheck) er } } if !found { - return fmt.Errorf("Cannot update a non-existent health check %v", hc.Name) + return fmt.Errorf("cannot update a non-existent health check %v", hc.Name) } f.hc = healthChecks return nil diff --git a/controllers/gce/instances/fakes.go b/controllers/gce/instances/fakes.go index 94e22ced9..df2ee26fa 100644 --- a/controllers/gce/instances/fakes.go +++ b/controllers/gce/instances/fakes.go @@ -75,7 +75,7 @@ func (f *FakeInstanceGroups) GetInstanceGroup(name, zone string) (*compute.Insta } } // TODO: Return googleapi 404 error - return nil, fmt.Errorf("Instance group %v not found", name) + return nil, fmt.Errorf("instance group %v not found", name) } // CreateInstanceGroup fakes instance group creation. @@ -97,7 +97,7 @@ func (f *FakeInstanceGroups) DeleteInstanceGroup(name, zone string) error { newGroups = append(newGroups, ig) } if !found { - return fmt.Errorf("Instance Group %v not found", name) + return fmt.Errorf("instance group %v not found", name) } f.instanceGroups = newGroups return nil diff --git a/controllers/gce/loadbalancers/fakes.go b/controllers/gce/loadbalancers/fakes.go index b167a9ae1..6dfdcd941 100644 --- a/controllers/gce/loadbalancers/fakes.go +++ b/controllers/gce/loadbalancers/fakes.go @@ -109,7 +109,7 @@ func (f *FakeLoadBalancers) GetGlobalForwardingRule(name string) (*compute.Forwa return f.Fw[i], nil } } - return nil, fmt.Errorf("Forwarding rule %v not found", name) + return nil, fmt.Errorf("forwarding rule %v not found", name) } // CreateGlobalForwardingRule fakes forwarding rule creation. @@ -176,7 +176,7 @@ func (f *FakeLoadBalancers) GetUrlMap(name string) (*compute.UrlMap, error) { return f.Um[i], nil } } - return nil, fmt.Errorf("Url Map %v not found", name) + return nil, fmt.Errorf("url map %v not found", name) } // CreateUrlMap fakes url-map creation. @@ -226,7 +226,7 @@ func (f *FakeLoadBalancers) GetTargetHttpProxy(name string) (*compute.TargetHttp return f.Tp[i], nil } } - return nil, fmt.Errorf("Targetproxy %v not found", name) + return nil, fmt.Errorf("target http proxy %v not found", name) } // CreateTargetHttpProxy fakes creating a target http proxy. @@ -275,7 +275,7 @@ func (f *FakeLoadBalancers) GetTargetHttpsProxy(name string) (*compute.TargetHtt return f.Tps[i], nil } } - return nil, fmt.Errorf("Targetproxy %v not found", name) + return nil, fmt.Errorf("target https proxy %v not found", name) } // CreateTargetHttpsProxy fakes creating a target http proxy. @@ -326,7 +326,7 @@ func (f *FakeLoadBalancers) SetSslCertificateForTargetHttpsProxy(proxy *compute. } } if !found { - return fmt.Errorf("Failed to find proxy %v", proxy.Name) + return fmt.Errorf("failed to find proxy %v", proxy.Name) } return nil } @@ -415,7 +415,7 @@ func (f *FakeLoadBalancers) GetGlobalStaticIP(name string) (*compute.Address, er return f.IP[i], nil } } - return nil, fmt.Errorf("Static IP %v not found", name) + return nil, fmt.Errorf("static IP %v not found", name) } // DeleteGlobalStaticIP fakes out static IP deletion. @@ -441,7 +441,7 @@ func (f *FakeLoadBalancers) GetSslCertificate(name string) (*compute.SslCertific return f.Certs[i], nil } } - return nil, fmt.Errorf("Cert %v not found", name) + return nil, fmt.Errorf("cert %v not found", name) } // CreateSslCertificate fakes out certificate creation. diff --git a/controllers/gce/loadbalancers/loadbalancers.go b/controllers/gce/loadbalancers/loadbalancers.go index 9688a4cc0..7e04fb2b0 100644 --- a/controllers/gce/loadbalancers/loadbalancers.go +++ b/controllers/gce/loadbalancers/loadbalancers.go @@ -106,7 +106,7 @@ func (l *L7s) Get(name string) (*L7, error) { name = l.namer.LBName(name) lb, exists := l.snapshotter.Get(name) if !exists { - return nil, fmt.Errorf("Loadbalancer %v not in pool", name) + return nil, fmt.Errorf("loadbalancer %v not in pool", name) } return lb.(*L7), nil } @@ -292,7 +292,7 @@ type L7 struct { func (l *L7) checkUrlMap(backend *compute.BackendService) (err error) { if l.glbcDefaultBackend == nil { - return fmt.Errorf("Cannot create urlmap without default backend.") + return fmt.Errorf("cannot create urlmap without default backend") } urlMapName := l.namer.Truncate(fmt.Sprintf("%v-%v", urlMapPrefix, l.Name)) urlMap, _ := l.cloud.GetUrlMap(urlMapName) @@ -313,7 +313,7 @@ func (l *L7) checkUrlMap(backend *compute.BackendService) (err error) { func (l *L7) checkProxy() (err error) { if l.um == nil { - return fmt.Errorf("Cannot create proxy without urlmap.") + return fmt.Errorf("cannot create proxy without urlmap") } proxyName := l.namer.Truncate(fmt.Sprintf("%v-%v", targetProxyPrefix, l.Name)) proxy, _ := l.cloud.GetTargetHttpProxy(proxyName) @@ -362,7 +362,7 @@ func (l *L7) checkSSLCert() (err error) { return err } if cert == nil { - return fmt.Errorf("Cannot find existing sslCertificate %v for %v", certName, l.Name) + return fmt.Errorf("cannot find existing sslCertificate %v for %v", certName, l.Name) } glog.Infof("Using existing sslCertificate %v for %v", certName, l.Name) @@ -429,7 +429,7 @@ func (l *L7) checkHttpsProxy() (err error) { return nil } if l.um == nil { - return fmt.Errorf("No UrlMap for %v, will not create HTTPS proxy.", l.Name) + return fmt.Errorf("no UrlMap for %v, will not create HTTPS proxy", l.Name) } proxyName := l.namer.Truncate(fmt.Sprintf("%v-%v", targetHTTPSProxyPrefix, l.Name)) proxy, _ := l.cloud.GetTargetHttpsProxy(proxyName) @@ -535,7 +535,7 @@ func (l *L7) getEffectiveIP() (string, bool) { func (l *L7) checkHttpForwardingRule() (err error) { if l.tp == nil { - return fmt.Errorf("Cannot create forwarding rule without proxy.") + return fmt.Errorf("cannot create forwarding rule without proxy") } name := l.namer.Truncate(fmt.Sprintf("%v-%v", forwardingRulePrefix, l.Name)) address, _ := l.getEffectiveIP() @@ -565,7 +565,7 @@ func (l *L7) checkHttpsForwardingRule() (err error) { // checkStaticIP reserves a static IP allocated to the Forwarding Rule. func (l *L7) checkStaticIP() (err error) { if l.fw == nil || l.fw.IPAddress == "" { - return fmt.Errorf("Will not create static IP without a forwarding rule.") + return fmt.Errorf("will not create static IP without a forwarding rule") } // Don't manage staticIPs if the user has specified an IP. if address, manageStaticIP := l.getEffectiveIP(); !manageStaticIP { @@ -704,7 +704,7 @@ func getNameForPathMatcher(hostRule string) string { // pathmatcher of the host. func (l *L7) UpdateUrlMap(ingressRules utils.GCEURLMap) error { if l.um == nil { - return fmt.Errorf("Cannot add url without an urlmap.") + return fmt.Errorf("cannot add url without an urlmap") } glog.V(3).Infof("Updating urlmap for l7 %v", l.Name) diff --git a/controllers/gce/main.go b/controllers/gce/main.go index b8afbf9ab..a306956a2 100644 --- a/controllers/gce/main.go +++ b/controllers/gce/main.go @@ -316,7 +316,7 @@ func useDefaultOrLookupVault(cfgVault *storage.ConfigMapVault, cm_key, default_n // 2. No such key in config map - found=false, err=nil // 3. Apiserver flake - found=false, err!=nil // It is not safe to proceed in 3. - return "", fmt.Errorf("Failed to retrieve %v: %v, returning empty name", cm_key, err) + return "", fmt.Errorf("failed to retrieve %v: %v, returning empty name", cm_key, err) } else if !found { // Not found but safe to proceed. return "", nil diff --git a/controllers/gce/storage/configmaps.go b/controllers/gce/storage/configmaps.go index 6af08b65d..ace030b9f 100644 --- a/controllers/gce/storage/configmaps.go +++ b/controllers/gce/storage/configmaps.go @@ -95,12 +95,12 @@ func (c *ConfigMapVault) Put(key, val string) error { glog.Infof("Configmap %v will be updated with %v = %v", cfgMapKey, key, val) } if err := c.ConfigMapStore.Update(apiObj); err != nil { - return fmt.Errorf("Failed to update %v: %v", cfgMapKey, err) + return fmt.Errorf("failed to update %v: %v", cfgMapKey, err) } } else { apiObj.Data = map[string]string{key: val} if err := c.ConfigMapStore.Add(apiObj); err != nil { - return fmt.Errorf("Failed to add %v: %v", cfgMapKey, err) + return fmt.Errorf("failed to add %v: %v", cfgMapKey, err) } } glog.Infof("Successfully stored key %v = %v in config map %v", key, val, cfgMapKey) @@ -176,7 +176,7 @@ func (a *APIServerConfigMapStore) Delete(obj interface{}) error { func (a *APIServerConfigMapStore) GetByKey(key string) (item interface{}, exists bool, err error) { nsName := strings.Split(key, "/") if len(nsName) != 2 { - return nil, false, fmt.Errorf("Failed to get key %v, unexpecte format, expecting ns/name", key) + return nil, false, fmt.Errorf("failed to get key %v, unexpecte format, expecting ns/name", key) } ns, name := nsName[0], nsName[1] cfg, err := a.client.Core().ConfigMaps(ns).Get(name) diff --git a/controllers/gce/utils/utils.go b/controllers/gce/utils/utils.go index 9d5dbfad1..1ed36769f 100644 --- a/controllers/gce/utils/utils.go +++ b/controllers/gce/utils/utils.go @@ -223,11 +223,11 @@ func (n *Namer) BePort(beName string) (string, error) { } match := r.FindStringSubmatch(beName) if len(match) < 2 { - return "", fmt.Errorf("Unable to lookup port for %v", beName) + return "", fmt.Errorf("unable to lookup port for %v", beName) } _, err = strconv.Atoi(match[1]) if err != nil { - return "", fmt.Errorf("Unexpected regex match: %v", beName) + return "", fmt.Errorf("unexpected regex match: %v", beName) } return match[1], nil } diff --git a/controllers/nginx/pkg/cmd/controller/nginx.go b/controllers/nginx/pkg/cmd/controller/nginx.go index 1bd7ede60..8e6873c50 100644 --- a/controllers/nginx/pkg/cmd/controller/nginx.go +++ b/controllers/nginx/pkg/cmd/controller/nginx.go @@ -441,7 +441,7 @@ func (n NGINXController) Check(_ *http.Request) error { } defer res.Body.Close() if res.StatusCode != 200 { - return fmt.Errorf("Ingress controller is not healthy") + return fmt.Errorf("ingress controller is not healthy") } return nil } diff --git a/controllers/nginx/pkg/metric/collector/status.go b/controllers/nginx/pkg/metric/collector/status.go index 1a0fcaf0e..361838a31 100644 --- a/controllers/nginx/pkg/metric/collector/status.go +++ b/controllers/nginx/pkg/metric/collector/status.go @@ -138,7 +138,7 @@ func (bit BoolToFloat64) UnmarshalJSON(data []byte) error { } else if asString == "0" || asString == "false" { bit = 0 } else { - return fmt.Errorf(fmt.Sprintf("Boolean unmarshal error: invalid input %s", asString)) + return fmt.Errorf(fmt.Sprintf("boolean unmarshal error: invalid input %s", asString)) } return nil } diff --git a/core/pkg/net/ssl/ssl.go b/core/pkg/net/ssl/ssl.go index c758423fc..70ed50434 100644 --- a/core/pkg/net/ssl/ssl.go +++ b/core/pkg/net/ssl/ssl.go @@ -75,13 +75,13 @@ func AddOrUpdateCertAndKey(name string, cert, key, ca []byte) (*ingress.SSLCert, pemBlock, _ := pem.Decode(pemCerts) if pemBlock == nil { _ = os.Remove(tempPemFile.Name()) - return nil, fmt.Errorf("No valid PEM formatted block found") + return nil, fmt.Errorf("no valid PEM formatted block found") } // If the file does not start with 'BEGIN CERTIFICATE' it's invalid and must not be used. if pemBlock.Type != "CERTIFICATE" { _ = os.Remove(tempPemFile.Name()) - return nil, fmt.Errorf("Certificate %v contains invalid data, and must be created with 'kubectl create secret tls'", name) + return nil, fmt.Errorf("certificate %v contains invalid data, and must be created with 'kubectl create secret tls'", name) } pemCert, err := x509.ParseCertificate(pemBlock.Bytes) @@ -115,7 +115,7 @@ func AddOrUpdateCertAndKey(name string, cert, key, ca []byte) (*ingress.SSLCert, caFile, err := os.OpenFile(pemFileName, os.O_RDWR|os.O_APPEND, 0600) if err != nil { - return nil, fmt.Errorf("Could not open file %v for writing additional CA chains: %v", pemFileName, err) + return nil, fmt.Errorf("could not open file %v for writing additional CA chains: %v", pemFileName, err) } defer caFile.Close() @@ -150,11 +150,11 @@ func AddCertAuth(name string, ca []byte) (*ingress.SSLCert, error) { pemCABlock, _ := pem.Decode(ca) if pemCABlock == nil { - return nil, fmt.Errorf("No valid PEM formatted block found") + return nil, fmt.Errorf("no valid PEM formatted block found") } // If the first certificate does not start with 'BEGIN CERTIFICATE' it's invalid and must not be used. if pemCABlock.Type != "CERTIFICATE" { - return nil, fmt.Errorf("CA File %v contains invalid data, and must be created only with PEM formated certificates", name) + return nil, fmt.Errorf("CA file %v contains invalid data, and must be created only with PEM formated certificates", name) } _, err := x509.ParseCertificate(pemCABlock.Bytes) @@ -206,13 +206,13 @@ func AddOrUpdateDHParam(name string, dh []byte) (string, error) { pemBlock, _ := pem.Decode(pemCerts) if pemBlock == nil { _ = os.Remove(tempPemFile.Name()) - return "", fmt.Errorf("No valid PEM formatted block found") + return "", fmt.Errorf("no valid PEM formatted block found") } // If the file does not start with 'BEGIN DH PARAMETERS' it's invalid and must not be used. if pemBlock.Type != "DH PARAMETERS" { _ = os.Remove(tempPemFile.Name()) - return "", fmt.Errorf("Certificate %v contains invalid data", name) + return "", fmt.Errorf("certificate %v contains invalid data", name) } err = os.Rename(tempPemFile.Name(), pemFileName) diff --git a/hack/e2e.go b/hack/e2e.go index 65dc71cd1..be9f2aa28 100644 --- a/hack/e2e.go +++ b/hack/e2e.go @@ -234,7 +234,7 @@ func getDeployer() (deployer, error) { case "bash": return bash{}, nil default: - return nil, fmt.Errorf("Unknown deployment strategy %q", *deployment) + return nil, fmt.Errorf("unknown deployment strategy %q", *deployment) } }