You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// the URL parser treat hostname as either path or opaque if scheme is not specified, so hostname must be empty
returnerr==nil&&parsed.Host==""
}
I wrote myself a little test:
package main
import (
"fmt"
"net/url"
)
func IsHelmOciRepo(repoURL string) bool {
if repoURL == "" {
return false
}
parsed, err := url.Parse(repoURL)
// the URL parser treat hostname as either path or opaque if scheme is not specified, so hostname must be empty
return err == nil && parsed.Host == ""
}
func main() {
fmt.Println(IsHelmOciRepo("192.168.100.150:1843"))
}
The result is false.
We should add a condition which allows pure IPs with optional Ports like
func IsHelmOciRepo(repoURL string) bool {
if net.ParseIP(repoURL) != nil {
return true
}
host, port, err := net.SplitHostPort(repoURL)
if net.ParseIP(host) != nil {
if p, err := strconv.Atoi(port); err == nil && p > 0 && p < 65536 {
return true
}
}
if repoURL == "" {
return false
}
parsed, err := url.Parse(repoURL)
// the URL parser treat hostname as either path or opaque if scheme is not specified, so hostname must be empty
return err == nil && parsed.Host == ""
}
Discussed in #15876
Originally posted by lovesharepc October 9, 2023
my registry server is harbor with port 1843
when use command
get error message
how do I solve this ?
The text was updated successfully, but these errors were encountered: