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

Add a kola verb #85

Merged
merged 1 commit into from
May 29, 2019
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
29 changes: 29 additions & 0 deletions src/cmd-kola
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -euo pipefail

dn=$(dirname "$0")
# shellcheck source=src/cmdlib.sh
. "${dn}"/cmdlib.sh

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

# XXX: teach to kola to auto-detect based on prefix; see discussions in
# https://github.com/coreos/coreos-assembler/pull/85
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 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not anything we need to do here but FYI if you have run cosa compress this will fail.

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