Skip to content

Commit

Permalink
fix: SecretEnricher.getSecretsFromXmlConfig returns Collections.empty…
Browse files Browse the repository at this point in the history
…List() instead of null #2530 (#2605)
  • Loading branch information
sankritimishra authored Feb 2, 2024
1 parent b5dbf12 commit 708dff2
Showing 1 changed file with 7 additions and 6 deletions.
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

0 comments on commit 708dff2

Please sign in to comment.