Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Move kairos vars to their own file #2908

Merged
merged 6 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ labels: bug, unconfirmed, triage

**Kairos version:**
<!-- Provide the output from "cat /etc/os-release" -->
<!-- Provide the output from "cat /etc/kairos-release" -->

**CPU architecture, OS, and Version:**
<!-- Provide the output from "uname -a" -->
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/reusable-uki-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ jobs:
sudo luet util unpack "${TEMP_IMAGE}" ./unpacked
new_version="mynewversion"
sudo sed -i 's/^KAIROS_VERSION=.*/KAIROS_VERSION="'$new_version'"/' ./unpacked/etc/os-release
sudo sed -i 's/^KAIROS_VERSION=.*/KAIROS_VERSION="'$new_version'"/' ./unpacked/etc/kairos-release
echo "$new_version" > "${PWD}/build/expected_new_version"

docker run --rm \
Expand Down
26 changes: 13 additions & 13 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ ARG TRIVY_VERSION=0.55.2
# renovate: datasource=docker depName=anchore/grype versioning=semver
ARG GRYPE_VERSION=v0.80.1
# renovate: datasource=docker depName=quay.io/kairos/framework versioning=semver
ARG KAIROS_FRAMEWORK_VERSION=v2.12.4
ARG KAIROS_FRAMEWORK_VERSION=v2.13.0
# renovate: datasource=docker depName=quay.io/kairos/osbuilder-tools versioning=semver
ARG OSBUILDER_VERSION=v0.300.3
ARG OSBUILDER_VERSION=v0.400.0
# renovate: datasource=docker depName=golang versioning=semver
ARG GO_VERSION=1.22
# renovate: datasource=docker depName=hadolint/hadolint
Expand Down Expand Up @@ -183,7 +183,7 @@ syft:
image-sbom:
FROM +base-image
WORKDIR /build
ARG ISO_NAME=$(cat /etc/os-release | grep 'KAIROS_ARTIFACT' | sed 's/KAIROS_ARTIFACT=\"//' | sed 's/\"//')
ARG ISO_NAME=$(cat /etc/kairos-release | grep 'KAIROS_ARTIFACT' | sed 's/KAIROS_ARTIFACT=\"//' | sed 's/\"//')

COPY +syft/syft /usr/bin/syft
RUN syft / -o json=sbom.syft.json -o spdx-json=sbom.spdx.json
Expand Down Expand Up @@ -507,7 +507,7 @@ uki-dev-iso:
# We just use it here to take a shortcut to the artifact name
FROM +base-image
WORKDIR /build
ARG ISO_NAME=$(cat /etc/os-release | grep 'KAIROS_ARTIFACT' | sed 's/KAIROS_ARTIFACT=\"//' | sed 's/\"//')
ARG ISO_NAME=$(cat /etc/kairos-release | grep 'KAIROS_ARTIFACT' | sed 's/KAIROS_ARTIFACT=\"//' | sed 's/\"//')

COPY +git-version/GIT_VERSION ./
ARG KAIROS_VERSION=$(cat GIT_VERSION)
Expand Down Expand Up @@ -561,7 +561,7 @@ uki-dev-iso:

iso:
FROM +base-image
ARG ISO_NAME=$(cat /etc/os-release | grep 'KAIROS_ARTIFACT' | sed 's/KAIROS_ARTIFACT=\"//' | sed 's/\"//')
ARG ISO_NAME=$(cat /etc/kairos-release | grep 'KAIROS_ARTIFACT' | sed 's/KAIROS_ARTIFACT=\"//' | sed 's/\"//')

ARG OSBUILDER_IMAGE
FROM $OSBUILDER_IMAGE
Expand All @@ -586,7 +586,7 @@ iso:
iso-remote:
ARG --required REMOTE_IMG
FROM $REMOTE_IMG
ARG ISO_NAME=$(cat /etc/os-release | grep 'KAIROS_ARTIFACT' | sed 's/KAIROS_ARTIFACT=\"//' | sed 's/\"//')
ARG ISO_NAME=$(cat /etc/kairos-release | grep 'KAIROS_ARTIFACT' | sed 's/KAIROS_ARTIFACT=\"//' | sed 's/\"//')

