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

registryurl: remove fallback code for go < 1.8 #225

Merged
merged 2 commits into from Aug 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions osxkeychain/osxkeychain_darwin.go
Expand Up @@ -138,7 +138,7 @@ func (h Osxkeychain) List() (map[string]string, error) {
listLen = int(listLenC)
pathTmp := (*[1 << 30]*C.char)(unsafe.Pointer(pathsC))[:listLen:listLen]
acctTmp := (*[1 << 30]*C.char)(unsafe.Pointer(acctsC))[:listLen:listLen]
//taking the array of c strings into go while ignoring all the stuff irrelevant to credentials-helper
// taking the array of c strings into go while ignoring all the stuff irrelevant to credentials-helper
resp := make(map[string]string)
for i := 0; i < listLen; i++ {
if C.GoString(pathTmp[i]) == "0" {
Expand All @@ -160,7 +160,7 @@ func splitServer(serverURL string) (*C.struct_Server, error) {
proto = C.kSecProtocolTypeHTTP
}
var port int
p := registryurl.GetPort(u)
p := u.Port()
if p != "" {
port, err = strconv.Atoi(p)
if err != nil {
Expand All @@ -170,7 +170,7 @@ func splitServer(serverURL string) (*C.struct_Server, error) {

return &C.struct_Server{
proto: C.SecProtocolType(proto),
host: C.CString(registryurl.GetHostname(u)),
host: C.CString(u.Hostname()),
port: C.uint(port),
path: C.CString(u.Path),
}, nil
Expand Down
16 changes: 15 additions & 1 deletion registryurl/parse.go
Expand Up @@ -28,10 +28,24 @@ func Parse(registryURL string) (*url.URL, error) {
return nil, errors.New("unsupported scheme: " + u.Scheme)
}

if GetHostname(u) == "" {
if u.Hostname() == "" {
return nil, errors.New("no hostname in URL")
}

u.RawQuery = ""
return u, nil
}

// GetHostname returns the hostname of the URL
//
// Deprecated: use url.Hostname()
func GetHostname(u *url.URL) string {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, let me drop internal uses of this function

return u.Hostname()
}

// GetPort returns the port number of the URL
//
// Deprecated: use url.Port()
func GetPort(u *url.URL) string {
return u.Port()
}
17 changes: 0 additions & 17 deletions registryurl/url_go18.go

This file was deleted.

41 changes: 0 additions & 41 deletions registryurl/url_non_go18.go

This file was deleted.