Skip to content

Commit

Permalink
Add k3s version when it is set (#1731)
Browse files Browse the repository at this point in the history
* Add k3s version when it is set

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>

* Make K3S_VERSION a global

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>

* Remove luet rebuild numbers from k3s version

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>

---------

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
  • Loading branch information
jimmykarily committed Aug 17, 2023
1 parent 3a6272e commit ee3477c
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ ARG SHELLCHECK_VERSION=v0.9.0

ARG IMAGE_REPOSITORY_ORG=quay.io/kairos

ARG K3S_VERSION

all:
ARG SECURITY_SCANS=true
Expand Down Expand Up @@ -103,13 +104,16 @@ CONTAINER_IMAGE_VERSION:

ARG VERSION

# quay.io doesn't accept "+" in the repo name
ARG _VERSION=$(echo $VERSION | sed 's/+/-/')

IF [ "$IMAGE" = "" ]
# TODO: This IF block should be deleted as soon as our repository names
# follow our conventions.
IF [ "$VARIANT" = "standard" ]
RUN echo ${BASE_URL}/kairos-${FLAVOR}:${VERSION} > IMAGE
RUN echo ${BASE_URL}/kairos-${FLAVOR}:${_VERSION} > IMAGE
ELSE
RUN echo ${BASE_URL}/${VARIANT}-${FLAVOR}:${VERSION} > IMAGE
RUN echo ${BASE_URL}/${VARIANT}-${FLAVOR}:${_VERSION} > IMAGE
END
ELSE
RUN echo $IMAGE > IMAGE
Expand Down Expand Up @@ -152,7 +156,16 @@ version:

COPY . ./

RUN --no-cache echo $(git describe --always --tags --dirty) > VERSION
ARG _GIT_VERSION=$(git describe --always --tags --dirty)

# Remove luet rebuild numbers like we do here:
# https://github.com/kairos-io/packages/blob/2fbc098d0499a0c34c587057ff8a9f00c2b7f575/packages/k8s/k3s/build.yaml#L11-L12
IF [ "$K3S_VERSION" != "" ]
ARG _FIXED_VERSION=$(echo $K3S_VERSION | sed 's/+[[:digit:]]*//')
ARG _K3S_VERSION="-k3sv${_FIXED_VERSION}+k3s1"
END

RUN --no-cache echo ${_GIT_VERSION}${_K3S_VERSION} > VERSION

ARG VERSION=$(cat VERSION)
SAVE ARTIFACT VERSION VERSION
Expand Down Expand Up @@ -397,11 +410,10 @@ base-image:
END

ARG PROVIDER_KAIROS_BRANCH
ARG K3S_VERSION
IF [[ "$VARIANT" = "standard" ]]
DO +PROVIDER_INSTALL -PROVIDER_KAIROS_BRANCH=${PROVIDER_KAIROS_BRANCH}

DO +INSTALL_K3S -K3S_VERSION=${K3S_VERSION}
DO +INSTALL_K3S

# Redo os-release with override settings to point to provider-kairos stuff
# in earthly 0.7 we will be able to just override VARIANT here and just run the OSRELEASE once
Expand Down Expand Up @@ -1189,7 +1201,6 @@ PROVIDER_INSTALL:
INSTALL_K3S:
COMMAND

ARG K3S_VERSION
IF [[ "$K3S_VERSION" = "" ]]
RUN echo "$K3S_VERSION must be set" && exit 1
END
Expand Down

0 comments on commit ee3477c

Please sign in to comment.