ARG OSBUILDER_IMAGE
FROM $OSBUILDER_IMAGE
Expand All @@ -600,7 +600,7 @@ iso-remote:
netboot:
FROM +base-image

ARG ISO_NAME=$(cat /etc/os-release | grep 'KAIROS_ARTIFACT' | sed 's/KAIROS_ARTIFACT=\"//' | sed 's/\"//')
ARG ISO_NAME=$(cat /etc/kairos-release | grep 'KAIROS_ARTIFACT' | sed 's/KAIROS_ARTIFACT=\"//' | sed 's/\"//')

# Variables used here:
# https://github.com/kairos-io/osbuilder/blob/66e9e7a9403a413e310f462136b70d715605ab09/tools-image/ipxe.tmpl#L5
Expand Down Expand Up @@ -630,7 +630,7 @@ arm-image:
ARG IMG_COMPRESSION=xz

FROM --platform=linux/arm64 +base-image
ARG IMAGE_NAME=$(cat /etc/os-release | grep 'KAIROS_ARTIFACT' | sed 's/KAIROS_ARTIFACT=\"//' | sed 's/\"//').img
ARG IMAGE_NAME=$(cat /etc/kairos-release | grep 'KAIROS_ARTIFACT' | sed 's/KAIROS_ARTIFACT=\"//' | sed 's/\"//').img

FROM $OSBUILDER_IMAGE
ARG --required MODEL
Expand Down Expand Up @@ -699,7 +699,7 @@ ipxe-iso:
ARG ENABLE_HTTPS

FROM +base-image
ARG ISO_NAME=$(cat /etc/os-release | grep 'KAIROS_ARTIFACT' | sed 's/KAIROS_ARTIFACT=\"//' | sed 's/\"//')
ARG ISO_NAME=$(cat /etc/kairos-release | grep 'KAIROS_ARTIFACT' | sed 's/KAIROS_ARTIFACT=\"//' | sed 's/\"//')

# Variables used here:
# https://github.com/kairos-io/osbuilder/blob/66e9e7a9403a413e310f462136b70d715605ab09/tools-image/ipxe.tmpl#L5
Expand Down Expand Up @@ -743,7 +743,7 @@ raw-image:
# We just use it here to take a shortcut to the artifact name
FROM +base-image
WORKDIR /build
ARG IMG_NAME=$(cat /etc/os-release | grep 'KAIROS_ARTIFACT' | sed 's/KAIROS_ARTIFACT=\"//' | sed 's/\"//').raw
ARG IMG_NAME=$(cat /etc/kairos-release | grep 'KAIROS_ARTIFACT' | sed 's/KAIROS_ARTIFACT=\"//' | sed 's/\"//').raw

ARG OSBUILDER_IMAGE
FROM $OSBUILDER_IMAGE
Expand Down Expand Up @@ -792,7 +792,7 @@ trivy-scan:
# Use base-image so it can read original os-release file
FROM +base-image

ARG ISO_NAME=$(cat /etc/os-release | grep 'KAIROS_ARTIFACT' | sed 's/KAIROS_ARTIFACT=\"//' | sed 's/\"//')
ARG ISO_NAME=$(cat /etc/kairos-release | grep 'KAIROS_ARTIFACT' | sed 's/KAIROS_ARTIFACT=\"//' | sed 's/\"//')

ENV TRIVY_CACHE=/trivy-cache
IF [ -n "$CACHEDIR" ]
Expand Down Expand Up @@ -825,7 +825,7 @@ grype-scan:

COPY +grype/grype grype

ARG ISO_NAME=$(cat /etc/os-release | grep 'KAIROS_ARTIFACT' | sed 's/KAIROS_ARTIFACT=\"//' | sed 's/\"//')
ARG ISO_NAME=$(cat /etc/kairos-release | grep 'KAIROS_ARTIFACT' | sed 's/KAIROS_ARTIFACT=\"//' | sed 's/\"//')

