use of io.fabric8.openshift.api.model.DeploymentConfigSpecBuilder in project fabric8-maven-plugin by fabric8io.
the class DeploymentConfigHandler method createDeploymentConfigSpec.
private DeploymentConfigSpec createDeploymentConfigSpec(ResourceConfig config, List<ImageConfiguration> images, Long openshiftDeployTimeoutSeconds, Boolean imageChangeTrigger, Boolean enableAutomaticTrigger, Boolean isOpenshiftBuildStrategy, List<String> generatedContainers) {
DeploymentConfigSpecBuilder specBuilder = new DeploymentConfigSpecBuilder();
PodTemplateSpec podTemplateSpec = podTemplateHandler.getPodTemplate(config, images);
specBuilder.withReplicas(config.getReplicas()).withTemplate(podTemplateSpec).addNewTrigger().withType("ConfigChange").endTrigger();
if (openshiftDeployTimeoutSeconds != null && openshiftDeployTimeoutSeconds > 0) {
specBuilder.withNewStrategy().withType("Rolling").withNewRollingParams().withTimeoutSeconds(openshiftDeployTimeoutSeconds).endRollingParams().endStrategy();
}
return specBuilder.build();
}
use of io.fabric8.openshift.api.model.DeploymentConfigSpecBuilder in project jkube by eclipse.
the class DeploymentConfigEnricher method getDeploymentConfigSpec.
private DeploymentConfigSpec getDeploymentConfigSpec(Integer replicas, Integer revisionHistoryLimit, LabelSelector selector, PodTemplateSpec podTemplateSpec, String strategyType) {
DeploymentConfigSpecBuilder specBuilder = new DeploymentConfigSpecBuilder();
if (replicas != null) {
specBuilder.withReplicas(replicas);
}
if (revisionHistoryLimit != null) {
specBuilder.withRevisionHistoryLimit(revisionHistoryLimit);
}
if (selector != null) {
Map<String, String> matchLabels = selector.getMatchLabels();
if (matchLabels != null && !matchLabels.isEmpty()) {
specBuilder.withSelector(matchLabels);
}
}
if (podTemplateSpec != null) {
specBuilder.withTemplate(podTemplateSpec);
PodSpec podSpec = podTemplateSpec.getSpec();
Objects.requireNonNull(podSpec, "No PodSpec for PodTemplate:" + podTemplateSpec);
Objects.requireNonNull(podSpec, "No containers for PodTemplate.spec: " + podTemplateSpec);
}
DeploymentStrategy deploymentStrategy = getDeploymentStrategy(strategyType);
if (deploymentStrategy != null) {
specBuilder.withStrategy(deploymentStrategy);
}
if (getValueFromConfig(OPENSHIFT_ENABLE_AUTOMATIC_TRIGGER, true)) {
specBuilder.addNewTrigger().withType("ConfigChange").endTrigger();
}
return specBuilder.build();
}
use of io.fabric8.openshift.api.model.DeploymentConfigSpecBuilder in project fabric8-maven-plugin by fabric8io.
the class DeploymentConfigEnricher method getDeploymentConfigSpec.
private DeploymentConfigSpec getDeploymentConfigSpec(Integer replicas, Integer revisionHistoryLimit, LabelSelector selector, PodTemplateSpec podTemplateSpec, String strategyType) {
DeploymentConfigSpecBuilder specBuilder = new DeploymentConfigSpecBuilder();
if (replicas != null) {
specBuilder.withReplicas(replicas);
}
if (revisionHistoryLimit != null) {
specBuilder.withRevisionHistoryLimit(revisionHistoryLimit);
}
if (selector != null) {
Map<String, String> matchLabels = selector.getMatchLabels();
if (matchLabels != null && !matchLabels.isEmpty()) {
specBuilder.withSelector(matchLabels);
}
}
if (podTemplateSpec != null) {
specBuilder.withTemplate(podTemplateSpec);
PodSpec podSpec = podTemplateSpec.getSpec();
Objects.requireNonNull(podSpec, "No PodSpec for PodTemplate:" + podTemplateSpec);
Objects.requireNonNull(podSpec, "No containers for PodTemplate.spec: " + podTemplateSpec);
}
io.fabric8.openshift.api.model.DeploymentStrategy deploymentStrategy = getDeploymentStrategy(strategyType);
if (deploymentStrategy != null) {
specBuilder.withStrategy(deploymentStrategy);
}
if (enableAutomaticTrigger.equals(Boolean.TRUE)) {
specBuilder.addNewTrigger().withType("ConfigChange").endTrigger();
}
return specBuilder.build();
}
Aggregations