Skip to content

Commit

Permalink
Update golangci-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Moss committed May 29, 2020
1 parent 84203f5 commit 3f53a09
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ linters:
- gocognit
- gomnd
- interfacer
- godot
- goerr113
- nestif
# Run with --fast=false for more extensive checks
fast: true
issues:
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/client/cluster/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ type Proxy interface {
}

// retryWithExponentialBackoff repeats an operation until it passes or the exponential backoff times out.
func retryWithExponentialBackoff(opts wait.Backoff, operation func() error) error { //nolint:unparam
func retryWithExponentialBackoff(opts wait.Backoff, operation func() error) error {
log := logf.Log

i := 0
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/client/cluster/objectgraph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ func getDetachedObjectGraphWihObjs(objs []runtime.Object) (*objectGraph, error)
graph := newObjectGraph(nil) // detached from any cluster
for _, o := range objs {
u := &unstructured.Unstructured{}
if err := test.FakeScheme.Convert(o, u, nil); err != nil { //nolint
if err := test.FakeScheme.Convert(o, u, nil); err != nil {
return nil, errors.Wrap(err, "failed to convert object in unstructured")
}
graph.addObj(u)
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/client/repository/repository_github.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ func (g *gitHubRepository) downloadFilesFromRelease(release *github.RepositoryRe
return nil, g.handleGithubErr(err, "failed to download file %q from %q release", *release.TagName, fileName)
}
if redirect != "" {
response, err := http.Get(redirect) //nolint:bodyclose (NB: The reader is actually closed in a defer)
response, err := http.Get(redirect) //nolint:bodyclose // (NB: The reader is actually closed in a defer)
if err != nil {
return nil, errors.Wrapf(err, "failed to download file %q from %q release via redirect location %q", *release.TagName, fileName, redirect)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/cmd/upgrade_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func runUpgradePlan() error {
if upgradeAvailable {
fmt.Println("You can now apply the upgrade by executing the following command:")
fmt.Println("")
fmt.Println(fmt.Sprintf(" upgrade apply --management-group %s --contract %s", plan.CoreProvider.InstanceName(), plan.Contract))
fmt.Printf(" upgrade apply --management-group %s --contract %s\n", plan.CoreProvider.InstanceName(), plan.Contract)
} else {
fmt.Println("You are already up to date!")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/internal/util/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func JoinYaml(yamls ...[]byte) []byte {

// ToUnstructured takes a YAML and converts it to a list of Unstructured objects
func ToUnstructured(rawyaml []byte) ([]unstructured.Unstructured, error) {
var ret []unstructured.Unstructured //nolint
var ret []unstructured.Unstructured

reader := utilyaml.NewYAMLReader(bufio.NewReader(bytes.NewReader(rawyaml)))
count := 1
Expand Down
4 changes: 2 additions & 2 deletions controllers/mdutil/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func getIntFromAnnotation(ms *clusterv1.MachineSet, annotationKey string, logger
if !ok {
return int32(0), false
}
intValue, err := strconv.Atoi(annotationValue)
intValue, err := strconv.ParseInt(annotationValue, 10, 64)
if err != nil {
logger.V(2).Info("Cannot convert the value to integer", "annotationValue", annotationValue)
return int32(0), false
Expand Down Expand Up @@ -563,7 +563,7 @@ func IsSaturated(deployment *clusterv1.MachineDeployment, ms *clusterv1.MachineS
return false
}
desiredString := ms.Annotations[clusterv1.DesiredReplicasAnnotation]
desired, err := strconv.Atoi(desiredString)
desired, err := strconv.ParseInt(desiredString, 10, 64)
if err != nil {
return false
}
Expand Down
2 changes: 1 addition & 1 deletion controlplane/kubeadm/controllers/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ func TestKubeadmControlPlaneReconciler_adoption(t *testing.T) {
"test0": &clusterv1.Machine{
ObjectMeta: metav1.ObjectMeta{
Namespace: cluster.Namespace,
Name: fmt.Sprintf("test0"),
Name: "test0",
Labels: internal.ControlPlaneLabelsForCluster(cluster.Name),
},
Spec: clusterv1.MachineSpec{
Expand Down
9 changes: 5 additions & 4 deletions controlplane/kubeadm/internal/machine_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ func NewFilterableMachineCollection(machines ...*clusterv1.Machine) FilterableMa

// NewFilterableMachineCollectionFromMachineList creates a FilterableMachineCollection from the given MachineList
func NewFilterableMachineCollectionFromMachineList(machineList *clusterv1.MachineList) FilterableMachineCollection {
if machineList == nil {
return nil
}
ss := make(FilterableMachineCollection, len(machineList.Items))
if machineList != nil {
for i := range machineList.Items {
ss.Insert(&machineList.Items[i])
}
for i := range machineList.Items {
ss.Insert(&machineList.Items[i])
}
return ss
}
Expand Down
7 changes: 4 additions & 3 deletions hack/tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ go 1.13
require (
github.com/blang/semver v3.5.1+incompatible
github.com/go-bindata/go-bindata v3.1.2+incompatible
github.com/golangci/golangci-lint v1.23.8
github.com/golangci/golangci-lint v1.27.0
github.com/joelanford/go-apidiff v0.0.0-20191206194835-106bcff5f060
github.com/onsi/ginkgo v1.11.0
github.com/onsi/ginkgo v1.12.0
github.com/raviqqe/liche v0.0.0-20200229003944-f57a5d1c5be4
golang.org/x/tools v0.0.0-20200204192400-7124308813f3
golang.org/x/tools v0.0.0-20200502202811-ed308ab3e770
honnef.co/go/tools v0.0.1-2020.1.4 // indirect
k8s.io/code-generator v0.18.0
sigs.k8s.io/controller-tools v0.2.9
sigs.k8s.io/kubebuilder/docs/book/utils v0.0.0-20200226075303-ed8438ec10a4
Expand Down
Loading

0 comments on commit 3f53a09

Please sign in to comment.