Repository navigation
Trim whitespace from CredHub application names #3372
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,6 @@ | |
| import org.springframework.credhub.support.CredentialDetails; | ||
| import org.springframework.credhub.support.SimpleCredentialName; | ||
| import org.springframework.credhub.support.json.JsonCredential; | ||
| import org.springframework.util.ObjectUtils; | ||
| import org.springframework.util.StringUtils; | ||
|
|
||
| import static java.util.stream.Collectors.toMap; | ||
|
|
@@ -67,18 +66,29 @@ public CredhubEnvironmentRepository(CredHubOperations credHubOperations, Credhub | |
|
|
||
| @Override | ||
| public Environment findOne(String application, String profile, String label) { | ||
| if (ObjectUtils.isEmpty(profile)) { | ||
| if (!StringUtils.hasText(profile)) { | ||
| profile = DEFAULT_PROFILE; | ||
| } | ||
| if (ObjectUtils.isEmpty(label)) { | ||
| if (!StringUtils.hasText(label)) { | ||
| label = this.defaultLabel; | ||
| } | ||
|
|
||
| List<String> applications = normalize(application, DEFAULT_APPLICATION); | ||
| List<String> profiles = normalize(profile, DEFAULT_PROFILE); | ||
| List<String> labels = normalize(label); | ||
|
|
||
| Environment environment = new Environment(application, split(profile), label, null, null); | ||
| List<String> normalizedApplications = normalize(application); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use normalize(String commaDelimitedItems, String defaultItem)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to clarify, should the Environment metadata include the default application/profile values from the normalized lists, or should it preserve the original metadata behavior while reusing the normalized values for property source lookup? |
||
| Collections.reverse(normalizedApplications); | ||
|
|
||
| List<String> normalizedProfiles = normalize(profile); | ||
| Collections.reverse(normalizedProfiles); | ||
|
|
||
| List<String> normalizedLabels = normalize(label); | ||
| Collections.reverse(normalizedLabels); | ||
|
|
||
| Environment environment = new Environment(String.join(",", normalizedApplications), | ||
| normalizedProfiles.toArray(new String[0]), String.join(",", normalizedLabels), null, null); | ||
|
|
||
| for (String l : labels) { | ||
| for (String prof : profiles) { | ||
| for (String app : applications) { | ||
|
|
@@ -103,10 +113,10 @@ private List<String> normalize(String commaDelimitedItems, String defaultItem) { | |
| */ | ||
| private List<String> normalize(String commaDelimitedItems) { | ||
| var items = Arrays.stream(split(commaDelimitedItems)) | ||
| .map(String::trim) | ||
|
yashdotdev13 marked this conversation as resolved.
Resolved
|
||
| .distinct() | ||
| .filter(StringUtils::hasText) | ||
| .collect(Collectors.toList()); | ||
|
|
||
| Collections.reverse(items); | ||
| return items; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.