use of com.netflix.spinnaker.fiat.model.resources.Application in project fiat by spinnaker.
the class DefaultApplicationResourceProvider method loadAll.
@Override
protected Set<Application> loadAll() throws ProviderException {
try {
List<Application> front50Applications = front50Service.getAllApplications();
List<Application> clouddriverApplications = clouddriverService.getApplications();
// Stream front50 first so that if there's a name collision, we'll keep that one instead of
// the clouddriver application (since front50 might have permissions stored on it, but the
// clouddriver version definitely won't)
List<Application> applications = Streams.concat(front50Applications.stream(), clouddriverApplications.stream()).filter(distinctByKey(a -> a.getName().toUpperCase())).collect(toImmutableList());
applications.forEach(application -> {
Permissions permissions = permissionProvider.getPermissions(application);
// Check to see if we need to fallback permissions to the configured fallback
application.setPermissions(executeFallbackPermissionsResolver.shouldResolve(permissions) ? executeFallbackPermissionsResolver.resolve(permissions) : permissions);
});
if (allowAccessToUnknownApplications) {
// unknown applications by default
return applications.stream().filter(a -> a.getPermissions().isRestricted()).collect(toImmutableSet());
} else {
return ImmutableSet.copyOf(applications);
}
} catch (RuntimeException e) {
throw new ProviderException(this.getClass(), e);
}
}
Aggregations