/** * Blue/Green deployments enabled, or not. * * @return boolean */ @JsonIgnore public boolean isEnabled() { return !getColor().isEmpty() || !getColorState().isEmpty(); } }
/** * Creates a ClusterInfo instance with color and colorState information. * * @param color the color of the cluster in Blue/Green deployment scenarios. * @param colorState the state of the color, for example "staged" or "live" to determine if the color is currently * in production, or not. * @return ClusterInfo with color and state */ public static ClusterInfo clusterInfo(final String color, final String colorState) { return new ClusterInfo(() -> color, () -> colorState); }
@Test public void shouldGetClusterInfo() { final ClusterInfo clusterInfo = clusterInfo( () -> "Foo", () -> "Bar" ); assertThat(clusterInfo.getColor(), is("Foo")); assertThat(clusterInfo.getColorState(), is("Bar")); } }
@Bean @ConditionalOnMissingBean(ClusterInfo.class) public ClusterInfo clusterInfo() { return ClusterInfo.clusterInfo( () -> httpHeaderValue(clusterInfoProperties.getColorHeader()), () -> httpHeaderValue(clusterInfoProperties.getColorStateHeader()) ); }
private StatusRepresentation(final ApplicationStatus applicationStatus, final Criticality criticality, final List<ExternalDependency> dependencies) { this.application = new ApplicationRepresentation(applicationStatus); this.system = applicationStatus.system; this.team = applicationStatus.team; this.cluster = applicationStatus.cluster.isEnabled() ? applicationStatus.cluster : null; this.criticality = criticality; this.dependencies = dependencies != null ? dependencies .stream() .sorted(comparing(ExternalDependency::getName)) .map(DependencyRepresentation::new) .collect(toList()) : emptyList(); }
@Test public void shouldCreateStatusRepresentationWithClusterInfo() { // given final ClusterInfo cluster = clusterInfo("BLU", "active"); final StatusRepresentation json = statusRepresentationOf( applicationStatus(mock(ApplicationInfo.class), cluster, mock(SystemInfo.class), mock(VersionInfo.class), mock(TeamInfo.class), emptyList()) ); // then assertThat(json.cluster.getColor(), is("BLU")); assertThat(json.cluster.getColorState(), is("active")); }
@Test public void shouldCreateStatusRepresentationWithoutClusterInfo() { // given final ClusterInfo cluster = clusterInfo("", ""); final StatusRepresentation json = statusRepresentationOf( applicationStatus(mock(ApplicationInfo.class), cluster, mock(SystemInfo.class), mock(VersionInfo.class), mock(TeamInfo.class), emptyList()) ); // then assertThat(json.cluster, is(nullValue())); }
/** * Creates a ClusterInfo instance with {@link Supplier suppliers} for color and colorState information. * * @param colorSupplier the Supplier for the color of the cluster in Blue/Green deployment scenarios. * @param colorStateSupplier the Supplier for the state of the cluster, for example "staged" or "live", * to determine if the color is currently in production, or not. * @return ClusterInfo with color and state provided by suppliers */ public static ClusterInfo clusterInfo(final Supplier<String> colorSupplier, final Supplier<String> colorStateSupplier) { return new ClusterInfo(colorSupplier, colorStateSupplier); }