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

SecurityGroupEditor- Allow for different jclouds prefixes on different clouds #549

Merged
merged 1 commit into from
Feb 7, 2017

Conversation

geomacy
Copy link
Contributor

@geomacy geomacy commented Feb 3, 2017

jclouds on AWS uses 'jclouds#' while on Openstack it is 'jclouds-'.
Also fix some incorrect log messages and add a bit of detail to them.

final Iterable<SecurityGroup> groupsMatching = findSecurityGroupsMatching(new Predicate<SecurityGroup>() {
final String rawName = name.matches(IS_JCLOUDS_PREFIXED_REGEX)
? name.substring(JCLOUDS_PREFIX_REGEX.length())
: name;
Copy link
Member

Choose a reason for hiding this comment

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

Now that you are using a regex could simplify to name.replaceAll("^jclouds[#-]", "")

@Override
public boolean apply(final SecurityGroup input) {
return input.getName().equals(query);
return input.getName().matches(JCLOUDS_PREFIX_REGEX + rawName);
Copy link
Member

Choose a reason for hiding this comment

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

Need to escape the name with "Pattern.quote(rawName)". Or better yet use the same method as above to strip the prefix and compare the non-prefixed names.

jclouds on AWS uses 'jclouds#' while on Openstack it is 'jclouds-'.
Also fix some incorrect log messages and add a bit of detail to them.
@geomacy
Copy link
Contributor Author

geomacy commented Feb 7, 2017

changes made as suggested thanks @neykov, and squashed

Copy link
Member

@drigodwin drigodwin left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @geomacy

@asfgit asfgit merged commit 98f521b into apache:master Feb 7, 2017
asfgit pushed a commit that referenced this pull request Feb 7, 2017
@geomacy geomacy deleted the jclouds-prefix-fix branch February 8, 2017 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants