Skip to content

Commit

Permalink
pkg/utils: Be more strict about what is acceptable
Browse files Browse the repository at this point in the history
  • Loading branch information
debarshiray committed Jan 29, 2023
1 parent ca8007c commit 9f2f5b5
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/pkg/utils/utils.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 9f2f5b5

Please sign in to comment.