use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project fabric8-maven-plugin by fabric8io.
the class DefaultControllerEnricherTest method enrichAndAssert.
protected void enrichAndAssert(int sizeOfObjects, int replicaCount) throws com.fasterxml.jackson.core.JsonProcessingException {
// Setup a sample docker build configuration
final BuildImageConfiguration buildConfig = new BuildImageConfiguration.Builder().ports(Arrays.asList("8080")).build();
final TreeMap controllerConfig = new TreeMap();
controllerConfig.put("replicaCount", String.valueOf(replicaCount));
setupExpectations(buildConfig, controllerConfig);
// Enrich
DefaultControllerEnricher controllerEnricher = new DefaultControllerEnricher(context);
KubernetesListBuilder builder = new KubernetesListBuilder();
controllerEnricher.addMissingResources(builder);
// Validate that the generated resource contains
KubernetesList list = builder.build();
assertEquals(sizeOfObjects, list.getItems().size());
String json = KubernetesResourceUtil.toJson(list.getItems().get(0));
assertThat(json, JsonPathMatchers.isJson());
assertThat(json, JsonPathMatchers.hasJsonPath("$.spec.replicas", Matchers.equalTo(replicaCount)));
}
use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project fabric8-maven-plugin by fabric8io.
the class DependencyEnricherTest method createResourcesForTest.
private KubernetesListBuilder createResourcesForTest() throws IOException, URISyntaxException {
setupExpectations();
List<File> resourceList = new ArrayList<>();
resourceList.add(new File(Paths.get(getClass().getResource(overrideFragementFile).toURI()).toAbsolutePath().toString()));
/*
* Our override file also contains a ConfigMap item with name jenkins, load it while
* loading Kubernetes resources.
*/
KubernetesListBuilder builder = KubernetesResourceUtil.readResourceFragmentsFrom(KubernetesResourceUtil.DEFAULT_RESOURCE_VERSIONING, project.getName(), resourceList.toArray(new File[resourceList.size()]));
return builder;
}
use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project fabric8-maven-plugin by fabric8io.
the class MavenProjectEnricherTest method testOldStyleGeneratedResources.
@Test
public void testOldStyleGeneratedResources() {
final Properties properties = new Properties();
properties.setProperty("fabric8.enricher.fmp-project.useProjectLabel", "true");
new Expectations() {
{
mavenProject.getProperties();
result = properties;
}
};
ProjectEnricher projectEnricher = new ProjectEnricher(context);
KubernetesListBuilder builder = createListWithDeploymentConfig();
projectEnricher.adapt(builder);
KubernetesList list = builder.build();
Map<String, String> labels = list.getItems().get(0).getMetadata().getLabels();
assertNotNull(labels);
assertEquals("groupId", labels.get("group"));
assertEquals("artifactId", labels.get("project"));
assertEquals("version", labels.get("version"));
assertNull(labels.get("app"));
Map<String, String> selectors = projectEnricher.getSelector(Kind.DEPLOYMENT_CONFIG);
assertEquals("groupId", selectors.get("group"));
assertEquals("artifactId", selectors.get("project"));
assertNull(selectors.get("version"));
assertNull(selectors.get("app"));
}
use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project fabric8-maven-plugin by fabric8io.
the class MavenProjectEnricherTest method testGeneratedResources.
@Test
public void testGeneratedResources() {
ProjectEnricher projectEnricher = new ProjectEnricher(context);
KubernetesListBuilder builder = createListWithDeploymentConfig();
projectEnricher.adapt(builder);
KubernetesList list = builder.build();
Map<String, String> labels = list.getItems().get(0).getMetadata().getLabels();
assertNotNull(labels);
assertEquals("groupId", labels.get("group"));
assertEquals("artifactId", labels.get("app"));
assertEquals("version", labels.get("version"));
assertNull(labels.get("project"));
Map<String, String> selectors = projectEnricher.getSelector(Kind.DEPLOYMENT_CONFIG);
assertEquals("groupId", selectors.get("group"));
assertEquals("artifactId", selectors.get("app"));
assertNull(selectors.get("version"));
assertNull(selectors.get("project"));
}
use of io.fabric8.maven.docker.config.CopyConfiguration.Builder in project fabric8-maven-plugin by fabric8io.
the class RevisionHistoryEnricherTest method testDefaultRevisionHistoryLimit.
@Test
public void testDefaultRevisionHistoryLimit() throws JsonProcessingException {
// Given
KubernetesListBuilder builder = new KubernetesListBuilder().addNewDeploymentItem().endDeploymentItem();
RevisionHistoryEnricher enricher = new RevisionHistoryEnricher(context);
// When
enricher.addMissingResources(builder);
// Then
assertRevisionHistory(builder.build(), Configs.asInt(RevisionHistoryEnricher.Config.limit.def()));
}
Aggregations