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

SecretEnricher getSecretsFromXmlConfig should return Collections.emptyList() instead of null #2554

Closed
wants to merge 13 commits into from
Closed
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
import org.eclipse.jkube.kit.enricher.api.JKubeEnricherContext;
import org.eclipse.jkube.kit.enricher.api.util.SecretConstants;
import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Collections;


public abstract class SecretEnricher extends BaseEnricher {

Expand Down Expand Up @@ -76,7 +78,7 @@ private void addSecretsFromXmlConfiguration(KubernetesListBuilder builder) {
log.verbose("Adding secrets resources from plugin configuration");
List<SecretConfig> secrets = getSecretsFromXmlConfig();
Map<String, Integer> secretToIndexMap = new HashMap<>();
if (secrets == null || secrets.isEmpty()) {
if (secrets.isEmpty()) {
return;
}

Expand Down Expand Up @@ -128,11 +130,10 @@ private void addSecretsFromXmlConfiguration(KubernetesListBuilder builder) {
}

private List<SecretConfig> getSecretsFromXmlConfig() {
ResourceConfig resourceConfig = getConfiguration().getResource();
if(resourceConfig != null && resourceConfig.getSecrets() != null) {
return resourceConfig.getSecrets();
}
return null;
return Optional.ofNullable(getConfiguration())
.map(Configuration::getResource)
Copy link
Member

Choose a reason for hiding this comment

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

You're missing the required import for org.eclipse.jkube.kit.enricher.api.model.Configuration, the project won't compile unless you add it

.map(ResourceConfig::getSecrets)
.orElse(Collections.emptyList());
}

private String getDockerIdFromAnnotation(Map<String, String> annotation) {
Expand Down
Loading