use of org.eclipse.jkube.kit.config.resource.ResourceConfig in project jkube by eclipse.
the class ReplicationControllerHandlerTest method replicationControllerHandlerWithInvalidNameTest.
@Test(expected = IllegalArgumentException.class)
public void replicationControllerHandlerWithInvalidNameTest() {
// with invalid controller name
ResourceConfig config = ResourceConfig.builder().imagePullPolicy("IfNotPresent").controllerName("TesTing").serviceAccount("test-account").replicas(5).volumes(volumes1).build();
replicationControllerHandler.get(config, images);
}
use of org.eclipse.jkube.kit.config.resource.ResourceConfig in project jkube by eclipse.
the class StatefulSetHandlerTest method statefulSetHandlerWithoutControllerTest.
@Test(expected = IllegalArgumentException.class)
public void statefulSetHandlerWithoutControllerTest() {
// without controller name
ResourceConfig config = ResourceConfig.builder().imagePullPolicy("IfNotPresent").serviceAccount("test-account").replicas(5).volumes(volumes1).build();
statefulSetHandler.get(config, images);
}
use of org.eclipse.jkube.kit.config.resource.ResourceConfig in project jkube by eclipse.
the class StatefulSetHandlerTest method statefulSetHandlerWithInvalidNameTest.
@Test(expected = IllegalArgumentException.class)
public void statefulSetHandlerWithInvalidNameTest() {
// with invalid controller name
ResourceConfig config = ResourceConfig.builder().imagePullPolicy("IfNotPresent").controllerName("TesTing").serviceAccount("test-account").replicas(5).volumes(volumes1).build();
statefulSetHandler.get(config, images);
}
use of org.eclipse.jkube.kit.config.resource.ResourceConfig in project jkube by eclipse.
the class DefaultControllerEnricher method create.
@Override
public void create(PlatformMode platformMode, KubernetesListBuilder builder) {
final String name = getConfig(Config.NAME, JKubeProjectUtil.createDefaultResourceName(getContext().getGav().getSanitizedArtifactId()));
ResourceConfig providedResourceConfig = Optional.ofNullable(getConfiguration().getResource()).orElse(ResourceConfig.builder().build());
ResourceConfig config = ResourceConfig.toBuilder(providedResourceConfig).controllerName(getControllerName(providedResourceConfig, name)).imagePullPolicy(getImagePullPolicy(providedResourceConfig, getConfig(Config.PULL_POLICY))).replicas(getReplicaCount(builder, providedResourceConfig, Configs.asInt(getConfig(Config.REPLICA_COUNT)))).restartPolicy(providedResourceConfig.getRestartPolicy()).build();
final List<ImageConfiguration> images = getImages();
// At least one image must be present, otherwise the resulting config will be invalid
if (!KubernetesResourceUtil.checkForKind(builder, POD_CONTROLLER_KINDS) && !images.isEmpty()) {
final ControllerHandler<? extends HasMetadata> ch = getContext().getHandlerHub().getHandlerFor(fromType(getConfig(Config.TYPE)));
final HasMetadata resource = ch.get(config, images);
log.info("Adding a default %s", resource.getKind());
builder.addToItems(resource);
setProcessingInstruction(FABRIC8_GENERATED_CONTAINERS, getContainersFromPodSpec(ch.getPodTemplateSpec(config, images)));
}
}
Aggregations