-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Change protocol strings to enum values in parsing Protocol options #12135
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
base: main
Are you sure you want to change the base?
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache CloudStack community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md)
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #12135 +/- ##
============================================
- Coverage 17.56% 17.55% -0.01%
+ Complexity 15538 15537 -1
============================================
Files 5912 5912
Lines 529383 529383
Branches 64660 64660
============================================
- Hits 92984 92956 -28
- Misses 425941 425968 +27
- Partials 10458 10459 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
DaanHoogland
left a comment
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.
some alternative (just for consideration)
| private Protocol parseOptions(String[] args) { | ||
| String protocolName = (args.length > 0) ? args[0] : ""; | ||
| Protocol protocol = Protocol.NONE; | ||
| Protocol protocol; |
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.
| Protocol protocol; | |
| Protocol protocol; | |
| try { | |
| protocol = Protocol.valueOf(protocolName); | |
| } catch (IllegalArgumentException e) { | |
| protocol = Protocol.NONE; | |
| } |
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.
can use this instead
Protocol protocol = EnumUtils.getEnumIgnoreCase(Protocol.class, protocolName, Protocol.NONE);
btw: no issues with the class, it is not used ...
| if (protocolName.equals(Protocol.VNC.name().toLowerCase())) { | ||
| protocol = Protocol.VNC; | ||
| options = join(commonOptions, vncOptions); | ||
| } else if (protocolName.equals("rdp")) { | ||
| } else if (protocolName.equals(Protocol.RDP.name().toLowerCase())) { | ||
| protocol = Protocol.RDP; | ||
| options = join(commonOptions, rdpOptions); | ||
| } else if (protocolName.equals("hyperv")) { | ||
| } else if (protocolName.equals(Protocol.HYPERV.name().toLowerCase())) { | ||
| protocol = Protocol.HYPERV; | ||
| options = join(commonOptions, hyperVOptions); | ||
| } else { | ||
| help(); | ||
| return Protocol.NONE; | ||
| } |
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.
| switch (protocol) { | |
| case VNC: | |
| options = join(commonOptions, vncOptions); | |
| break; | |
| case RDP: | |
| options = join(commonOptions, rdpOptions); | |
| break; | |
| case HYPERV: | |
| options = join(commonOptions, hyperVOptions); | |
| break; | |
| case NONE: | |
| help(); | |
| return Protocol.NONE; | |
| } |
Description
This PR...
Fixes: #11821
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
How did you try to break this feature and the system with this change?