mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
Merge pull request #262 from erikwilson/golangci-lint
Upgrade to golangci-lint & go v1.12.1
This commit is contained in:
commit
028b8a444d
19
.golangci.json
Normal file
19
.golangci.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"linters": {
|
||||
"disable-all": true,
|
||||
"enable": [
|
||||
"govet",
|
||||
"golint",
|
||||
"goimports",
|
||||
"misspell",
|
||||
"ineffassign",
|
||||
"gofmt"
|
||||
]
|
||||
},
|
||||
"run": {
|
||||
"skip-files": [
|
||||
"/zz_generated_"
|
||||
],
|
||||
"deadline": "5m"
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
{
|
||||
"EnableAll": false,
|
||||
"Enable": [
|
||||
"golint",
|
||||
"goimports",
|
||||
"misspell",
|
||||
"ineffassign",
|
||||
"errcheck"
|
||||
],
|
||||
"Deadline": "1m"
|
||||
}
|
@ -1,22 +1,22 @@
|
||||
FROM golang:1.11.4-alpine3.8
|
||||
# FROM arm=golang@sha256:fe81149b4e7f07ecb558fd16cdbcdb11e739846a046e38cc6e170aa39a67e7ec arm64=golang@sha256:da9c2d140ed4bf911ef8f6d9437912b80497c256ef2235c65836eac83d1c0ce7
|
||||
FROM golang:1.12.1-alpine3.9
|
||||
|
||||
RUN apk -U --no-cache add bash git gcc musl-dev docker vim less file curl wget ca-certificates jq linux-headers zlib-dev tar zip squashfs-tools npm coreutils \
|
||||
python3 py3-pip python3-dev openssl-dev libffi-dev libseccomp libseccomp-dev make
|
||||
RUN pip3 install 'tox==3.6.0'
|
||||
RUN apk -U --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/main/ add sqlite-dev sqlite-static
|
||||
RUN mkdir -p /go/src/golang.org/x && \
|
||||
cd /go/src/golang.org/x && git clone https://github.com/golang/tools && git clone https://github.com/golang/lint && \
|
||||
git -C /go/src/golang.org/x/lint/golint checkout -b current 06c8688daad7faa9da5a0c2f163a3d14aac986ca && \
|
||||
go install golang.org/x/lint/golint
|
||||
RUN go get -d github.com/alecthomas/gometalinter && \
|
||||
git -C /go/src/github.com/alecthomas/gometalinter checkout -b current v2.0.11 && \
|
||||
go install github.com/alecthomas/gometalinter && \
|
||||
gometalinter --install
|
||||
cd /go/src/golang.org/x && git clone https://github.com/golang/tools && \
|
||||
git -C /go/src/golang.org/x/tools checkout -b current aa82965741a9fecd12b026fbb3d3c6ed3231b8f8 && \
|
||||
go install golang.org/x/tools/cmd/goimports
|
||||
RUN rm -rf /go/src /go/pkg
|
||||
|
||||
ARG DAPPER_HOST_ARCH
|
||||
ENV ARCH $DAPPER_HOST_ARCH
|
||||
|
||||
RUN if [ "${ARCH}" == "amd64" ]; then \
|
||||
curl -sL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.15.0; \
|
||||
fi
|
||||
|
||||
ENV DAPPER_RUN_ARGS --privileged -v k3s-cache:/go/src/github.com/rancher/k3s/.cache
|
||||
ENV DAPPER_ENV REPO TAG DRONE_TAG IMAGE_NAME
|
||||
ENV DAPPER_SOURCE /go/src/github.com/rancher/k3s/
|
||||
|
@ -105,13 +105,13 @@ func getAssetAndDir(dataDir string) (string, string) {
|
||||
|
||||
func extract(dataDir string) (string, error) {
|
||||
// first look for global asset folder so we don't create a HOME version if not needed
|
||||
asset, dir := getAssetAndDir(datadir.DefaultDataDir)
|
||||
_, dir := getAssetAndDir(datadir.DefaultDataDir)
|
||||
if _, err := os.Stat(dir); err == nil {
|
||||
logrus.Debugf("Asset dir %s", dir)
|
||||
return dir, nil
|
||||
}
|
||||
|
||||
asset, dir = getAssetAndDir(dataDir)
|
||||
asset, dir := getAssetAndDir(dataDir)
|
||||
if _, err := os.Stat(dir); err == nil {
|
||||
logrus.Debugf("Asset dir %s", dir)
|
||||
return dir, nil
|
||||
|
@ -122,7 +122,7 @@ func WriteSubnetFile(path string, nw ip.IP4Net, ipMasq bool, bn backend.Network)
|
||||
// Write out the first usable IP by incrementing
|
||||
// sn.IP by one
|
||||
sn := bn.Lease().Subnet
|
||||
sn.IP += 1
|
||||
sn.IP++
|
||||
|
||||
fmt.Fprintf(f, "FLANNEL_NETWORK=%s\n", nw)
|
||||
fmt.Fprintf(f, "FLANNEL_SUBNET=%s\n", sn)
|
||||
|
@ -35,7 +35,7 @@ const (
|
||||
]
|
||||
}
|
||||
`
|
||||
netJson = `{
|
||||
netJSON = `{
|
||||
"Network": "%CIDR%",
|
||||
"Backend": {
|
||||
"Type": "vxlan"
|
||||
@ -99,5 +99,5 @@ func createFlannelConf(config *config.Node) error {
|
||||
return nil
|
||||
}
|
||||
return util.WriteFile(config.FlannelConf,
|
||||
strings.Replace(netJson, "%CIDR%", config.AgentConfig.ClusterCIDR.String(), -1))
|
||||
strings.Replace(netJSON, "%CIDR%", config.AgentConfig.ClusterCIDR.String(), -1))
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ type Server struct {
|
||||
DisableAgent bool
|
||||
KubeConfigOutput string
|
||||
KubeConfigMode string
|
||||
KnownIPs cli.StringSlice
|
||||
KnownIPs cli.StringSlice
|
||||
}
|
||||
|
||||
var ServerConfig Server
|
||||
@ -96,8 +96,8 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command {
|
||||
EnvVar: "K3S_KUBECONFIG_MODE",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "tls-san",
|
||||
Usage: "Add additional hostname or IP as a Subject Alternative Name in the TLS cert",
|
||||
Name: "tls-san",
|
||||
Usage: "Add additional hostname or IP as a Subject Alternative Name in the TLS cert",
|
||||
Value: &ServerConfig.KnownIPs,
|
||||
},
|
||||
NodeIPFlag,
|
||||
|
@ -2,11 +2,12 @@ package deploy
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func Stage(dataDir string, templateVars map[string]string, skipList []string) error {
|
||||
|
@ -137,8 +137,7 @@ func startNorman(ctx context.Context, config *Config) (string, error) {
|
||||
},
|
||||
}
|
||||
|
||||
ctx, _, err = normanConfig.Build(ctx, nil)
|
||||
if err != nil {
|
||||
if _, _, err = normanConfig.Build(ctx, nil); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,7 @@ func (h *handler) newDeployment(svc *core.Service) (*apps.Deployment, error) {
|
||||
|
||||
for _, node := range nodes {
|
||||
if Ready.IsTrue(node) {
|
||||
replicas += 1
|
||||
replicas++
|
||||
}
|
||||
if replicas >= 2 {
|
||||
break
|
||||
|
@ -3,34 +3,21 @@ set -e
|
||||
|
||||
cd $(dirname $0)/..
|
||||
|
||||
if ! command -v golangci-lint; then
|
||||
echo Skipping validation: no golangci-lint available
|
||||
exit
|
||||
fi
|
||||
echo Running validation
|
||||
|
||||
PACKAGES="$(go list ./...)"
|
||||
|
||||
if [ ! -e build/data ];then
|
||||
mkdir -p build/data
|
||||
fi
|
||||
|
||||
echo Running: go generate
|
||||
go generate
|
||||
|
||||
echo Running: go vet
|
||||
go vet ${PACKAGES}
|
||||
echo Running: gometalinter
|
||||
for i in ${PACKAGES}; do
|
||||
if [ -n "$(gometalinter $i | \
|
||||
grep -v 'pkg/data/zz_generated_bindata.go' | \
|
||||
grep -v 'should have comment.*or be unexported' | \
|
||||
grep -v 'cli/cmd.*don.t use underscores in Go name' | \
|
||||
grep -v 'cli/cmd.*should be DNS' | \
|
||||
tee /dev/stderr)" ]; then
|
||||
failed=true
|
||||
fi
|
||||
done
|
||||
test -z "$failed"
|
||||
echo Running: go fmt
|
||||
test -z "$(go fmt ${PACKAGES} | \
|
||||
grep -v 'pkg/data/zz_generated_bindata.go' | \
|
||||
tee /dev/stderr)"
|
||||
echo Running: golangci-lint
|
||||
golangci-lint run
|
||||
|
||||
. ./scripts/version.sh
|
||||
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/rancher/norman/controller"
|
||||
"github.com/rancher/norman/objectclient"
|
||||
"k8s.io/api/apps/v1"
|
||||
v1 "k8s.io/api/apps/v1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
|
@ -2,7 +2,7 @@ package v1
|
||||
|
||||
import (
|
||||
"github.com/rancher/norman/lifecycle"
|
||||
"k8s.io/api/apps/v1"
|
||||
v1 "k8s.io/api/apps/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/rancher/norman/controller"
|
||||
"github.com/rancher/norman/objectclient"
|
||||
"k8s.io/api/batch/v1"
|
||||
v1 "k8s.io/api/batch/v1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
|
@ -2,7 +2,7 @@ package v1
|
||||
|
||||
import (
|
||||
"github.com/rancher/norman/lifecycle"
|
||||
"k8s.io/api/batch/v1"
|
||||
v1 "k8s.io/api/batch/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/rancher/norman/controller"
|
||||
"github.com/rancher/norman/objectclient"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
|
@ -2,7 +2,7 @@ package v1
|
||||
|
||||
import (
|
||||
"github.com/rancher/norman/lifecycle"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/rancher/norman/controller"
|
||||
"github.com/rancher/norman/objectclient"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
|
@ -2,7 +2,7 @@ package v1
|
||||
|
||||
import (
|
||||
"github.com/rancher/norman/lifecycle"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/rancher/norman/controller"
|
||||
"github.com/rancher/norman/objectclient"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
|
@ -2,7 +2,7 @@ package v1
|
||||
|
||||
import (
|
||||
"github.com/rancher/norman/lifecycle"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/rancher/norman/controller"
|
||||
"github.com/rancher/norman/objectclient"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
|
@ -2,7 +2,7 @@ package v1
|
||||
|
||||
import (
|
||||
"github.com/rancher/norman/lifecycle"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/rancher/norman/controller"
|
||||
"github.com/rancher/norman/objectclient"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
|
@ -2,7 +2,7 @@ package v1
|
||||
|
||||
import (
|
||||
"github.com/rancher/norman/lifecycle"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/rancher/norman/controller"
|
||||
"github.com/rancher/norman/objectclient"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
|
@ -2,7 +2,7 @@ package v1
|
||||
|
||||
import (
|
||||
"github.com/rancher/norman/lifecycle"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/rancher/norman/controller"
|
||||
"github.com/rancher/norman/objectclient"
|
||||
"k8s.io/api/rbac/v1"
|
||||
v1 "k8s.io/api/rbac/v1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
|
@ -2,7 +2,7 @@ package v1
|
||||
|
||||
import (
|
||||
"github.com/rancher/norman/lifecycle"
|
||||
"k8s.io/api/rbac/v1"
|
||||
v1 "k8s.io/api/rbac/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user