Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

feature(resource): Remove runtimeMode from fabric8:resource #1576

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
<parent>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-parent</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>

<artifactId>fabric8-maven-core</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>

<name>Fabric8 Maven :: Core</name>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,17 @@ public class DeploymentConfigHandler {
}

public DeploymentConfig getDeploymentConfig(ResourceConfig config,
List<ImageConfiguration> images, Long openshiftDeployTimeoutSeconds, Boolean imageChangeTrigger, Boolean enableAutomaticTrigger, Boolean isOpenshiftBuildStrategy) {
List<ImageConfiguration> images, Long openshiftDeployTimeoutSeconds, Boolean imageChangeTrigger, Boolean enableAutomaticTrigger) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please remove PlatformMode import also?


DeploymentConfig deploymentConfig = new DeploymentConfigBuilder()
.withMetadata(createDeploymentConfigMetaData(config))
.withSpec(createDeploymentConfigSpec(config, images, openshiftDeployTimeoutSeconds, imageChangeTrigger, enableAutomaticTrigger, isOpenshiftBuildStrategy))
.withSpec(
createDeploymentConfigSpec(
config,
images,
openshiftDeployTimeoutSeconds,
imageChangeTrigger,
enableAutomaticTrigger))
.build();

return deploymentConfig;
Expand All @@ -60,7 +66,7 @@ private ObjectMeta createDeploymentConfigMetaData(ResourceConfig config) {
.build();
}

