Skip to content

Commit

Permalink
Fix NPE while applying empty manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
sepulvedablanco committed Mar 1, 2022
1 parent 6731924 commit 6e2bba6
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.CollectionUtils;

public class KubernetesDeployManifestOperation implements AtomicOperation<OperationResult> {
private static final Logger log =
Expand Down Expand Up @@ -167,18 +168,21 @@ public OperationResult operate(List<OperationResult> _unused) {
@NotNull
private List<KubernetesManifest> getManifestsFromDescription() {
List<KubernetesManifest> inputManifests = description.getManifests();
if (inputManifests == null || inputManifests.isEmpty()) {
// The stage currently only supports using the `manifests` field but we need to continue to
// check `manifest` for backwards compatibility until all existing stages have been updated.
@SuppressWarnings("deprecation")
KubernetesManifest manifest = description.getManifest();

// The stage currently only supports using the `manifests` field but we need to continue to
// check `manifest` for backwards compatibility until all existing stages have been updated.
@SuppressWarnings("deprecation")
KubernetesManifest manifest = description.getManifest();

if (CollectionUtils.isEmpty(inputManifests) && manifest != null) {
log.warn(
"Relying on deprecated single manifest input (account: {}, kind: {}, name: {})",
accountName,
manifest.getKind(),
manifest.getName());
inputManifests = ImmutableList.of(manifest);
}

inputManifests = inputManifests.stream().filter(Objects::nonNull).collect(Collectors.toList());
return inputManifests;
}
Expand Down

0 comments on commit 6e2bba6

Please sign in to comment.