refactor!: Rename template to generate and move rebase/upgrade under switch (#116)

This updates the `template` subcommand to be `generate`. The `template`
usage will continue to work as an alias to `generate`. A new `switch`
command is added that will manage both `rpm-ostree rebase` and
`rpm-ostree upgrade` and is fully replacing the respective subcommands
as a breaking change.

The new `switch` command is under the feature flag `switch` and will
currently only build for the `main` branch builds until it is moved as a
default feature (`v0.9.0`).

Closes #159
This commit is contained in:
Gerald Pinder 2024-05-26 22:47:34 -04:00 committed by GitHub
parent 968cf3db97
commit 02b2fe5434
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 672 additions and 62 deletions

View file

@ -8,6 +8,7 @@ all:
BUILD +build
BUILD +rebase
BUILD +upgrade
BUILD +switch
test-image:
FROM +build-template --src=template-containerfile
@ -45,7 +46,7 @@ build-template:
template-containerfile:
FROM +test-base
RUN bluebuild -vv template recipes/recipe.yml | tee Containerfile
RUN bluebuild -vv generate recipes/recipe.yml | tee Containerfile
SAVE ARTIFACT /test
@ -57,13 +58,13 @@ template-legacy-containerfile:
template-secureblue:
FROM +secureblue-base
RUN bluebuild -vv template -o Containerfile recipes/general/recipe-silverblue-nvidia.yml
RUN bluebuild -vv generate -o Containerfile recipes/general/recipe-silverblue-nvidia.yml
SAVE ARTIFACT /test
template-secureblue-ucore:
FROM +secureblue-base
RUN bluebuild -vv template -o Containerfile recipes/server/recipe-server-main.yml
RUN bluebuild -vv generate -o Containerfile recipes/server/recipe-server-main.yml
SAVE ARTIFACT /test
@ -73,15 +74,21 @@ build:
RUN bluebuild -vv build recipes/recipe.yml
rebase:
FROM +test-base
FROM +legacy-base
RUN bluebuild -vv rebase recipes/recipe.yml
RUN bluebuild -vv rebase config/recipe.yml
upgrade:
FROM +legacy-base
RUN mkdir -p /etc/bluebuild && touch $BB_TEST_LOCAL_IMAGE
RUN bluebuild -vv upgrade config/recipe.yml
switch:
FROM +test-base
RUN mkdir -p /etc/bluebuild && touch $BB_TEST_LOCAL_IMAGE
RUN bluebuild -vv upgrade recipes/recipe.yml
RUN bluebuild -vv switch recipes/recipe.yml
secureblue-base:
FROM +test-base
@ -93,7 +100,8 @@ secureblue-base:
legacy-base:
FROM ../+blue-build-cli-alpine
ENV BB_TEST_LOCAL_IMAGE=/etc/bluebuild/cli_test.tar.gz
RUN apk update --no-cache && apk add bash grep jq sudo coreutils
ENV BB_TEST_LOCAL_IMAGE=/etc/bluebuild/cli_test-legacy.tar.gz
ENV CLICOLOR_FORCE=1
COPY ./mock-scripts/ /usr/bin/
@ -107,6 +115,7 @@ legacy-base:
test-base:
FROM ../+blue-build-cli-alpine
RUN apk update --no-cache && apk add bash grep jq sudo coreutils
ENV BB_TEST_LOCAL_IMAGE=/etc/bluebuild/cli_test.tar.gz
ENV CLICOLOR_FORCE=1

View file

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
print_version_json() {
local version="1.24.0"
@ -8,6 +8,11 @@ print_version_json() {
main() {
if [[ "$1" == "version" && "$2" == "--json" ]]; then
print_version_json
elif [[ "$1" == "build" && "$6" == *"cli_test.tar.gz" ]]; then
tarpath=$(echo "$6" | awk -F ':' '{print $2}')
echo "Exporting image to a tarball (JK JUST A MOCK!)"
echo "${tarpath}"
touch $tarpath
else
echo 'Running buildah'
fi

View file

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
print_version_json() {
local version="4.0.0"
@ -8,6 +8,11 @@ print_version_json() {
main() {
if [[ "$1" == "version" && "$2" == "-f" && "$3" == "json" ]]; then
print_version_json
elif [[ "$1" == "build" && "$6" == *"cli_test.tar.gz" ]]; then
tarpath=$(echo "$6" | awk -F ':' '{print $2}')
echo "Exporting image to a tarball (JK JUST A MOCK!)"
echo "${tarpath}"
touch $tarpath
else
echo 'Running podman'
fi

View file

@ -1,9 +1,7 @@
#!/bin/sh
#!/bin/bash
set -euo pipefail
echo 'Running rpm-ostree'
if [ "$1" = "rebase" ]; then
if [ "$2" = "ostree-unverified-image:oci-archive:$BB_TEST_LOCAL_IMAGE" ]; then
echo "Rebased to local image $BB_TEST_LOCAL_IMAGE"
@ -13,6 +11,23 @@ if [ "$1" = "rebase" ]; then
fi
elif [ "$1" = "upgrade" ]; then
echo "Performing upgrade for $BB_TEST_LOCAL_IMAGE"
elif [ "$1" = "status" ]; then
cat <<EOF
{
"deployments": [
{
"container-image-reference": "ostree-image-signed:docker://ghcr.io/blue-build/cli/test",
"booted": true,
"staged": false
},
{
"container-image-reference": "ostree-image-signed:docker://ghcr.io/blue-build/cli/test:last",
"booted": false,
"staged": false
}
]
}
EOF
else
echo "Arg $1 is not recognized"
exit 1