/** Returns the athenz service for environment/region if configured */ public Optional<AthenzService> athenzService(Environment environment, RegionName region) { AthenzService athenzService = zones().stream() .filter(zone -> zone.deploysTo(environment, Optional.of(region))) .findFirst() .flatMap(DeclaredZone::athenzService) .orElse(this.athenzService.orElse(null)); return Optional.ofNullable(athenzService); }
private void validateAthenz() { // If athenz domain is not set, athenz service cannot be set on any level if (! athenzDomain.isPresent()) { for (DeclaredZone zone : zones()) { if(zone.athenzService().isPresent()) { throw new IllegalArgumentException("Athenz service configured for zone: " + zone + ", but Athenz domain is not configured"); } } // if athenz domain is not set, athenz service must be set implicitly or directly on all zones. } else if(! athenzService.isPresent()) { for (DeclaredZone zone : zones()) { if(! zone.athenzService().isPresent()) { throw new IllegalArgumentException("Athenz domain is configured, but Athenz service not configured for zone: " + zone); } } } }
private boolean zoneHasActiveRotation(Zone zone, DeploymentSpec spec) { return spec.zones().stream() .anyMatch(declaredZone -> declaredZone.deploysTo(zone.environment(), Optional.of(zone.region())) && declaredZone.active()); }