From b3f4d7569901cf062dc2a39d021c54ad36953aef Mon Sep 17 00:00:00 2001 From: Achilleas Koutsou Date: Fri, 25 Nov 2022 16:20:56 +0100 Subject: [PATCH] image: panic if unknown compression option is specified Currently we only support "xz", but keeping it as a `switch` to easily support more types in the future. The empty string is also supported as a no-op. --- internal/image/live.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/image/live.go b/internal/image/live.go index a9e873e98..e42e752ac 100644 --- a/internal/image/live.go +++ b/internal/image/live.go @@ -1,6 +1,7 @@ package image import ( + "fmt" "math/rand" "github.com/osbuild/osbuild-composer/internal/artifact" @@ -99,6 +100,11 @@ func (img *LiveImage) InstantiateManifest(m *manifest.Manifest, xzPipeline := manifest.NewXZ(m, buildPipeline, artifactPipeline) xzPipeline.Filename = img.Filename artifact = xzPipeline.Export() + case "": + // do nothing + default: + // panic on unknown strings + panic(fmt.Sprintf("unsupported compression type %q", img.Compression)) } return artifact, nil