private DeploymentConfigSpec createDeploymentConfigSpec(ResourceConfig config, List<ImageConfiguration> images, Long openshiftDeployTimeoutSeconds, Boolean imageChangeTrigger, Boolean enableAutomaticTrigger, Boolean isOpenshiftBuildStrategy) {
private DeploymentConfigSpec createDeploymentConfigSpec(ResourceConfig config, List<ImageConfiguration> images, Long openshiftDeployTimeoutSeconds, Boolean imageChangeTrigger, Boolean enableAutomaticTrigger) {
DeploymentConfigSpecBuilder specBuilder = new DeploymentConfigSpecBuilder();

PodTemplateSpec podTemplateSpec = podTemplateHandler.getPodTemplate(config,images);
Expand All @@ -80,7 +86,7 @@ private DeploymentConfigSpec createDeploymentConfigSpec(ResourceConfig config, L
}

// add a new image change trigger for the build stream
if (containerToImageMap.size() != 0 && imageChangeTrigger && isOpenshiftBuildStrategy) {
if (containerToImageMap.size() != 0 && imageChangeTrigger) {
for (Map.Entry<String, String> entry : containerToImageMap.entrySet()) {
String containerName = entry.getKey();
ImageName image = new ImageName(entry.getValue());
Expand Down
4 changes: 2 additions & 2 deletions doc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
<parent>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-parent</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>

<artifactId>fabric8-maven-doc</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Fabric8 Maven :: Documentation</name>
Expand Down
4 changes: 2 additions & 2 deletions enricher/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
<parent>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-parent</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>

<artifactId>fabric8-maven-enricher-api</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>

<name>Fabric8 Maven :: Enricher :: API</name>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,4 @@ protected Map<String, String> getRawConfig() {
protected EnricherContext getContext() {
return enricherContext;
}

/**
* Returns true if we are in OpenShift S2I binary building mode
*/
protected boolean isOpenShiftMode() {
Properties properties = getContext().getConfiguration().getProperties();
if (properties != null) {
return RuntimeMode.isOpenShiftMode(properties);
}
return false;
}
}
4 changes: 2 additions & 2 deletions enricher/deprecated/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
<parent>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-parent</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>

<artifactId>fabric8-maven-enricher-deprecated</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>

<name>Fabric8 Maven :: Enricher :: Deprecated</name>

Expand Down
4 changes: 2 additions & 2 deletions enricher/fabric8/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
<parent>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-parent</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>

<artifactId>fabric8-maven-enricher-fabric8</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>

<name>Fabric8 Maven :: Enricher :: Fabric8</name>

Expand Down
4 changes: 2 additions & 2 deletions enricher/osio/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
<parent>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-parent</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>

<artifactId>fabric8-maven-enricher-osio</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>

<name>Fabric8 Maven :: Enricher :: OpenShift.io</name>

Expand Down
4 changes: 2 additions & 2 deletions enricher/standard/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
<parent>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-parent</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>

<artifactId>fabric8-maven-enricher-standard</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>

<name>Fabric8 Maven :: Enricher :: Standard</name>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,12 @@ public void create(PlatformMode platformMode, KubernetesListBuilder builder) {
setProcessingInstruction(getContainersFromPodSpec(deployment.getSpec().getTemplate()));
} else {
log.info("Adding a default DeploymentConfig");
DeploymentConfig deploymentConfig = deployConfigHandler.getDeploymentConfig(config, images, getOpenshiftDeployTimeoutInSeconds(3600L), getImageChangeTriggerFlag(true), isAutomaticTriggerEnabled(true), isOpenShiftMode());
DeploymentConfig deploymentConfig =
deployConfigHandler.getDeploymentConfig(
config, images,
getOpenshiftDeployTimeoutInSeconds(3600L),
getImageChangeTriggerFlag(true),
isAutomaticTriggerEnabled(true));
builder.addToDeploymentConfigItems(deploymentConfig);
setProcessingInstruction(getContainersFromPodSpec(deploymentConfig.getSpec().getTemplate()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public RevisionHistoryEnricher(MavenEnricherContext buildContext) {
public void create(PlatformMode platformMode, KubernetesListBuilder builder) {
final Integer maxRevisionHistories = Configs.asInt(getConfig(Config.limit));

log.info("Adding revision history limit to %s", maxRevisionHistories);
log.verbose("Adding revision history limit to %s", maxRevisionHistories);

if(platformMode == PlatformMode.kubernetes) {
builder.accept(new TypedVisitor<DeploymentBuilder>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public AutoTLSEnricher(MavenEnricherContext buildContext) {

@Override
public void create(PlatformMode platformMode, KubernetesListBuilder builder) {
if (!isOpenShiftMode()) {
if (platformMode != PlatformMode.openshift) {
return;
}

Expand Down Expand Up @@ -136,7 +136,7 @@ private boolean isVolumeMountAlreadyExists(List<VolumeMount> volumes, String vol

@Override
public void enrich(PlatformMode platformMode, KubernetesListBuilder builder) {
if (!isOpenShiftMode()) {
if (platformMode != PlatformMode.openshift) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ public DeploymentConfigEnricher(MavenEnricherContext context) {

@Override
public void create(PlatformMode platformMode, KubernetesListBuilder builder) {
if(platformMode == PlatformMode.openshift) {
for(HasMetadata item : builder.buildItems()) {
if(item instanceof Deployment) {
DeploymentConfig deploymentConfig = convert(item, isOpenShiftMode());
if (platformMode == PlatformMode.openshift) {
for (HasMetadata item : builder.buildItems()) {
if (item instanceof Deployment) {
DeploymentConfig deploymentConfig = convert(item);
removeItemFromBuilder(builder, item);
builder.addToDeploymentConfigItems(deploymentConfig);
}
Expand All @@ -76,7 +76,7 @@ private void removeItemFromBuilder(KubernetesListBuilder builder, HasMetadata it
builder.withItems(newListItems);
}

private DeploymentConfig convert(HasMetadata item, Boolean isOpenshiftBuildStrategy) {
private DeploymentConfig convert(HasMetadata item) {
Deployment resource = (Deployment) item;
DeploymentConfigBuilder builder = new DeploymentConfigBuilder();
builder.withMetadata(resource.getMetadata());
Expand Down Expand Up @@ -138,7 +138,7 @@ private DeploymentConfig convert(HasMetadata item, Boolean isOpenshiftBuildStrat

// add a new image change trigger for the build stream
if (containerToImageMap.size() != 0) {
if(enableImageChangeTrigger && isOpenshiftBuildStrategy) {
if (enableImageChangeTrigger) {
for (Map.Entry<String, String> entry : containerToImageMap.entrySet()) {
String containerName = entry.getKey();
ImageName image = new ImageName(entry.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,11 @@ public void testAdapt() throws Exception {
final ProcessorConfig config = new ProcessorConfig(null, null,
Collections.singletonMap(AutoTLSEnricher.ENRICHER_NAME, configMap));

final Properties projectProps = new Properties();
projectProps.put(RuntimeMode.FABRIC8_EFFECTIVE_PLATFORM_MODE, tc.mode.name());

// Setup mock behaviour
new Expectations() {
{
Configuration configuration =
new Configuration.Builder()
.properties(projectProps)
.processorConfig(config)
.build();
context.getConfiguration();
Expand All @@ -138,7 +134,7 @@ public void testAdapt() throws Exception {
AutoTLSEnricher enricher = new AutoTLSEnricher(context);
KubernetesListBuilder klb = new KubernetesListBuilder().addNewPodTemplateItem().withNewMetadata().and()
.withNewTemplate().withNewMetadata().and().withNewSpec().and().and().and();
enricher.enrich(PlatformMode.kubernetes, klb);
enricher.enrich(tc.mode, klb);
PodTemplate pt = (PodTemplate) klb.getItems().get(0);

List<Container> initContainers = pt.getTemplate().getSpec().getInitContainers();
Expand Down
4 changes: 2 additions & 2 deletions generator/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
<parent>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-parent</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>

<artifactId>fabric8-maven-generator-api</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>

<name>Fabric8 Maven :: Generator :: API</name>

Expand Down
4 changes: 2 additions & 2 deletions generator/java-exec/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
<parent>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-parent</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>

<artifactId>fabric8-maven-generator-java-exec</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>

<name>Fabric8 Maven :: Generator :: Java Exec</name>

Expand Down
4 changes: 2 additions & 2 deletions generator/karaf/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
<parent>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-parent</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>

<artifactId>fabric8-maven-generator-karaf</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>

<name>Fabric8 Maven :: Generator :: Karaf</name>

Expand Down
4 changes: 2 additions & 2 deletions generator/spring-boot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
<parent>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-parent</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>

<artifactId>fabric8-maven-generator-spring-boot</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>

<name>Fabric8 Maven :: Generator :: Spring Boot</name>

Expand Down
4 changes: 2 additions & 2 deletions generator/thorntail-v2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
<parent>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-parent</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>

<artifactId>fabric8-maven-generator-thorntail-v2</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>

<name>Fabric8 Maven :: Generator :: Thorntail v2</name>

Expand Down
4 changes: 2 additions & 2 deletions generator/vertx/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
<parent>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-parent</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>

<artifactId>fabric8-maven-generator-vertx</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>

<name>Fabric8 Maven :: Generator :: Vert.x</name>

Expand Down
4 changes: 2 additions & 2 deletions generator/webapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
<parent>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-parent</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>

<artifactId>fabric8-maven-generator-webapp</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>

<name>Fabric8 Maven :: Generator :: WebApp</name>

Expand Down
4 changes: 2 additions & 2 deletions generator/wildfly-swarm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
<parent>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-parent</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>

<artifactId>fabric8-maven-generator-wildfly-swarm</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>

<name>Fabric8 Maven :: Generator :: WildFly Swarm</name>

Expand Down
4 changes: 2 additions & 2 deletions it/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ for running a single test.
<parent>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-parent</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>

<artifactId>fabric8-maven-it</artifactId>
<version>4.0-SNAPSHOT</version>
<version>4.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Fabric8 Maven :: Integration Tests</name>
Expand Down
Loading