1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00

parsing the entire url and not spliting it (#3775)

Co-authored-by: anilkeshav27 <you@example.com>
This commit is contained in:
Anil Keshav 2022-05-13 10:02:46 +02:00 committed by GitHub
parent 7d9f018529
commit b7cc1eb62f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"os"
"path"
"path/filepath"
"regexp"
"strings"
@ -194,14 +195,15 @@ func (c *Client) GetRemoteImageInfo(imageSource string) (v1.Image, error) {
func (c *Client) getImageRef(image string) (name.Reference, error) {
opts := []name.Option{}
registry := ""
if len(c.registryURL) > 0 {
re := regexp.MustCompile(`(?i)^https?://`)
registry := re.ReplaceAllString(c.registryURL, "")
registry = re.ReplaceAllString(c.registryURL, "")
opts = append(opts, name.WithDefaultRegistry(registry))
}
return name.ParseReference(image, opts...)
return name.ParseReference(path.Join(registry, image), opts...)
}
// ImageListWithFilePath compiles container image names based on all Dockerfiles found, considering excludes