Skip to content

Commit

Permalink
Merge pull request #1175 from luthermonson/fix-validate
Browse files Browse the repository at this point in the history
fixing golangci-lint for validate script to start working again
  • Loading branch information
luthermonson authored Jun 23, 2021
2 parents a9562d7 + d571724 commit d58ad61
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 26 deletions.
10 changes: 9 additions & 1 deletion .golangci.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"disable-all": true,
"enable": [
"govet",
"golint",
"revive",
"goimports",
"misspell",
"ineffassign",
Expand All @@ -15,5 +15,13 @@
"/zz_generated_"
],
"deadline": "5m"
},
"issues": {
"exclude-rules": [
{
"linters": "typecheck",
"text": "imported but not used"
}
]
}
}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ RUN curl -sL https://storage.googleapis.com/kubernetes-release/release/$( \
chmod a+x /usr/local/bin/kubectl; \
pip install codespell

RUN curl -sL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.27.0
RUN curl -sL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.41.0
RUN set -x \
&& apk --no-cache add \
libarchive-tools \
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/cmds/k3sopts.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var (
Hide: true,
}
)
var copy *K3SFlagOption = nil
var copy *K3SFlagOption

type K3SFlagOption struct {
Hide bool
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/cisnetworkpolicy/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const (
flannelHostNetworkPolicyName = "rke2-flannel-host-networking"
)

func CISNetworkPolicyController(ctx context.Context, sc *server.Context) error {
func Controller(ctx context.Context, sc *server.Context) error {
return register(ctx, sc.Core.Core().V1().Node(), sc.K8s)
}

Expand Down
7 changes: 2 additions & 5 deletions pkg/images/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/sirupsen/logrus"
)

// Image defaults overridden by config passed in and ImageOverrideConfig below
const (
Runtime = "runtime-image"
KubeAPIServer = "kube-apiserver-image"
Expand Down Expand Up @@ -236,11 +237,7 @@ func Pull(dir, name string, image name.Reference) error {
}

dest := filepath.Join(dir, name+".txt")
if err := ioutil.WriteFile(dest, []byte(image.Name()+"\n"), 0644); err != nil {
return err
}

return nil
return ioutil.WriteFile(dest, []byte(image.Name()+"\n"), 0644)
}

// checkPreloadedImages returns true if there are any files in dir that do not
Expand Down
11 changes: 5 additions & 6 deletions pkg/rke2/rke2.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@ import (
"time"

"github.com/pkg/errors"

containerdk3s "github.com/rancher/k3s/pkg/agent/containerd"
"github.com/rancher/rke2/pkg/controllers/cisnetworkpolicy"
"github.com/sirupsen/logrus"

"github.com/rancher/k3s/pkg/agent/config"
containerdk3s "github.com/rancher/k3s/pkg/agent/containerd"
"github.com/rancher/k3s/pkg/cli/agent"
"github.com/rancher/k3s/pkg/cli/cmds"
"github.com/rancher/k3s/pkg/cli/etcdsnapshot"
Expand All @@ -26,8 +22,10 @@ import (
"github.com/rancher/k3s/pkg/etcd"
rawServer "github.com/rancher/k3s/pkg/server"
"github.com/rancher/rke2/pkg/cli/defaults"
"github.com/rancher/rke2/pkg/controllers/cisnetworkpolicy"
"github.com/rancher/rke2/pkg/images"
"github.com/rancher/rke2/pkg/podexecutor"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
Expand All @@ -41,6 +39,7 @@ type Config struct {
KubeletPath string
}

// Valid CIS Profile versions
const (
CISProfile15 = "cis-1.5"
CISProfile16 = "cis-1.6"
Expand Down Expand Up @@ -76,7 +75,7 @@ func Server(clx *cli.Context, cfg Config) error {
var leaderControllers rawServer.CustomControllers

if cisMode {
leaderControllers = append(leaderControllers, cisnetworkpolicy.CISNetworkPolicyController)
leaderControllers = append(leaderControllers, cisnetworkpolicy.Controller)
}

return server.RunWithControllers(clx, leaderControllers, rawServer.CustomControllers{})
Expand Down
21 changes: 10 additions & 11 deletions scripts/validate
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
#!/usr/bin/env bash
set -ex

if [ -n ${SKIP_VALIDATE} ]; then
if [ -n "${SKIP_VALIDATE}" ]; then
echo "skipping validation. continuing..."
exit 0
fi

cd $(dirname $0)/..
if ! command -v golangci-lint; then
echo Skipping validation: no golangci-lint available
exit
fi

cd $(dirname $0)/..
GO=${GO-go}

echo Running validation

echo Running: go fmt
go fmt ./
echo Running: go vet
go vet ./

echo Running: golangci-lint
if ! command -v golangci-lint; then
echo Skipping validation: no golangci-lint available
exit
fi
golangci-lint run

echo Running: go fmt
go fmt ./

echo Running: go mod tidy
go mod tidy

. ./scripts/version.sh
Expand Down

0 comments on commit d58ad61

Please sign in to comment.