Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions pkg/types/validation/installconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,9 +566,14 @@ func validateNamedRepository(r string) error {
// in an error. Instead we will check whether the input is
// a valid hostname as a workaround.
if err == dockerref.ErrNameNotCanonical {
_, err := url.ParseRequestURI(r)
// If the hostname string contains a port, lets attempt
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit

Suggested change
// If the hostname string contains a port, lets attempt
// If the hostname string contains a port, let's attempt

// to split them
host, _, err := net.SplitHostPort(r)
if err != nil {
return fmt.Errorf("the repository provided is invalid")
host = r
Comment thread
kirankt marked this conversation as resolved.
Outdated
}
if err = validate.Host(host); err != nil {
return errors.Wrap(err, "the repository provided is invalid")
}
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/types/validation/installconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,7 @@ func TestValidateInstallConfig(t *testing.T) {
}}
return c
}(),
expectedError: `^imageContentSources\[0\]\.source: Invalid value: "ocp/release-x\.y": the repository provided is invalid$`,
expectedError: `^imageContentSources\[0\]\.source: Invalid value: "ocp/release-x\.y": the repository provided is invalid: a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, \'\-\' or \'\.\', and must start and end with an alphanumeric character \(e.g. \'example\.com\', regex used for validation is \'\[a\-z0\-9\]\(\[\-a\-z0\-9\]\*\[a\-z0\-9\]\)\?\(\\\.\[a\-z0\-9\]\(\[\-a\-z0\-9\]\*\[a\-z0\-9\]\)\?\)\*\'\)`,
},
{
name: "release image source's mirror is not valid",
Expand All @@ -1104,7 +1104,7 @@ func TestValidateInstallConfig(t *testing.T) {
}}
return c
}(),
expectedError: `^imageContentSources\[0\]\.mirrors\[0\]: Invalid value: "ocp/openshift-x.y": the repository provided is invalid$`,
expectedError: `^imageContentSources\[0\]\.mirrors\[0\]: Invalid value: "ocp/openshift-x\.y": the repository provided is invalid: a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, \'\-\' or \'\.\', and must start and end with an alphanumeric character \(e.g. \'example\.com\', regex used for validation is \'\[a\-z0\-9\]\(\[\-a\-z0\-9\]\*\[a\-z0\-9\]\)\?\(\\\.\[a\-z0\-9\]\(\[\-a\-z0\-9\]\*\[a\-z0\-9\]\)\?\)\*\'\)`,
},
{
name: "release image source's mirror is valid",
Expand Down