diff --git a/.golangci.json b/.golangci.json index c1c6c3e2b5..3e2499bfaf 100644 --- a/.golangci.json +++ b/.golangci.json @@ -16,7 +16,8 @@ "contrib", "manifests", "package", - "scripts" + "scripts", + "vendor" ], "skip-files": [ "/zz_generated_" diff --git a/Dockerfile.dapper b/Dockerfile.dapper index b6a52aa8f6..e92cbbaaac 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -26,7 +26,7 @@ RUN if [ "$(go env GOARCH)" = "arm64" ]; then mv trivy /usr/local/bin; \ fi # this works for both go 1.15 and 1.16 -RUN GO111MODULE=on GOPROXY=direct go get golang.org/x/tools/cmd/goimports@gopls/v0.7.0 +RUN GOPROXY=direct go get golang.org/x/tools/cmd/goimports@gopls/v0.7.0 RUN rm -rf /go/src /go/pkg RUN if [ "$(go env GOARCH)" = "amd64" ]; then \ @@ -39,7 +39,6 @@ RUN wget -O - ${YQ_URL}_$(go env GOARCH) > /usr/bin/yq && chmod +x /usr/bin/yq ARG SELINUX=true ENV SELINUX $SELINUX -ENV GO111MODULE off ENV DAPPER_RUN_ARGS --privileged -v k3s-cache:/go/src/github.com/rancher/k3s/.cache -v trivy-cache:/root/.cache/trivy ENV DAPPER_ENV REPO TAG DRONE_TAG IMAGE_NAME SKIP_VALIDATE SKIP_AIRGAP GCLOUD_AUTH GITHUB_TOKEN GOLANG ENV DAPPER_SOURCE /go/src/github.com/rancher/k3s/ diff --git a/Makefile b/Makefile index 3eca4ec940..a1dc61fc5e 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ TARGETS := $(shell ls scripts | grep -v \\.sh) .dapper: @echo Downloading dapper - @curl -sL https://releases.rancher.com/dapper/v0.5.1/dapper-$$(uname -s)-$$(uname -m) > .dapper.tmp + @curl -sL https://releases.rancher.com/dapper/v0.5.7/dapper-$$(uname -s)-$$(uname -m) > .dapper.tmp @@chmod +x .dapper.tmp @./.dapper.tmp -v @mv .dapper.tmp .dapper diff --git a/go.mod b/go.mod index 6d2ff8bfa9..24f2de86d9 100644 --- a/go.mod +++ b/go.mod @@ -17,8 +17,6 @@ replace ( github.com/matryer/moq => github.com/rancher/moq v0.0.0-20190404221404-ee5226d43009 github.com/opencontainers/runc => github.com/opencontainers/runc v1.0.3 github.com/opencontainers/runtime-spec => github.com/opencontainers/runtime-spec v1.0.3-0.20210316141917-a8c4a9ee0f6b - github.com/rancher/k3s/pkg/data => ./pkg/data - github.com/rancher/wrangler => github.com/rancher/wrangler v0.8.10 go.etcd.io/etcd/api/v3 => github.com/k3s-io/etcd/api/v3 v3.5.0-k3s2 go.etcd.io/etcd/client/v3 => github.com/k3s-io/etcd/client/v3 v3.5.0-k3s2 go.etcd.io/etcd/etcdutl/v3 => github.com/k3s-io/etcd/etcdutl/v3 v3.5.0-k3s2 @@ -99,7 +97,7 @@ require ( github.com/rancher/lasso v0.0.0-20210616224652-fc3ebd901c08 github.com/rancher/remotedialer v0.2.0 github.com/rancher/wharfie v0.5.1 - github.com/rancher/wrangler v0.8.9 + github.com/rancher/wrangler v0.8.10 github.com/robfig/cron/v3 v3.0.1 github.com/rootless-containers/rootlesskit v0.14.5 github.com/sirupsen/logrus v1.8.1 diff --git a/go.sum b/go.sum index 5d11e87c84..c15d89e3d8 100644 --- a/go.sum +++ b/go.sum @@ -927,6 +927,8 @@ github.com/rancher/remotedialer v0.2.0 h1:xD7t3K6JYwTdAsxmGtTHQMkEkFgKouQ1foLxVW github.com/rancher/remotedialer v0.2.0/go.mod h1:tkU8ZvrR5lRgaKWaX71nAy6daeqvPFx/lJEnbW7tXSI= github.com/rancher/wharfie v0.5.1 h1:TUqZyNj6BaGe2+tqhwAGwZouuwx02mvAMMjNuyejc5I= github.com/rancher/wharfie v0.5.1/go.mod h1:5AHZRFBAOWYPDNCwj/y5Dpj+MMwXLoitPwxjYAIbcxQ= +github.com/rancher/wrangler v0.8.3/go.mod h1:dKEaHNB4izxmPUtpq1Hvr3z3Oh+9k5pCZyFO9sUhlaY= +github.com/rancher/wrangler v0.8.9/go.mod h1:Lte9WjPtGYxYacIWeiS9qawvu2R4NujFU9xuXWJvc/0= github.com/rancher/wrangler v0.8.10 h1:GfM3dZyw3TconwqknRm6YO/wiKEbUIGl0/HWVqBy658= github.com/rancher/wrangler v0.8.10/go.mod h1:Lte9WjPtGYxYacIWeiS9qawvu2R4NujFU9xuXWJvc/0= github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M= diff --git a/pkg/data/data.go b/pkg/data/data.go new file mode 100644 index 0000000000..0ad59c200c --- /dev/null +++ b/pkg/data/data.go @@ -0,0 +1 @@ +package data diff --git a/scripts/build b/scripts/build index ef11bdc552..05cac70322 100755 --- a/scripts/build +++ b/scripts/build @@ -7,7 +7,7 @@ cd $(dirname $0)/.. GO=${GO-go} -PKG="github.com/rancher/k3s" +PKG="github.com/k3s-io/k3s" PKG_CONTAINERD="github.com/containerd/containerd" PKG_K3S_CONTAINERD="github.com/k3s-io/containerd" PKG_CRICTL="github.com/kubernetes-sigs/cri-tools/pkg" @@ -16,25 +16,24 @@ PKG_K8S_CLIENT="k8s.io/client-go/pkg" buildDate=$(date -u '+%Y-%m-%dT%H:%M:%SZ') -VENDOR_PREFIX="${PKG}/vendor/" VERSIONFLAGS=" -X ${PKG}/pkg/version.Version=${VERSION} -X ${PKG}/pkg/version.GitCommit=${COMMIT:0:8} - -X ${VENDOR_PREFIX}${PKG_K8S_CLIENT}/version.gitVersion=${VERSION} - -X ${VENDOR_PREFIX}${PKG_K8S_CLIENT}/version.gitCommit=${COMMIT} - -X ${VENDOR_PREFIX}${PKG_K8S_CLIENT}/version.gitTreeState=${TREE_STATE} - -X ${VENDOR_PREFIX}${PKG_K8S_CLIENT}/version.buildDate=${buildDate} + -X ${PKG_K8S_CLIENT}/version.gitVersion=${VERSION} + -X ${PKG_K8S_CLIENT}/version.gitCommit=${COMMIT} + -X ${PKG_K8S_CLIENT}/version.gitTreeState=${TREE_STATE} + -X ${PKG_K8S_CLIENT}/version.buildDate=${buildDate} - -X ${VENDOR_PREFIX}${PKG_K8S_BASE}/version.gitVersion=${VERSION} - -X ${VENDOR_PREFIX}${PKG_K8S_BASE}/version.gitCommit=${COMMIT} - -X ${VENDOR_PREFIX}${PKG_K8S_BASE}/version.gitTreeState=${TREE_STATE} - -X ${VENDOR_PREFIX}${PKG_K8S_BASE}/version.buildDate=${buildDate} + -X ${PKG_K8S_BASE}/version.gitVersion=${VERSION} + -X ${PKG_K8S_BASE}/version.gitCommit=${COMMIT} + -X ${PKG_K8S_BASE}/version.gitTreeState=${TREE_STATE} + -X ${PKG_K8S_BASE}/version.buildDate=${buildDate} - -X ${VENDOR_PREFIX}${PKG_CRICTL}/version.Version=${VERSION_CRICTL} + -X ${PKG_CRICTL}/version.Version=${VERSION_CRICTL} - -X ${VENDOR_PREFIX}${PKG_CONTAINERD}/version.Version=${VERSION_CONTAINERD} - -X ${VENDOR_PREFIX}${PKG_CONTAINERD}/version.Package=${PKG_K3S_CONTAINERD} + -X ${PKG_CONTAINERD}/version.Version=${VERSION_CONTAINERD} + -X ${PKG_CONTAINERD}/version.Package=${PKG_K3S_CONTAINERD} -X ${PKG_CONTAINERD}/version.Version=${VERSION_CONTAINERD} -X ${PKG_CONTAINERD}/version.Package=${PKG_K3S_CONTAINERD} @@ -98,7 +97,7 @@ if [ ! -x ${INSTALLBIN}/cni ]; then WORKDIR=$TMPDIR/src/github.com/containernetworking/plugins git clone -b $VERSION_CNIPLUGINS https://github.com/rancher/plugins.git $WORKDIR cd $WORKDIR - GOPATH=$TMPDIR CGO_ENABLED=0 "${GO}" build -tags "$TAGS" -ldflags "$LDFLAGS $STATIC" -o $INSTALLBIN/cni + GO111MODULE=off GOPATH=$TMPDIR CGO_ENABLED=0 "${GO}" build -tags "$TAGS" -ldflags "$LDFLAGS $STATIC" -o $INSTALLBIN/cni ) fi diff --git a/scripts/build-tests-sonobuoy b/scripts/build-tests-sonobuoy index 430dc8356e..6312e57b7d 100755 --- a/scripts/build-tests-sonobuoy +++ b/scripts/build-tests-sonobuoy @@ -14,7 +14,7 @@ PKG_TO_TEST=$(find ./pkg/ -type f -name "*_int_test.go" | sed -r 's|/[^/]+$||' | for i in $PKG_TO_TEST; do name=$(echo "${i##*/}") echo $name - go test -c -v -ldflags "-X 'github.com/rancher/k3s/tests/util.existingServer=True'" -o dist/artifacts/k3s-integration-$name.test $i -run Integration + go test -c -v -ldflags "-X 'github.com/k3s-io/k3s/tests/util.existingServer=True'" -o dist/artifacts/k3s-integration-$name.test $i -run Integration done # Integration tests under /tests @@ -22,7 +22,7 @@ PKG_TO_TEST=$(find ./tests/integration -type f -name "*_int_test.go" | sed -r 's for i in $PKG_TO_TEST; do name=$(echo "${i##*/}") echo $name - go test -c -v -ldflags "-X 'github.com/rancher/k3s/tests/util.existingServer=True'" -o dist/artifacts/k3s-integration-$name.test $i -run Integration + go test -c -v -ldflags "-X 'github.com/k3s-io/k3s/tests/util.existingServer=True'" -o dist/artifacts/k3s-integration-$name.test $i -run Integration done docker build -f ./tests/integration/Dockerfile.test -t $REPO . docker save $REPO -o ./dist/artifacts/$REPO.tar diff --git a/scripts/ci b/scripts/ci index 21df29638e..9fb3ec5fb6 100755 --- a/scripts/ci +++ b/scripts/ci @@ -5,10 +5,7 @@ SCRIPT_DIR=$(dirname $0) pushd $SCRIPT_DIR ./download -if [ -z "$SKIP_VALIDATE" ]; then - ./validate -fi - +./validate ./build ./package diff --git a/scripts/manifest b/scripts/manifest index 5e863d26fd..c9eddf9f6d 100755 --- a/scripts/manifest +++ b/scripts/manifest @@ -25,7 +25,7 @@ if echo "${DRONE_TAG}" | grep -q '-'; then fi # get latest released version from github -GITHUB_URL=https://github.com/rancher/k3s/releases +GITHUB_URL=https://github.com/k3s-io/k3s/releases VERSION_K3S=$(curl -w '%{url_effective}' -I -L -s -S ${GITHUB_URL}/latest -o /dev/null | sed -e 's|.*/||') # function for comparing versions diff --git a/scripts/package-cli b/scripts/package-cli index 6c36922c28..e65aa43dbc 100755 --- a/scripts/package-cli +++ b/scripts/package-cli @@ -52,8 +52,8 @@ CMD_NAME=dist/artifacts/k3s${BIN_SUFFIX} "${GO}" generate LDFLAGS=" - -X github.com/rancher/k3s/pkg/version.Version=$VERSION - -X github.com/rancher/k3s/pkg/version.GitCommit=${COMMIT:0:8} + -X github.com/k3s-io/k3s/pkg/version.Version=$VERSION + -X github.com/k3s-io/k3s/pkg/version.GitCommit=${COMMIT:0:8} -w -s " STATIC="-extldflags '-static'" diff --git a/scripts/validate b/scripts/validate index 098fc4e77b..93e9abb3b9 100755 --- a/scripts/validate +++ b/scripts/validate @@ -3,27 +3,33 @@ set -e cd $(dirname $0)/.. -GO=${GO-go} +echo Running: go mod tidy +go mod tidy + +echo Running: go generate +go generate + +if [ -n "$SKIP_VALIDATE" ]; then + echo Skipping validation + exit +fi if ! command -v golangci-lint; then echo Skipping validation: no golangci-lint available exit fi + echo Running validation +echo Running: go mod verify +go mod verify if [ ! -e build/data ];then mkdir -p build/data fi -echo Running: "${GO}" generate -"${GO}" generate - echo Running: golangci-lint golangci-lint run -v -GO111MODULE=on go mod tidy -GO111MODULE=on go mod vendor - . ./scripts/version.sh if [ -n "$DIRTY" ]; then diff --git a/vendor.go b/vendor.go deleted file mode 100644 index 441981c8ef..0000000000 --- a/vendor.go +++ /dev/null @@ -1,16 +0,0 @@ -// +build vendor - -package main - -import ( - _ "github.com/containerd/containerd/cmd/containerd-shim-runc-v2" - _ "github.com/coreos/go-systemd/activation" - _ "github.com/go-bindata/go-bindata" - _ "github.com/go-bindata/go-bindata/go-bindata" - _ "github.com/opencontainers/runc" - _ "github.com/opencontainers/runc/contrib/cmd/recvtty" - _ "github.com/opencontainers/runc/libcontainer/nsenter" - _ "github.com/opencontainers/runc/libcontainer/specconv" -) - -func main() {}