-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[BZ1365986] new-app: validate that EXPOSEd ports are numbers #10677
[BZ1365986] new-app: validate that EXPOSEd ports are numbers #10677
Conversation
@@ -502,6 +503,11 @@ func AddMissingComponentsToRefBuilder( | |||
errs = append(errs, fmt.Errorf("the Dockerfile in the repository %q has no FROM instruction", info.Path)) | |||
continue | |||
} | |||
err := exposedPortsAreNumeric(dockerfileutil.LastExposedPorts(node)) | |||
if err != nil { | |||
errs = append(errs, fmt.Errorf("the Dockerfile in the repository has invalid EXPOSE instruction: %v", err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/the Dockerfile in the repository/the Dockerfile/
s/has invalid/has an invalid/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
5a0c070
to
ff9fc69
Compare
if err != nil { | ||
errs = append(errs, fmt.Errorf("the Dockerfile has an invalid EXPOSE instruction: %v", err)) | ||
continue | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm wondering if this is the right place for this check. is this also going to cause "oc new-build" to fail w/ these dockerfiles? because it probably shouldn't.
it should only be an error in cases where we're trying to generate a service(which is why we need to know what ports the dockerfile exposes).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this also going to cause "oc new-build" to fail w/ these dockerfiles?
Yes, it will :-(
(oc new-app
and oc new-build
looks very similar. Do they duplicate each other?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they use the same code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you just need to move the check to where we're creating the service.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, will do. (In September.)
ff9fc69
to
3443ea6
Compare
@bparees PTAL again. Because new-app and new-build both use |
3443ea6
to
dcc2955
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one nit and i'd like to see tests for both the new-app and new-build codepaths.
func exposedPortsAreNumeric(node *dockerfileparser.Node) error { | ||
for _, port := range dockerfileutil.LastExposedPorts(node) { | ||
if _, err := strconv.ParseInt(port, 10, 32); err != nil { | ||
return fmt.Errorf("could not parse %q: must be numerical", port) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/numerical/numeric/
dcc2955
to
80e16ec
Compare
@bparees PTAL again. |
lgtm [merge] |
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/10739/) (Image: devenv-rhel7_5263) |
Evaluated for origin merge up to 80e16ec |
[Test]ing while waiting on the merge queue |
[test] flake #9548 |
Evaluated for origin test up to 80e16ec |
continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/10739/) (Base Commit: 9f85202) |
Add validation to
oc new-app
to ensure that exposed ports from theDockerfile
in a user's repository are numbers.Example:
At the same time
oc new-build
works as before:PTAL @bparees
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1365986