RUN mkdir build
RUN ./grype dir:. --output sarif --add-cpes-if-none --file /build/report.sarif
Expand Down Expand Up @@ -875,7 +875,7 @@ run-qemu-datasource-tests:

run-qemu-netboot-test:
FROM +base-image
ARG ISO_NAME=$(cat /etc/os-release | grep 'KAIROS_ARTIFACT' | sed 's/KAIROS_ARTIFACT=\"//' | sed 's/\"//')
ARG ISO_NAME=$(cat /etc/kairos-release | grep 'KAIROS_ARTIFACT' | sed 's/KAIROS_ARTIFACT=\"//' | sed 's/\"//')

COPY +git-version/GIT_VERSION GIT_VERSION
ARG VERSION=$(cat ./GIT_VERSION)
Expand Down
8 changes: 2 additions & 6 deletions images/Dockerfile.kairos
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN rm -rf /etc/ssh/ssh_host_*

COPY which-init.sh /usr/local/bin/which-init.sh

RUN sed -i -n '/KAIROS_/!p' /etc/os-release
RUN if [ -f "/etc/kairos-release" ]; then sed -i -n '/KAIROS_/!p' /etc/kairos-release; fi
mauromorales marked this conversation as resolved.
Show resolved Hide resolved

# need to be defined after FROM for them to be replaced in the RUN bellow
ARG HOME_URL="https://github.com/kairos-io/kairos"
Expand Down Expand Up @@ -73,11 +73,7 @@ LABEL io.kairos.software-version="${SOFTWARE_VERSION}"
LABEL io.kairos.software-version-prefix="${SOFTWARE_VERSION_PREFIX}"
LABEL io.kairos.targetarch="${TARGETARCH}"

# not duplicated but used to see the error
RUN kairos-agent versioneer os-release-variables
RUN kairos-agent versioneer os-release-variables >> /etc/os-release
# not duplicated but used to see the error
RUN kairos-agent versioneer container-artifact-name
RUN kairos-agent versioneer os-release-variables > /etc/kairos-release
Itxaka marked this conversation as resolved.
Show resolved Hide resolved
RUN kairos-agent versioneer container-artifact-name > /IMAGE

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
Expand Down
8 changes: 2 additions & 6 deletions images/Dockerfile.kairos-alpine
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ RUN rm -rf /etc/ssh/ssh_host_*

COPY which-init.sh /usr/local/bin/which-init.sh

RUN sed -i -n '/KAIROS_/!p' /etc/os-release
RUN if [ -f "/etc/kairos-release" ]; then sed -i -n '/KAIROS_/!p' /etc/kairos-release; fi

# need to be defined after FROM for them to be replaced in the RUN bellow
ARG HOME_URL="https://github.com/kairos-io/kairos"
Expand Down Expand Up @@ -223,11 +223,7 @@ LABEL io.kairos.software-version="${SOFTWARE_VERSION}"
LABEL io.kairos.software-version-prefix="${SOFTWARE_VERSION_PREFIX}"
LABEL io.kairos.targetarch="${TARGETARCH}"

# not duplicated but used to see the error
RUN kairos-agent versioneer os-release-variables
RUN kairos-agent versioneer os-release-variables >> /etc/os-release
# not duplicated but used to see the error
RUN kairos-agent versioneer container-artifact-name
RUN kairos-agent versioneer os-release-variables > /etc/kairos-release
RUN kairos-agent versioneer container-artifact-name > /IMAGE

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
Expand Down
8 changes: 2 additions & 6 deletions images/Dockerfile.kairos-debian
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ RUN rm -rf /etc/ssh/ssh_host_*

COPY which-init.sh /usr/local/bin/which-init.sh

RUN sed -i -n '/KAIROS_/!p' /etc/os-release
RUN if [ -f "/etc/kairos-release" ]; then sed -i -n '/KAIROS_/!p' /etc/kairos-release; fi

