Skip to content

Commit

Permalink
Set service account name only to the generated deployment
Browse files Browse the repository at this point in the history
This change is related to this comment: #25750 (comment)
  • Loading branch information
Sgitario committed Jul 5, 2022
1 parent 7c5db92 commit 2521138
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public static List<DecoratorBuildItem> createDecorators(Optional<Project> projec

//Handle RBAC
if (!roleBindings.isEmpty()) {
result.add(new DecoratorBuildItem(target, new ApplyServiceAccountNameDecorator(name)));
result.add(new DecoratorBuildItem(target, new ApplyServiceAccountNameDecorator(name, name)));
result.add(new DecoratorBuildItem(target, new AddServiceAccountResourceDecorator(name)));
roles.forEach(r -> result.add(new DecoratorBuildItem(target, new AddRoleResourceDecorator(name, r))));
roleBindings.forEach(rb -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ public void assertGeneratedResources() throws IOException {

assertThat(kubernetesList).filteredOn(h -> "Deployment".equals(h.getKind())).allSatisfy(h -> {
Deployment deployment = (Deployment) h;
assertThat(deployment.getSpec().getTemplate().getSpec().getServiceAccountName()).isEqualTo(APPLICATION_NAME);
String serviceAccountName = deployment.getSpec().getTemplate().getSpec().getServiceAccountName();
if (h.getMetadata().getName().equals(APPLICATION_NAME)) {
assertThat(serviceAccountName).isEqualTo(APPLICATION_NAME);
} else {
assertThat(serviceAccountName).isNull();
}
});

assertThat(kubernetesList).filteredOn(h -> "ServiceAccount".equals(h.getKind())).singleElement().satisfies(h -> {
Expand Down

0 comments on commit 2521138

Please sign in to comment.