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

Fixes the issue of url creation for same component when no name is provided #1061

Merged
merged 4 commits into from Dec 7, 2018

Conversation

mik-dass
Copy link
Contributor

@mik-dass mik-dass commented Dec 3, 2018

fixes #1040

It introduces a new function GetValidPortNumber() to check and return the valid port of the component.

@codeclimate
Copy link

codeclimate bot commented Dec 3, 2018

Code Climate has analyzed commit 7c94a4c and detected 0 issues on this pull request.

View more on Code Climate.

@mik-dass mik-dass force-pushed the url_multiple_ports branch 2 times, most recently from 009e356 to d65c429 Compare December 3, 2018 13:16
@codecov
Copy link

codecov bot commented Dec 3, 2018

Codecov Report

Merging #1061 into master will decrease coverage by 0.06%.
The diff coverage is 57.14%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1061      +/-   ##
==========================================
- Coverage   41.53%   41.46%   -0.07%     
==========================================
  Files          30       30              
  Lines        4081     4085       +4     
==========================================
- Hits         1695     1694       -1     
- Misses       2212     2218       +6     
+ Partials      174      173       -1
Impacted Files Coverage Δ
pkg/url/url.go 68.23% <57.14%> (-4.61%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bedbd8f...7c94a4c. Read the comment docs.

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@@ -63,10 +63,15 @@ The created URL can be used to access the specified component from outside the O
applicationName := context.Application
componentName := context.Component()

componentPort, err := url.GetValidPortNumber(client, urlPort, componentName, applicationName)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to check here, this is done in CheckError.

pkg/url/url.go Show resolved Hide resolved
pkg/url/url.go Show resolved Hide resolved
pkg/url/url.go Show resolved Hide resolved
pkg/url/url.go Outdated

if portNumber == -1 {
if len(componentPorts) > 1 {
return portNumber, errors.Errorf("'port' is required as the component %s exposes %d ports: %s", componentName, len(componentPorts), strings.Trim(strings.Replace(fmt.Sprint(componentPorts), " ", ",", -1), "[]"))
Copy link
Contributor

Choose a reason for hiding this comment

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

This is bad as the error message leaks the UI port flag to this layer which shouldn't know about it. The error message should be more generic and processed at the command level to inform the user that the port flag is required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't understand it

Copy link
Contributor

Choose a reason for hiding this comment

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

The error message mentions port which is the flag that the command uses when this function is called to pass the port number. This means that the error message in this function is tied to the calling command implementation. This should be fixed.

Copy link
Contributor

Choose a reason for hiding this comment

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

More precisely, the error message should mention the missing function parameter portNumber and not something called port, which doesn't mean anything in this context.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

pkg/url/url.go Outdated
var portFound bool

if portNumber == -1 {
if len(componentPorts) > 1 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe use a switch here?

pkg/url/url.go Outdated
}
}

if !portFound {
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for this: if port was found then the function should have already returned.

@AppVeyorBot
Copy link

@mik-dass
Copy link
Contributor Author

mik-dass commented Dec 5, 2018

@metacosm Fixed Please have a look again :)

…ovided

It introduces a new function GetValidPortNumber to check and return the valid port of the component.

Signed-off-by: mik-dass <mrinald7@gmail.com>
Signed-off-by: mik-dass <mrinald7@gmail.com>
Signed-off-by: mik-dass <mrinald7@gmail.com>
@AppVeyorBot
Copy link

Copy link
Contributor

@metacosm metacosm left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@surajnarwade surajnarwade left a comment

Choose a reason for hiding this comment

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

WFM, LGTM 🎉

@surajnarwade surajnarwade merged commit 439f58f into redhat-developer:master Dec 7, 2018
@mik-dass mik-dass deleted the url_multiple_ports branch December 7, 2018 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple URL creation fails for same component
4 participants