Skip to content

Commit 5f0fb8e

Browse files
committed
Fix typos identified by go vet in internal package
Tests pass when running `go test ./internal/...` with Go 1.13, but it emits warnings and exits non-zero. The `./internal/operator` package fails to build on Go 1.14 because the `%w` verb is not allowed in formatted log messages. `go test ./internal/... ./pkg/...` now exits zero in both Go 1.13 and 1.14. See: 63ed759
1 parent 1b933cb commit 5f0fb8e

File tree

13 files changed

+22
-22
lines changed

13 files changed

+22
-22
lines changed

internal/apiserver/clusterservice/clusterimpl.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ func getServices(cluster *crv1.Pgcluster, ns string) ([]msgs.ShowClusterService,
339339
func TestCluster(name, selector, ns, pgouser string, allFlag bool) msgs.ClusterTestResponse {
340340
var err error
341341

342-
log.Debugf("TestCluster(%s,%s,%s,%s,%s): Called",
342+
log.Debugf("TestCluster(%s,%s,%s,%s,%v): Called",
343343
name, selector, ns, pgouser, allFlag)
344344

345345
response := msgs.ClusterTestResponse{}
@@ -355,7 +355,7 @@ func TestCluster(name, selector, ns, pgouser string, allFlag bool) msgs.ClusterT
355355
// be used
356356
if selector == "" {
357357
if allFlag {
358-
log.Debug("selector is : all clusters in %s", ns)
358+
log.Debugf("selector is : all clusters in %s", ns)
359359
} else {
360360
selector = "name=" + name
361361
log.Debugf("selector is: %s", selector)
@@ -446,7 +446,7 @@ func TestCluster(name, selector, ns, pgouser string, allFlag bool) msgs.ClusterT
446446
case msgs.PodTypeReplica:
447447
instance.InstanceType = msgs.ClusterTestInstanceTypeReplica
448448
}
449-
log.Debugf("Instance found with attributes: (%s, %s, %s)",
449+
log.Debugf("Instance found with attributes: (%s, %s, %v)",
450450
instance.InstanceType, instance.Message, instance.Available)
451451
// Add the report on the pods to this set
452452
result.Instances = append(result.Instances, instance)
@@ -514,7 +514,7 @@ func TestCluster(name, selector, ns, pgouser string, allFlag bool) msgs.ClusterT
514514
}
515515
}
516516

517-
log.Debugf("Endpoint found with attributes: (%s, %s, %s)",
517+
log.Debugf("Endpoint found with attributes: (%s, %s, %v)",
518518
endpoint.InstanceType, endpoint.Message, endpoint.Available)
519519

520520
// append the endpoint to the list
@@ -1699,7 +1699,7 @@ func UpdateCluster(request *msgs.UpdateClusterRequest) msgs.UpdateClusterRespons
16991699
response.Status = msgs.Status{Code: msgs.Ok, Msg: ""}
17001700
response.Results = make([]string, 0)
17011701

1702-
log.Debugf("autofail is [%t]\n", request.Autofail)
1702+
log.Debugf("autofail is [%v]\n", request.Autofail)
17031703

17041704
switch {
17051705
case request.Startup && request.Shutdown:

internal/apiserver/clusterservice/clusterservice.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func ShowClusterHandler(w http.ResponseWriter, r *http.Request) {
131131
namespace := request.Namespace
132132
allflag := request.AllFlag
133133

134-
log.Debugf("ShowClusterHandler: parameters name [%s] selector [%s] ccpimagetag [%s] version [%s] namespace [%s] allflag [%s]", clustername, selector, ccpimagetag, clientVersion, namespace, allflag)
134+
log.Debugf("ShowClusterHandler: parameters name [%s] selector [%s] ccpimagetag [%s] version [%s] namespace [%s] allflag [%v]", clustername, selector, ccpimagetag, clientVersion, namespace, allflag)
135135

136136
username, err := apiserver.Authn(apiserver.SHOW_CLUSTER_PERM, w, r)
137137
if err != nil {
@@ -206,7 +206,7 @@ func DeleteClusterHandler(w http.ResponseWriter, r *http.Request) {
206206
deleteData := request.DeleteData
207207
deleteBackups := request.DeleteBackups
208208

209-
log.Debugf("DeleteClusterHandler: parameters namespace [%s] selector [%s] delete-data [%t] delete-backups [%t]", namespace, selector, clientVersion, deleteData, deleteBackups)
209+
log.Debugf("DeleteClusterHandler: parameters namespace [%s] selector [%s] delete-data [%t] delete-backups [%t]", namespace, selector, deleteData, deleteBackups)
210210

211211
username, err := apiserver.Authn(apiserver.DELETE_CLUSTER_PERM, w, r)
212212
if err != nil {

internal/apiserver/labelservice/labelimpl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ func deleteTheLabel(deployment *v1.Deployment, clusterName string, labelsMap map
483483

484484
_, err = apiserver.Clientset.AppsV1().Deployments(ns).Patch(deployment.Name, types.MergePatchType, patchBytes, "")
485485
if err != nil {
486-
log.Debugf("error patching deployment ", err.Error())
486+
log.Debugf("error patching deployment: %v", err.Error())
487487
}
488488
return err
489489

internal/apiserver/pgdumpservice/pgdumpimpl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ func ShowpgDump(clusterName string, selector string, ns string) msgs.ShowBackupR
237237
// nothing found, no error
238238
log.Debugf("pgTask %s not found, no erros", pgTaskName)
239239
response.Status.Code = msgs.Ok
240-
response.Status.Msg = fmt.Sprintln("pgDump %s not found.", pgTaskName)
240+
response.Status.Msg = fmt.Sprintf("pgDump %s not found.", pgTaskName)
241241
}
242242

243243
}

internal/apiserver/pgouserservice/pgouserimpl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ func UpdatePgouser(clientset kubernetes.Interface, updatedBy string, request *ms
244244
log.Info("Updating secret for: ", request.PgouserName)
245245
_, err = clientset.CoreV1().Secrets(apiserver.PgoNamespace).Update(secret)
246246
if err != nil {
247-
log.Debug("Error updating pgouser secret: ", err.Error)
247+
log.Debug("Error updating pgouser secret: ", err.Error())
248248
resp.Status.Code = msgs.Error
249249
resp.Status.Msg = err.Error()
250250
return resp

internal/apiserver/policyservice/policyimpl.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ func ApplyPolicy(request *msgs.ApplyPolicyRequest, ns, pgouser string) msgs.Appl
220220
return resp
221221
}
222222
if len(deployments.Items) < 1 {
223-
log.Error("%s did not have a deployment for some reason", c.Name)
223+
log.Errorf("%s did not have a deployment for some reason", c.Name)
224224
} else {
225225
allDeployments = append(allDeployments, deployments.Items[0])
226226
}
@@ -239,7 +239,7 @@ func ApplyPolicy(request *msgs.ApplyPolicyRequest, ns, pgouser string) msgs.Appl
239239

240240
for _, d := range allDeployments {
241241
if d.ObjectMeta.Labels[config.LABEL_SERVICE_NAME] != d.ObjectMeta.Labels[config.LABEL_PG_CLUSTER] {
242-
log.Debug("skipping apply policy on deployment %s", d.Name)
242+
log.Debugf("skipping apply policy on deployment %s", d.Name)
243243
continue
244244
//skip non primary deployments
245245
}

internal/apiserver/pvcservice/pvcservice.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func ShowPVCHandler(w http.ResponseWriter, r *http.Request) {
5353
clientVersion := request.ClientVersion
5454
namespace := request.Namespace
5555

56-
log.Debugf("ShowPVCHandler parameters version [%s] namespace [%s] pvcname [%s] nodeLabel [%]", clientVersion, namespace, clusterName)
56+
log.Debugf("ShowPVCHandler parameters version [%s] namespace [%s] pvcname [%s]", clientVersion, namespace, clusterName)
5757

5858
switch r.Method {
5959
case "GET":

internal/apiserver/statusservice/statusimpl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ func getLabels(ns string) []msgs.KeyValue {
174174
}
175175

176176
for k, v := range results {
177-
ss = append(ss, msgs.KeyValue{k, v})
177+
ss = append(ss, msgs.KeyValue{Key: k, Value: v})
178178
}
179179

180180
sort.Slice(ss, func(i, j int) bool {

internal/apiserver/upgradeservice/upgradeimpl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ func supportedOperatorVersion(version string) bool {
222222
// then the upgrade cannot continue
223223
minor, err := strconv.Atoi(operatorVersion[2])
224224
if err != nil {
225-
log.Errorf("Cannot convert Postgres Operator's minor version to an integer. Error: ", err)
225+
log.Errorf("Cannot convert Postgres Operator's minor version to an integer. Error: %v", err)
226226
return false
227227
}
228228
if minor < MINIMUM_MINOR_PGO_VERSION || minor > MAXIMUM_MINOR_PGO_VERSION {

internal/controller/manager/controllermanager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ func (c *ControllerManager) addControllerGroup(namespace string) error {
304304
pgoInformerFactory.Crunchydata().V1().Pgclusters(),
305305
*c.pgoConfig.Pgo.ConfigMapWorkerCount)
306306
if err != nil {
307-
log.Errorf("Unable to create ConfigMap controller: %w", err)
307+
log.Errorf("Unable to create ConfigMap controller: %v", err)
308308
return err
309309
}
310310

0 commit comments

Comments
 (0)