code changes to drop the vendor dir

Signed-off-by: Luther Monson <luther.monson@gmail.com>
This commit is contained in:
Luther Monson 2021-11-08 20:50:42 -07:00
parent 8ad7d141e8
commit e6cf8f5982
13 changed files with 40 additions and 53 deletions

View File

@ -16,7 +16,8 @@
"contrib",
"manifests",
"package",
"scripts"
"scripts",
"vendor"
],
"skip-files": [
"/zz_generated_"

View File

@ -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/

View File

@ -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

4
go.mod
View File

@ -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

2
go.sum
View File

@ -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=

1
pkg/data/data.go Normal file
View File

@ -0,0 +1 @@
package data

View File

@ -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

View File

@ -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

View File

@ -5,10 +5,7 @@ SCRIPT_DIR=$(dirname $0)
pushd $SCRIPT_DIR
./download
if [ -z "$SKIP_VALIDATE" ]; then
./validate
fi
./validate
./build
./package

View File

@ -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

View File

@ -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'"

View File

@ -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

View File

@ -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() {}