Skip to content

Commit

Permalink
Added NullCheck in FileDataSecretEnricher
Browse files Browse the repository at this point in the history
  • Loading branch information
rohanKanojia committed Mar 6, 2020
1 parent b5ed36f commit d8a9d00
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ private void addAnnotations(KubernetesListBuilder builder) {
public void visit(SecretBuilder element) {
final Map<String, String> annotations = element.buildMetadata().getAnnotations();
try {
final Map<String, String> secretAnnotations = createSecretFromAnnotations(annotations);
element.addToData(secretAnnotations);
if (annotations != null && !annotations.isEmpty()) {
final Map<String, String> secretAnnotations = createSecretFromAnnotations(annotations);
element.addToData(secretAnnotations);
}
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,19 @@ public void create(PlatformMode platformMode, KubernetesListBuilder builder) {
@Override
public void visit(SecretBuilder secretBuilder) {
Map<String, String> annotation = secretBuilder.buildMetadata().getAnnotations();
if (!annotation.containsKey(getAnnotationKey())) {
return;
if (annotation != null) {
if (!annotation.containsKey(getAnnotationKey())) {
return;
}
String dockerId = annotation.get(getAnnotationKey());
Map<String, String> data = generateData(dockerId);
if (data == null) {
return;
}
// remove the annotation key
annotation.remove(getAnnotationKey());
secretBuilder.addToData(data);
}
String dockerId = annotation.get(getAnnotationKey());
Map<String, String> data = generateData(dockerId);
if (data == null) {
return;
}
// remove the annotation key
annotation.remove(getAnnotationKey());
secretBuilder.addToData(data);
}
});

Expand Down

0 comments on commit d8a9d00

Please sign in to comment.