Add CNI Plugins and Flannel version to build scripts

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit 1caae63140)
pull/5612/head
Brad Davidson 2022-04-19 14:48:04 -07:00 committed by Brad Davidson
parent 7168f7282c
commit 4943071aa0
2 changed files with 16 additions and 5 deletions

View File

@ -10,9 +10,10 @@ GO=${GO-go}
PKG="github.com/k3s-io/k3s" PKG="github.com/k3s-io/k3s"
PKG_CONTAINERD="github.com/containerd/containerd" PKG_CONTAINERD="github.com/containerd/containerd"
PKG_K3S_CONTAINERD="github.com/k3s-io/containerd" PKG_K3S_CONTAINERD="github.com/k3s-io/containerd"
PKG_CRICTL="github.com/kubernetes-sigs/cri-tools" PKG_CRICTL="github.com/kubernetes-sigs/cri-tools/pkg"
PKG_K8S_BASE="k8s.io/component-base" PKG_K8S_BASE="k8s.io/component-base"
PKG_K8S_CLIENT="k8s.io/client-go/pkg" PKG_K8S_CLIENT="k8s.io/client-go/pkg"
PKG_CNI_PLUGINS="github.com/containernetworking/plugins"
buildDate=$(date -u '+%Y-%m-%dT%H:%M:%SZ') buildDate=$(date -u '+%Y-%m-%dT%H:%M:%SZ')
@ -34,7 +35,12 @@ VERSIONFLAGS="
-X ${PKG_CONTAINERD}/version.Version=${VERSION_CONTAINERD} -X ${PKG_CONTAINERD}/version.Version=${VERSION_CONTAINERD}
-X ${PKG_CONTAINERD}/version.Package=${PKG_K3S_CONTAINERD} -X ${PKG_CONTAINERD}/version.Package=${PKG_K3S_CONTAINERD}
-X ${PKG_CRICTL}/pkg/version.Version=${VERSION_CRICTL}
-X ${PKG_CNI_PLUGINS}/pkg/utils/buildversion.BuildVersion=${VERSION_CNIPLUGINS}
-X ${PKG_CNI_PLUGINS}/plugins/meta/flannel.Program=flannel
-X ${PKG_CNI_PLUGINS}/plugins/meta/flannel.Version=${VERSION_FLANNEL}
-X ${PKG_CNI_PLUGINS}/plugins/meta/flannel.Commit=${COMMIT}
-X ${PKG_CNI_PLUGINS}/plugins/meta/flannel.buildDate=${buildDate}
" "
LDFLAGS=" LDFLAGS="
-w -s" -w -s"
@ -99,7 +105,7 @@ if [ ! -x ${INSTALLBIN}/cni ]; then
WORKDIR=$TMPDIR/src/github.com/containernetworking/plugins WORKDIR=$TMPDIR/src/github.com/containernetworking/plugins
git clone -b $VERSION_CNIPLUGINS https://github.com/rancher/plugins.git $WORKDIR git clone -b $VERSION_CNIPLUGINS https://github.com/rancher/plugins.git $WORKDIR
cd $WORKDIR cd $WORKDIR
GO111MODULE=off 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 "$VERSIONFLAGS $LDFLAGS $STATIC" -o $INSTALLBIN/cni
) )
fi fi

View File

@ -42,9 +42,14 @@ if [ -z "$VERSION_RUNC" ]; then
VERSION_RUNC="v0.0.0" VERSION_RUNC="v0.0.0"
fi fi
VERSION_CNIPLUGINS="v0.9.1-k3s1" VERSION_FLANNEL=$(grep github.com/flannel-io/flannel go.mod | head -n1 | awk '{print $2}')
if [ -z "$VERSION_FLANNEL" ]; then
VERSION_FLANNEL="v0.0.0"
fi
VERSION_ROOT="v0.10.0" VERSION_CNIPLUGINS="v1.1.1-k3s1"
VERSION_ROOT="v0.11.0"
if [[ -n "$GIT_TAG" ]]; then if [[ -n "$GIT_TAG" ]]; then
if [[ ! "$GIT_TAG" =~ ^"$VERSION_K8S"[+-] ]]; then if [[ ! "$GIT_TAG" =~ ^"$VERSION_K8S"[+-] ]]; then