From 7bf02771750dc7a48b752d05d04d2a45353a1845 Mon Sep 17 00:00:00 2001 From: Achilleas Koutsou Date: Wed, 24 Aug 2022 15:04:48 +0200 Subject: [PATCH] gen-manifests: don't fail on invalid distro-arch-image combos When the user specifies any of the distro, arch, or image type values to filter generation, invalid combinations would cause a panic, which made it hard to filter requests based just on an image type. Instead of failing, print an error message to inform the user, but continue with the rest of the jobs. This way, a user is informed that a certain combination is invalid if they make a mistake, but can also filter on a single image type and only get valid manifests out of the run. --- cmd/gen-manifests/main.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cmd/gen-manifests/main.go b/cmd/gen-manifests/main.go index c584b50d6..d049b647e 100644 --- a/cmd/gen-manifests/main.go +++ b/cmd/gen-manifests/main.go @@ -379,7 +379,8 @@ func main() { for _, distroName := range distros { distribution := distroReg.GetDistro(distroName) if distribution == nil { - panic(fmt.Sprintf("invalid distro name %q\n", distroName)) + fmt.Fprintf(os.Stderr, "invalid distro name %q\n", distroName) + continue } distroArches := arches @@ -389,7 +390,8 @@ func main() { for _, archName := range distroArches { arch, err := distribution.GetArch(archName) if err != nil { - panic(fmt.Sprintf("invalid arch name %q for distro %q: %s", archName, distroName, err.Error())) + fmt.Fprintf(os.Stderr, "invalid arch name %q for distro %q: %s\n", archName, distroName, err.Error()) + continue } daImgTypes := imgTypes @@ -399,7 +401,8 @@ func main() { for _, imgTypeName := range daImgTypes { imgType, err := arch.GetImageType(imgTypeName) if err != nil { - panic(fmt.Sprintf("invalid image type %q for distro %q and arch %q: %s", imgTypeName, distroName, archName, err.Error())) + fmt.Fprintf(os.Stderr, "invalid image type %q for distro %q and arch %q: %s\n", imgTypeName, distroName, archName, err.Error()) + continue } // get repositories