Skip to content

Commit

Permalink
refactor: leverage type inference more (#712)
Browse files Browse the repository at this point in the history
This will be useful for a future upgrade of the Fabric8 Kubernetes
client.

Signed-off-by: Chris Laprun <claprun@redhat.com>
  • Loading branch information
metacosm committed Sep 20, 2023
1 parent ff47499 commit b563961
Showing 1 changed file with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,13 @@ public byte[] getManifestData(List<ServiceAccount> serviceAccounts, List<Cluster
return YAML_MAPPER.writeValueAsBytes(csv);
}

private void handleDeployments(List<Deployment> deployments,
NamedInstallStrategyFluent.SpecNested<ClusterServiceVersionSpecFluent.InstallNested<ClusterServiceVersionFluent.SpecNested<ClusterServiceVersionBuilder>>> installSpec) {
private void handleDeployments(List<Deployment> deployments, NamedInstallStrategyFluent.SpecNested<?> installSpec) {
deployments.forEach(deployment -> handleDeployment(deployment, installSpec));
}

private void handlePermissions(List<ClusterRole> clusterRoles, List<RoleBinding> roleBindings, List<Role> roles,
String defaultServiceAccountName,
NamedInstallStrategyFluent.SpecNested<ClusterServiceVersionSpecFluent.InstallNested<ClusterServiceVersionFluent.SpecNested<ClusterServiceVersionBuilder>>> installSpec) {
NamedInstallStrategyFluent.SpecNested<?> installSpec) {
Map<String, List<PolicyRule>> customPermissionRules = new HashMap<>();
if (metadata.permissionRules != null) {
for (CSVMetadataHolder.PermissionRule permissionRule : metadata.permissionRules) {
Expand Down Expand Up @@ -322,7 +321,7 @@ private void handlePermissions(List<ClusterRole> clusterRoles, List<RoleBinding>
private void handleClusterPermissions(List<ClusterRoleBinding> clusterRoleBindings, List<ClusterRole> clusterRoles,
List<Role> roles,
String defaultServiceAccountName,
NamedInstallStrategyFluent.SpecNested<ClusterServiceVersionSpecFluent.InstallNested<ClusterServiceVersionFluent.SpecNested<ClusterServiceVersionBuilder>>> installSpec) {
NamedInstallStrategyFluent.SpecNested<?> installSpec) {
for (ClusterRoleBinding binding : clusterRoleBindings) {
String serviceAccountName = findServiceAccountFromSubjects(binding.getSubjects(), defaultServiceAccountName);
if (NO_SERVICE_ACCOUNT.equals(serviceAccountName)) {
Expand All @@ -335,8 +334,7 @@ private void handleClusterPermissions(List<ClusterRoleBinding> clusterRoleBindin
}
}

private void handleDeployment(Deployment deployment,
NamedInstallStrategyFluent.SpecNested<ClusterServiceVersionSpecFluent.InstallNested<ClusterServiceVersionFluent.SpecNested<ClusterServiceVersionBuilder>>> installSpec) {
private void handleDeployment(Deployment deployment, NamedInstallStrategyFluent.SpecNested<?> installSpec) {
if (deployment != null) {
installSpec.addNewDeployment()
.withName(deployment.getMetadata().getName())
Expand All @@ -345,9 +343,8 @@ private void handleDeployment(Deployment deployment,
}
}

private void handlerPermission(List<PolicyRule> rules,
String serviceAccountName,
NamedInstallStrategyFluent.SpecNested<ClusterServiceVersionSpecFluent.InstallNested<ClusterServiceVersionFluent.SpecNested<ClusterServiceVersionBuilder>>> installSpec) {
private void handlerPermission(List<PolicyRule> rules, String serviceAccountName,
NamedInstallStrategyFluent.SpecNested<?> installSpec) {
if (!rules.isEmpty()) {
Predicate<StrategyDeploymentPermissionsBuilder> sameServiceAccountName = p -> serviceAccountName
.equals(p.getServiceAccountName());
Expand All @@ -366,7 +363,7 @@ private void handlerPermission(List<PolicyRule> rules,

private void handleClusterPermission(List<PolicyRule> rules,
String serviceAccountName,
NamedInstallStrategyFluent.SpecNested<ClusterServiceVersionSpecFluent.InstallNested<ClusterServiceVersionFluent.SpecNested<ClusterServiceVersionBuilder>>> installSpec) {
NamedInstallStrategyFluent.SpecNested<?> installSpec) {

Predicate<StrategyDeploymentPermissionsBuilder> sameServiceAccountName = p -> serviceAccountName
.equals(p.getServiceAccountName());
Expand Down

0 comments on commit b563961

Please sign in to comment.