# need to be defined after FROM for them to be replaced in the RUN bellow
ARG HOME_URL="https://github.com/kairos-io/kairos"
Expand Down Expand Up @@ -237,11 +237,7 @@ LABEL io.kairos.software-version="${SOFTWARE_VERSION}"
LABEL io.kairos.software-version-prefix="${SOFTWARE_VERSION_PREFIX}"
LABEL io.kairos.targetarch="${TARGETARCH}"

# not duplicated but used to see the error
RUN kairos-agent versioneer os-release-variables
RUN kairos-agent versioneer os-release-variables >> /etc/os-release
# not duplicated but used to see the error
RUN kairos-agent versioneer container-artifact-name
RUN kairos-agent versioneer os-release-variables > /etc/kairos-release
RUN kairos-agent versioneer container-artifact-name > /IMAGE

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
Expand Down
8 changes: 2 additions & 6 deletions images/Dockerfile.kairos-opensuse
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ RUN rm -rf /etc/ssh/ssh_host_*

COPY which-init.sh /usr/local/bin/which-init.sh

RUN sed -i -n '/KAIROS_/!p' /etc/os-release
RUN if [ -f "/etc/kairos-release" ]; then sed -i -n '/KAIROS_/!p' /etc/kairos-release; fi

# need to be defined after FROM for them to be replaced in the RUN bellow
ARG HOME_URL="https://github.com/kairos-io/kairos"
Expand Down Expand Up @@ -233,11 +233,7 @@ LABEL io.kairos.software-version="${SOFTWARE_VERSION}"
LABEL io.kairos.software-version-prefix="${SOFTWARE_VERSION_PREFIX}"
LABEL io.kairos.targetarch="${TARGETARCH}"

# not duplicated but used to see the error
RUN kairos-agent versioneer os-release-variables
RUN kairos-agent versioneer os-release-variables >> /etc/os-release
# not duplicated but used to see the error
RUN kairos-agent versioneer container-artifact-name
RUN kairos-agent versioneer os-release-variables > /etc/kairos-release
RUN kairos-agent versioneer container-artifact-name > /IMAGE

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
Expand Down
8 changes: 2 additions & 6 deletions images/Dockerfile.kairos-rhel
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ RUN rm -rf /etc/ssh/ssh_host_*

COPY which-init.sh /usr/local/bin/which-init.sh

RUN sed -i -n '/KAIROS_/!p' /etc/os-release
RUN if [ -f "/etc/kairos-release" ]; then sed -i -n '/KAIROS_/!p' /etc/kairos-release; fi

# need to be defined after FROM for them to be replaced in the RUN bellow
ARG HOME_URL="https://github.com/kairos-io/kairos"
Expand Down Expand Up @@ -172,11 +172,7 @@ LABEL io.kairos.software-version="${SOFTWARE_VERSION}"
LABEL io.kairos.software-version-prefix="${SOFTWARE_VERSION_PREFIX}"
LABEL io.kairos.targetarch="${TARGETARCH}"

# not duplicated but used to see the error
RUN kairos-agent versioneer os-release-variables
RUN kairos-agent versioneer os-release-variables >> /etc/os-release
# not duplicated but used to see the error
RUN kairos-agent versioneer container-artifact-name
RUN kairos-agent versioneer os-release-variables > /etc/kairos-release
RUN kairos-agent versioneer container-artifact-name > /IMAGE

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
Expand Down
8 changes: 2 additions & 6 deletions images/Dockerfile.kairos-ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ RUN rm -rf /etc/ssh/ssh_host_*

COPY which-init.sh /usr/local/bin/which-init.sh

RUN sed -i -n '/KAIROS_/!p' /etc/os-release
RUN if [ -f "/etc/kairos-release" ]; then sed -i -n '/KAIROS_/!p' /etc/kairos-release; fi

# need to be defined after FROM for them to be replaced in the RUN bellow
ARG HOME_URL="https://github.com/kairos-io/kairos"
Expand Down Expand Up @@ -438,11 +438,7 @@ LABEL io.kairos.software-version="${SOFTWARE_VERSION}"
LABEL io.kairos.software-version-prefix="${SOFTWARE_VERSION_PREFIX}"
LABEL io.kairos.targetarch="${TARGETARCH}"

