code to remove vendor dir

Signed-off-by: Luther Monson <luther.monson@gmail.com>
pull/4842/head
Luther Monson 2021-12-22 14:39:05 -07:00
parent d47e38e05e
commit 1942d18447
6 changed files with 36 additions and 31 deletions

View File

@ -19,4 +19,4 @@
],
"deadline": "5m"
}
}
}

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.6.9
RUN GOPROXY=direct go get golang.org/x/tools/cmd/goimports@gopls/v0.6.9
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 GCLOUD_AUTH GITHUB_TOKEN GOLANG
ENV DAPPER_SOURCE /go/src/github.com/rancher/k3s/

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

@ -0,0 +1 @@
package data

View File

@ -16,26 +16,25 @@ 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 ${VENDOR_PREFIX}${PKG_CRICTL}/pkg/version.Version=${VERSION_CRICTL}
-X ${PKG_CONTAINERD}/version.Version=${VERSION_CONTAINERD}
-X ${PKG_CONTAINERD}/version.Package=${PKG_K3S_CONTAINERD}
-X ${PKG_CRICTL}/pkg/version.Version=${VERSION_CRICTL}
"
LDFLAGS="
-w -s"
@ -96,7 +95,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
@ -113,15 +112,15 @@ ln -s containerd ./bin/ctr
echo Building runc
rm -f ./build/src/github.com/opencontainers/runc/runc
make GOPATH=$(pwd)/build EXTRA_LDFLAGS="-w -s" BUILDTAGS="$RUNC_TAGS" -C ./build/src/github.com/opencontainers/runc $RUNC_STATIC
GO111MODULE=off make GOPATH=$(pwd)/build EXTRA_LDFLAGS="-w -s" BUILDTAGS="$RUNC_TAGS" -C ./build/src/github.com/opencontainers/runc $RUNC_STATIC
cp -f ./build/src/github.com/opencontainers/runc/runc ./bin/runc
echo Building containerd-shim
rm -f ./vendor/github.com/containerd/containerd/bin/containerd-shim
make -C ./vendor/github.com/containerd/containerd bin/containerd-shim
GO111MODULE=off make -C ./vendor/github.com/containerd/containerd bin/containerd-shim
cp -f ./vendor/github.com/containerd/containerd/bin/containerd-shim ./bin/containerd-shim
echo Building containerd-shim-runc-v2
rm -f ./vendor/github.com/containerd/containerd/bin/containerd-shim-runc-v2
make -C ./vendor/github.com/containerd/containerd bin/containerd-shim-runc-v2
GO111MODULE=off make -C ./vendor/github.com/containerd/containerd bin/containerd-shim-runc-v2
cp -f ./vendor/github.com/containerd/containerd/bin/containerd-shim-runc-v2 ./bin/containerd-shim-runc-v2

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

@ -3,27 +3,36 @@ set -e
cd $(dirname $0)/..
GO=${GO-go}
echo Running: go mod tidy
go mod tidy
echo Running: go generate
go generate
echo Running: go mod vendor
go mod vendor
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