Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

breaking change: include sanitized hostname in offline registry path #562

16 changes: 10 additions & 6 deletions src/internal/utils/image.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package utils

import "regexp"
import (
"regexp"

// For further explanation see https://regex101.com/library/PiL191 and https://regex101.com/r/PiL191/1
var hostParser = regexp.MustCompile(`(?im)^([a-z0-9\-.]+\.[a-z0-9\-]+:?[0-9]*)?/?(.+)$`)
"github.com/defenseunicorns/zarf/src/internal/message"
)

// For further explanation see https://regex101.com/r/DzfGag/1
var hostParser = regexp.MustCompile(`(?im)^(.*):(.*/.*)`)

// SwapHost Perform base url replacment without the docker libs
func SwapHost(src string, targetHost string) string {
var substitution = targetHost + "/$2"
return hostParser.ReplaceAllString(src, substitution)
func SwapHost(src, targetHost string) string {
message.Debugf("images.SwapHost(%s, %s)", src, targetHost)
return hostParser.ReplaceAllString(src, targetHost+"/$1.$2")
}