public static boolean isNotProjectLink(String link) { return !isProjectLink(link); }
public static Set<String> getProjectAndGroupLinks(Collection<String> tenantLinks) { if (tenantLinks == null) { return new HashSet<>(); } return tenantLinks.stream() .filter(link -> isProjectLink(link) || isGroupLink(link)) .collect(Collectors.toSet()); }
private static boolean isCreatePKSClusterRequest(Operation op, SecurityContext sc, String projectLink) { ContainerHostSpec hostSpec = extractContainerHostSpec(op); boolean isCreatePKSClusterRequest = hostSpec != null && hostSpec.hostState != null && hostSpec.hostState.customProperties != null && hostSpec.hostState.customProperties .get(PKSConstants.PKS_ENDPOINT_PROP_NAME) != null; if (isCreatePKSClusterRequest) { if (projectLink == null && hostSpec.hostState.tenantLinks != null) { projectLink = hostSpec.hostState.tenantLinks.stream() .filter(tenantLink -> isProjectLink(tenantLink)) .findFirst().orElse(null); } return op.getAction() == Action.POST && isCreatePKSClusterRequest && isProjectAdminOrProjectMember(projectLink, sc); } return false; }
/** * Takes all non-project links from the old tenant links and all project links from the patched * tenant links, puts them together and returns the result. */ List<String> mergeTenantLinks(List<String> oldTenantLinks, List<String> patchTenantLinks) { // no pathed tenant links = keep original tenant links if (patchTenantLinks == null) { return oldTenantLinks; } // we are allowed to patch only the project links (i.e. to make group assignments). // Clear all other links from the patch List<String> projectLinks = patchTenantLinks.stream() .filter(link -> { return TenantLinksUtil.isProjectLink(link) || TenantLinksUtil.isGroupLink(link); }).collect(Collectors.toList()); if (oldTenantLinks == null) { // no old tenant links = use patch links return projectLinks; } // merge old non-project links with patch project links and return the result List<String> otherLinks = oldTenantLinks.stream() .filter(link -> { return TenantLinksUtil.isNotProjectLink(link) && TenantLinksUtil.isNotGroupLink(link); }).collect(Collectors.toList()); otherLinks.addAll(projectLinks); return otherLinks; }
registry.tenantLinks .stream() .anyMatch(tenantLink -> TenantLinksUtil.isProjectLink(tenantLink) || TenantLinksUtil.isGroupLink(tenantLink))); if (registryInvalid) {