Skip to content

Commit

Permalink
Add a kola verb
Browse files Browse the repository at this point in the history
This is the first place we're wrapping mantle via our
main entrypoint, and hopefully we'll increase that.

Example usage: `coreos-assembler kola run rhcos.basic`.

Requires: coreos/mantle#920
  • Loading branch information
cgwalters authored and jlebon committed May 28, 2019
1 parent de8f556 commit 5571445
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 5 deletions.
27 changes: 27 additions & 0 deletions src/cmd-kola
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -euo pipefail

dn=$(dirname $0)
. ${dn}/cmdlib.sh

latest_qcow=$(get_latest_qemu)
if [ -z "${latest_qcow}" ]; then
fatal "No latest build"
fi

# XXX: teach to kola
distro=
bn=$(basename "${latest_qcow}")
if [[ ${bn} = fedora-coreos-* ]]; then
distro="-b fcos"
elif [[ ${bn} = rhcos-* ]]; then
distro="-b rhcos --ignition-version v2"
else
echo "WARNING: Failed to detect distro, use -b to specify"
fi

# let's print out the actual exec() call we do
set -x

# shellcheck disable=SC2086
exec sudo kola $distro --output-dir tmp/kola --qemu-image "${latest_qcow}" "$@"
6 changes: 2 additions & 4 deletions src/cmd-run
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@ done
preflight

if [ -z "${VM_DISK}" ]; then
if [ -L ./builds/latest ]; then
latest_build=$(readlink builds/latest)
VM_DISK=$(ls builds/"${latest_build}"/*-"${latest_build}"-qemu.qcow2)
else
VM_DISK=$(get_latest_qemu)
if [ -z "${VM_DISK}" ]; then
die "No builds/latest, and no -d argument provided"
fi
fi
Expand Down
15 changes: 15 additions & 0 deletions src/cmdlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -515,3 +515,18 @@ run_virtinstall() {
--ostree-repo="${ostree_repo}" "$@"
mv "${tmpdest}" "${dest}"
}

get_latest_build() {
if [ -L builds/latest ]; then
readlink builds/latest
fi
}

get_latest_qemu() {
local latest
latest=$(get_latest_build)
if [ -n "$latest" ]; then
# shellcheck disable=SC2086
ls builds/${latest}/*-qemu.qcow2
fi
}
2 changes: 1 addition & 1 deletion src/coreos-assembler
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ build_commands="init fetch build run prune clean"
# commands more likely to be used in a prod pipeline only
advanced_build_commands="buildprep oscontainer"
buildextend_commands="aws gcp openstack installer vmware metal"
utility_commands="tag compress bump-timestamp koji-upload"
utility_commands="tag compress bump-timestamp koji-upload kola"
other_commands="shell"
if [ -z "${cmd}" ]; then
echo Usage: "coreos-assembler CMD ..."
Expand Down

0 comments on commit 5571445

Please sign in to comment.