# not duplicated but used to see the error
RUN kairos-agent versioneer os-release-variables
RUN kairos-agent versioneer os-release-variables >> /etc/os-release
# not duplicated but used to see the error
RUN kairos-agent versioneer container-artifact-name
RUN kairos-agent versioneer os-release-variables > /etc/kairos-release
RUN kairos-agent versioneer container-artifact-name > /IMAGE

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
Expand Down
4 changes: 2 additions & 2 deletions tests/bundles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ var _ = Describe("kairos bundles test", Label("bundles-test"), func() {
}, 3*time.Minute, 10*time.Second).Should(ContainSubstring("kubo"), func() string {
// Debug output in case of an error
result := ""
out, _ := vm.Sudo("cat /etc/os-release")
result = result + fmt.Sprintf("os-release:\n%s\n", out)
out, _ := vm.Sudo("cat /etc/kairos-release")
result = result + fmt.Sprintf("kairos-release:\n%s\n", out)

out, _ = vm.Sudo("cat /oem/90_custom.yaml")
result = result + fmt.Sprintf("90_custom.yaml:\n%s\n", out)
Expand Down
2 changes: 1 addition & 1 deletion tests/provider_decentralized_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ var _ = Describe("kairos decentralized k8s test", Label("provider", "provider-de
})

vmForEach("checking if it upgrades to a specific version", vms, func(vm VM) {
version, err := vm.Sudo("source /etc/os-release; echo $VERSION")
version, err := vm.Sudo(getVersionCmd)
Expect(err).ToNot(HaveOccurred(), version)

out, err := vm.Sudo("kairos-agent upgrade --image quay.io/kairos/kairos-opensuse:v1.0.0-rc2-k3sv1.21.14-k3s1")
Expand Down
2 changes: 1 addition & 1 deletion tests/tests_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestSuite(t *testing.T) {
RunSpecs(t, "kairos Test Suite")
}

var getVersionCmd = ". /etc/os-release; [ ! -z \"$KAIROS_VERSION\" ] && echo $KAIROS_VERSION || echo $VERSION"
var getVersionCmd = ". /etc/kairos-release; [ ! -z \"$KAIROS_VERSION\" ] && echo $KAIROS_VERSION"

// https://gist.github.com/sevkin/96bdae9274465b2d09191384f86ef39d
// GetFreePort asks the kernel for a free open port that is ready to use.
Expand Down
2 changes: 1 addition & 1 deletion tests/uki_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ var _ = Describe("kairos UKI test", Label("uki"), Ordered, func() {
vm.EventuallyConnects(1200)

By("checking if upgrade worked")
out, err = vm.Sudo("cat /etc/os-release")
out, err = vm.Sudo("cat /etc/kairos-release")
Expect(err).ToNot(HaveOccurred(), out)
Expect(out).To(MatchRegexp(fmt.Sprintf("KAIROS_VERSION=\"?%s\"?", os.Getenv("EXPECTED_NEW_VERSION"))))

Expand Down
9 changes: 8 additions & 1 deletion tests/upgrade_latest_cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,15 @@ var _ = Describe("k3s upgrade manual test", Label("upgrade-latest-with-cli"), fu
})

It("can upgrade to current image", func() {
var currentVersion string
currentVersion, err := vm.Sudo(getVersionCmd)
Expect(err).ToNot(HaveOccurred())
// Upgrade test uses old version the upgrades to newer so test needs to get the version from os-release for now as
// fallback
if err != nil || currentVersion == "" {
currentVersion, err = vm.Sudo(". /etc/os-release; [ ! -z \"$KAIROS_VERSION\" ] && echo $KAIROS_VERSION")
Expect(err).ToNot(HaveOccurred())
}

By(fmt.Sprintf("Checking current version: %s", currentVersion))
Expect(currentVersion).To(ContainSubstring("v"))

Expand Down
Loading