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 #2530 #2605

Merged
merged 5 commits into from
Feb 2, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@
import org.eclipse.jkube.kit.enricher.api.JKubeEnricherContext;
import org.eclipse.jkube.kit.enricher.api.util.SecretConstants;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.jkube.kit.enricher.api.model.Configuration;

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

import java.util.Collections;
import java.util.Optional;
public abstract class SecretEnricher extends BaseEnricher {

public SecretEnricher(JKubeEnricherContext buildContext, String name) {
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)
.map(ResourceConfig::getSecrets)
.orElse(Collections.emptyList());
}

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