cloudapi: enable edge-commit on Fedora

We have to do a small hack to enable edge-commit on Fedora because its name
is different. We can also change this in the image definition but I want to
iterate quickly on the Fedora Integration MVP and don't want to run in
any conflicts with
https://github.com/osbuild/osbuild-composer/pull/2461

This commit also enables a test for Fedora IoT built through the API.

While enabling the test, I also simplified our decision logic for SSH_USER
and DISTRO.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
Ondřej Budai 2022-03-24 09:16:48 +01:00 committed by Ondřej Budai
parent bf46113251
commit 80af9cac98
3 changed files with 28 additions and 44 deletions

View file

@ -392,6 +392,9 @@ API:
- aws/rhel-8.6-nightly-x86_64
- aws/rhel-9.0-nightly-x86_64
INTERNAL_NETWORK: ["true"]
- IMAGE_TYPE: ["edge-commit"]
RUNNER:
- aws/fedora-35-x86_64
libvirt:
stage: test

View file

@ -279,7 +279,7 @@ func (h *apiHandlers) PostCompose(ctx echo.Context) error {
if err != nil {
return HTTPError(ErrorUnsupportedArchitecture)
}
imageType, err := arch.GetImageType(imageTypeFromApiImageType(ir.ImageType))
imageType, err := arch.GetImageType(imageTypeFromApiImageType(ir.ImageType, arch))
if err != nil {
return HTTPError(ErrorUnsupportedImageType)
}
@ -715,7 +715,7 @@ func generateManifest(ctx context.Context, cancel context.CancelFunc, workers *w
jobResult.Manifest = manifest
}
func imageTypeFromApiImageType(it ImageTypes) string {
func imageTypeFromApiImageType(it ImageTypes, arch distro.Arch) string {
switch it {
case ImageTypesAws:
return "ami"
@ -738,6 +738,13 @@ func imageTypeFromApiImageType(it ImageTypes) string {
case ImageTypesImageInstaller:
return "image-installer"
case ImageTypesEdgeCommit:
// Fedora doesn't define "rhel-edge-commit", or "edge-commit" yet.
// Assume that if the distro contains "fedora-iot-commit", it's Fedora
// and translate ImageTypesEdgeCommit to fedora-iot-commit in this case.
// This should definitely be removed in the near future.
if _, err := arch.GetImageType("fedora-iot-commit"); err == nil {
return "fedora-iot-commit"
}
return "rhel-edge-commit"
case ImageTypesEdgeContainer:
return "rhel-edge-container"

View file

@ -458,48 +458,22 @@ else
TEST_ID=$(uuidgen);
fi
case "$ID-$VERSION_ID" in
"rhel-9.0")
DISTRO="rhel-90"
if [[ "$CLOUD_PROVIDER" == "$CLOUD_PROVIDER_AWS" ]]; then
SSH_USER="ec2-user"
else
SSH_USER="cloud-user"
fi
;;
"rhel-8.6")
DISTRO="rhel-86"
if [[ "$CLOUD_PROVIDER" == "$CLOUD_PROVIDER_AWS" ]]; then
SSH_USER="ec2-user"
else
SSH_USER="cloud-user"
fi
;;
"rhel-8.5")
DISTRO="rhel-85"
if [[ "$CLOUD_PROVIDER" == "$CLOUD_PROVIDER_AWS" ]]; then
SSH_USER="ec2-user"
else
SSH_USER="cloud-user"
fi
;;
"centos-8")
DISTRO="centos-8"
if [[ "$CLOUD_PROVIDER" == "$CLOUD_PROVIDER_AWS" ]]; then
SSH_USER="ec2-user"
else
SSH_USER="cloud-user"
fi
;;
"centos-9")
DISTRO="centos-9"
if [[ "$CLOUD_PROVIDER" == "$CLOUD_PROVIDER_AWS" ]]; then
SSH_USER="ec2-user"
else
SSH_USER="cloud-user"
fi
;;
esac
if [[ "$ID" == "fedora" ]]; then
# fedora uses fedora for everything
SSH_USER="fedora"
elif [[ "$CLOUD_PROVIDER" == "$CLOUD_PROVIDER_AWS" ]]; then
# RHEL and centos use ec2-user for AWS
SSH_USER="ec2-user"
else
# RHEL and centos use cloud-user for other clouds
SSH_USER="cloud-user"
fi
# This removes dot from VERSION_ID.
# ID == rhel && VERSION_ID == 8.6 => DISTRO == rhel-86
# ID == centos && VERSION_ID == 8 => DISTRO == centos-8
# ID == fedora && VERSION_ID == 35 => DISTRO == fedora-35
DISTRO="$ID-${VERSION_ID//./}"
# Only RHEL need subscription block.
if [[ "$ID" == "rhel" ]]; then