From 9f2f5b5ce79d2ad29826860e444d53819f3376d1 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Sun, 29 Jan 2023 09:41:16 +0100 Subject: [PATCH] pkg/utils: Be more strict about what is acceptable https://github.com/containers/toolbox/issues/1065 --- src/pkg/utils/utils.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/pkg/utils/utils.go b/src/pkg/utils/utils.go index fafae4f74..1931aff5c 100644 --- a/src/pkg/utils/utils.go +++ b/src/pkg/utils/utils.go @@ -1,5 +1,5 @@ /* - * Copyright © 2019 – 2022 Red Hat Inc. + * Copyright © 2019 – 2023 Red Hat Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -292,6 +292,19 @@ func GetEnvOptionsForPreservedVariables() []string { func GetFullyQualifiedImageFromDistros(image, release string) (string, error) { logrus.Debugf("Resolving fully qualified name for image %s from known registries", image) + if image == "" { + panic("image not specified") + } + + if release == "" { + panic("release not specified") + } + + if tag := ImageReferenceGetTag(image); tag != "" && release != tag { + panicMsg := fmt.Sprintf("image %s does not match release %s", image, release) + panic(panicMsg) + } + if ImageReferenceHasDomain(image) { return image, nil }