use of io.fabric8.kubernetes.api.model.KubernetesListBuilder in project fabric8-maven-plugin by fabric8io.
the class DockerRegistrySecretEnricherTest method testDockerRegistryWithBadAnnotation.
@Test
public void testDockerRegistryWithBadAnnotation() {
DockerRegistrySecretEnricher enricher = new DockerRegistrySecretEnricher(context);
new Expectations() {
{
{
context.getSettings();
returns(new Settings());
}
}
};
KubernetesListBuilder builder = new KubernetesListBuilder();
Secret secret = createBaseSecret(true);
secret.getMetadata().getAnnotations().put(annotation, "docker1.io");
builder.addToSecretItems(createBaseSecret(true));
KubernetesList expected = builder.build();
enricher.addMissingResources(builder);
assertEquals(expected, builder.build());
}
use of io.fabric8.kubernetes.api.model.KubernetesListBuilder in project fabric8-maven-plugin by fabric8io.
the class DockerRegistrySecretEnricherTest method testDockerRegistry.
@Test
public void testDockerRegistry() {
new Expectations() {
{
{
context.getSettings();
result = createSettings();
}
}
};
DockerRegistrySecretEnricher enricher = new DockerRegistrySecretEnricher(context);
KubernetesListBuilder builder = new KubernetesListBuilder();
builder.addToSecretItems(createBaseSecret(true));
enricher.addMissingResources(builder);
KubernetesListBuilder expectedBuilder = new KubernetesListBuilder();
Secret expectedSecret = createBaseSecret(false);
expectedSecret.getData().put(SecretConstants.DOCKER_DATA_KEY, "eyJkb2NrZXIuaW8iOnsicGFzc3dvcmQiOiJwYXNzd29yZCIsImVtYWlsIjoiZm9vQGZvby5jb20iLCJ1c2VybmFtZSI6InVzZXJuYW1lIn19");
expectedBuilder.addToSecretItems(expectedSecret);
assertEquals(expectedBuilder.build(), builder.build());
}
use of io.fabric8.kubernetes.api.model.KubernetesListBuilder in project fabric8-maven-plugin by fabric8io.
the class EnricherManagerTest method enrichSimple.
@Test
public void enrichSimple() {
new Expectations() {
{
context.getConfig();
result = new ProcessorConfig(Arrays.asList("fmp-project"), null, new HashMap<String, TreeMap>());
}
};
EnricherManager manager = new EnricherManager(null, context);
KubernetesListBuilder builder = new KubernetesListBuilder();
builder.addNewReplicaSetItem().withNewSpec().withNewTemplate().withNewSpec().addNewContainer().withName("test").withImage("busybox").endContainer().endSpec().endTemplate().endSpec().endReplicaSetItem();
manager.enrich(builder);
KubernetesList list = builder.build();
assertEquals(1, list.getItems().size());
ReplicaSet pod = (ReplicaSet) list.getItems().get(0);
ObjectMeta metadata = pod.getMetadata();
assertNotNull(metadata);
Map<String, String> labels = metadata.getLabels();
assertNotNull(labels);
assertEquals("fabric8", labels.get("provider"));
}
use of io.fabric8.kubernetes.api.model.KubernetesListBuilder in project fabric8-maven-plugin by fabric8io.
the class EnricherManagerTest method createDefaultResources.
@Test
public void createDefaultResources() {
new Expectations() {
{
context.getConfig();
result = new ProcessorConfig(Arrays.asList("fmp-controller"), null, null);
context.getImages();
result = new ImageConfiguration.Builder().alias("img1").name("img1").build();
}
};
EnricherManager manager = new EnricherManager(null, context);
KubernetesListBuilder builder = new KubernetesListBuilder();
manager.createDefaultResources(builder);
assertTrue(builder.build().getItems().size() > 0);
}
use of io.fabric8.kubernetes.api.model.KubernetesListBuilder in project fabric8-maven-plugin by fabric8io.
the class SecretEnricher method addMissingResources.
@Override
public void addMissingResources(KubernetesListBuilder builder) {
Map<String, String> config = getRawConfig();
SecretBuilder secretBuilder = createSecretBuilder();
for (Map.Entry<String, String> entry : config.entrySet()) {
if (!isTypedKey(entry.getKey())) {
addToSecretBuilder(secretBuilder, entry.getKey(), entry.getValue());
}
}
if (secretBuilder.hasData() && secretBuilder.getData().size() > 0) {
builder.addToSecretItems(secretBuilder.build());
}
}
Aggregations