Skip to content

Commit

Permalink
Issue #4: Changing design
Browse files Browse the repository at this point in the history
  • Loading branch information
jdewinne committed Feb 1, 2017
1 parent b240648 commit 236df2c
Show file tree
Hide file tree
Showing 23 changed files with 279 additions and 212 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ deploy:
provider: releases
api_key:
secure: VCLFgZ77ppDlMEM/Z6KiwG0MsW4SxVBlI3cgTn/L+1F6PWj9J40bT4Gp11ymydiO1P6GdPsBqUcBjo0KbeNmC6DdjEvAoJKrcBEH5w4OB0xk65ckBs4XOh6NLliMHHc9cLgo6nMNaFp04UGfngMxardani/CL4X+Llid04lQJls=
file: build/distributions/xld-openshift-plugin-6.5.0.xldp
file: build/distributions/xld-openshift-plugin-7.0.0.xldp
skip_cleanup: true
on:
all_branches: true
Expand Down
37 changes: 25 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ See the **XL Deploy Reference Manual** for background information on XL Deploy a

# Overview #

This XLD OpenShift plugin supports v2 & v3 OpenShift implementations. This plugin allows you to manage the deployment of OpenShift projects, containers and resources to your OpenShift infrastructure. Additionaly this plugin still supports doing WAR deployment to OpenShift JBoss gear. It uses rhc client to push to OpenShift environments.
This XLD OpenShift plugin supports v2 & v3 OpenShift implementations. This plugin allows you to manage the deployment of OpenShift projects, containers and resources to your OpenShift infrastructure. Additionally this plugin still supports doing WAR deployment to OpenShift JBoss gear. It uses rhc client to push to OpenShift environments.

# Requirements #

* **Requirements**
* **XL Deploy** 5.1.3+
* From version v7.x+, XLD 6.x is required.
* **Remark**: version v7.x+ breaks compatibility with previous versions!
* **rhc client on target machine for OpenShift v2**
* **oc client on target machine for OpenShift v3**

Expand All @@ -43,7 +44,7 @@ utility on a server.
* OpenShift Containers

* **openshift.Server**
The `openshift.server` represents the Open Shift server and is the container where the open shift `oc` commands will be exectued. The `openshift.Server` container object is defined as follows:
The `openshift.server` represents the OpenShift server and is the container where the open shift `oc` commands will be exectued. The `openshift.Server` container object is defined as follows:
`openshift.Server` extends `udm.BaseContainer`
Expand Down Expand Up @@ -95,24 +96,36 @@ utility on a server.
# Classpath Resources
openshift.Server.wgetExecutable=[Put your path here]
```
* OpenShift Deployables
* **openshift.Project:**
An OpenShift project Module. The project module is defined as follows:
* **openshift.Project**
An OpenShift project. The project module is defined as follows:

`openshift.ProjectModule` extends `udm.BasedDeployed`
`openshift.Project` extends `udm.BaseContainer`

| Properties | Description |
|-----------------|------------------------------------------|
| projectName | A name for the project |
| description | A description of this project |
| projectDisplayName | A human readable name for the project |

* OpenShift Provisionables
* **openshift.openshift.ProjectSpec**
An OpenShift project spec. The project spec is defined as follows:

`openshift.ProjectSpec` extends `udm.BaseProvisionable`

* **openshift.App:**
| Properties | Description |
|-----------------|------------------------------------------|
| projectName | A name for the project |
| description | A description of this project |
| projectDisplayName | A human readable name for the project |

* OpenShift Deployables

* **openshift.App**
The OpenShift App is a container image that can be deployed from a registry. By default XLD will deploy container images from the Docker Hub, but it is possible to supply and internal URL for a local repository. The App module is defined as follows:

`openshift.App` extends `udm.BaseDeployed`
`openshift.App` extends `udm.BaseDeployable`

| Properties | Description |
|--------------------|-----------------------------------|
Expand All @@ -128,7 +141,7 @@ utility on a server.
* **openshift.BinaryApp:**
An OpenShift Binary App is an actual container file that should be deployed to a OpenShift project. The Binary App module is defined as follows:

`openshift.BinaryAppModule` extends `udm.BasedDeployedArtifact`
`openshift.BinaryAppModule` extends `udm.BaseDeployableArtifact`

| Properties | Description |
|---------------------|-----------------------------------|
Expand All @@ -139,7 +152,7 @@ utility on a server.
* **openshift.DockerfileApp:**
An OpenShift Docker App is an actual Dockerfile that should be deployed to a OpenShift project. The Dockerfile app module is defined as follows:

`openshift.DockerfileAppModule` extends `udm.BasedDeployedArtifact`
`openshift.DockerfileAppModule` extends `udm.BaseDeployableArtifact`

| Properties | Description |
|---------------------|-----------------------------------|
Expand All @@ -148,7 +161,7 @@ utility on a server.
* **openshift.ResourceModule:** The resource module defines the resources availble to the project. The definition of the resources are defined in a YAML file attached to this deployable. The Resource Modules is defined as follows:

`openshift.ResourceModule` extends `udm.BaseDeployedArtifact`
`openshift.ResourceModule` extends `udm.BaseDeployableArtifact`

| Properties | Description |
|---------------------|-----------------------------------|
Expand Down
45 changes: 23 additions & 22 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,51 +1,52 @@
import org.apache.tools.ant.filters.ReplaceTokens

plugins {
id "com.github.hierynomus.license" version "0.13.0"
id "com.xebialabs.xldp" version "1.0.5"
id "com.xebialabs.xl.docker" version "1.0.0"
id "com.github.hierynomus.license" version "0.13.0"
id "com.xebialabs.xldp" version "1.0.5"
id "com.xebialabs.xl.docker" version "1.0.0"
}

xlDocker {
compileImage = 'xebialabs/xld_dev_compile'
compileVersion = 'v6.0.2.1'
compileVersion = 'v6.1.0.1'
runImage = 'xebialabs/xld_dev_run'
runVersion = 'v6.0.2.1'
runVersion = 'v6.1.0.1'
runPortMapping = '14516:4516'
}

version="6.5.0"
version = "7.0.0"

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'maven'

def apiVersion = '2015.6.3'
def apiVersion = '2016.2.2'

repositories {
mavenLocal()
mavenCentral()
maven {
credentials {
username 'community-plugins'
password 'community'
}
url 'http://nexus.xebialabs.com/nexus/content/repositories/releases'
mavenLocal()
mavenCentral()
maven {
credentials {
username 'community-plugins'
password 'community'
}
url 'http://nexus.xebialabs.com/nexus/content/repositories/releases'
}
}

dependencies {
compile "com.xebialabs.deployit:udm-plugin-api:$apiVersion"
compile "com.xebialabs.deployit:udm-plugin-api:$apiVersion"
}

processResources.configure {
filter ReplaceTokens, tokens: [
'project.version': version.toString(),
'project.name': rootProject.name
]
filter ReplaceTokens, tokens: [
'project.version': version.toString(),
'project.name' : rootProject.name
]
}

license {
header rootProject.file('src/main/license/xebialabs_community.license')
strictCheck true
header rootProject.file('src/main/license/xebialabs_community.license')
strictCheck true
}
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Jan 03 13:04:20 PST 2017
#Tue Jan 31 16:24:16 PST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-all.zip
12 changes: 6 additions & 6 deletions src/main/resources/openshift/deploy-app-module.bat.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
FOR A PARTICULAR PURPOSE. THIS CODE AND INFORMATION ARE NOT SUPPORTED BY XEBIALABS.
-->
<#assign container=deployed.container />
<#assign container=deployed.container.server />
<#include "/openshift/oc-login-container.ftl">

${deployed.container.ocHome}/oc project ${deployed.project} || goto :error
${deployed.container.server.ocHome}/oc project ${deployed.container.projectName} || goto :error

<#-- determine if this app already exists, if not deploy a new one -->
echo "create new app automatically"
${deployed.container.ocHome}/oc new-app <#if deployed.dockerUrl?has_content>${deployed.dockerUrl}/</#if><#if deployed.dockerOrganization?has_content>${deployed.dockerOrganization}/</#if>${deployed.dockerName}<#if deployed.dockerTag?has_content>:${deployed.dockerTag}</#if> --name=${deployed.appName} || goto :error
${deployed.container.ocHome}/oc expose service ${deployed.appName} || goto :error
${deployed.container.ocHome}/oc status || goto :error
${deployed.container.ocHome}/oc logout || goto :error
${deployed.container.server.ocHome}/oc new-app <#if deployed.dockerUrl?has_content>${deployed.dockerUrl}/</#if><#if deployed.dockerOrganization?has_content>${deployed.dockerOrganization}/</#if>${deployed.dockerName}<#if deployed.dockerTag?has_content>:${deployed.dockerTag}</#if> --name=${deployed.appName} || goto :error
${deployed.container.server.ocHome}/oc expose service ${deployed.appName} || goto :error
${deployed.container.server.ocHome}/oc status || goto :error
${deployed.container.server.ocHome}/oc logout || goto :error
goto :EOF

<#include "/openshift/error.bat.ftl">
12 changes: 6 additions & 6 deletions src/main/resources/openshift/deploy-app-module.sh.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
-->
#!/bin/sh
set -e
<#assign container=deployed.container />
<#assign container=deployed.container.server />
<#include "/openshift/oc-login-container.ftl">

${deployed.container.ocHome}/oc project ${deployed.project}
${deployed.container.server.ocHome}/oc project ${deployed.container.projectName}

# determine if this app already exists, if not deploy a new one
echo "create new app automatically"
${deployed.container.ocHome}/oc new-app <#if deployed.dockerUrl?has_content>${deployed.dockerUrl}/</#if><#if deployed.dockerOrganization?has_content>${deployed.dockerOrganization}/</#if>${deployed.dockerName}<#if deployed.dockerTag?has_content>:${deployed.dockerTag}</#if> --name=${deployed.appName}
${deployed.container.ocHome}/oc expose service ${deployed.appName}
${deployed.container.ocHome}/oc status
${deployed.container.ocHome}/oc logout
${deployed.container.server.ocHome}/oc new-app <#if deployed.dockerUrl?has_content>${deployed.dockerUrl}/</#if><#if deployed.dockerOrganization?has_content>${deployed.dockerOrganization}/</#if>${deployed.dockerName}<#if deployed.dockerTag?has_content>:${deployed.dockerTag}</#if> --name=${deployed.appName}
${deployed.container.server.ocHome}/oc expose service ${deployed.appName}
${deployed.container.server.ocHome}/oc status
${deployed.container.server.ocHome}/oc logout
16 changes: 8 additions & 8 deletions src/main/resources/openshift/deploy-binary-app-module.bat.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
FOR A PARTICULAR PURPOSE. THIS CODE AND INFORMATION ARE NOT SUPPORTED BY XEBIALABS.
-->
<#assign container=deployed.container />
<#assign container=deployed.container.server />
<#include "/openshift/oc-login-container.ftl">

${deployed.container.ocHome}/oc project ${deployed.project} || goto :error
${deployed.container.server.ocHome}/oc project ${deployed.container.projectName} || goto :error

<#-- determine if this app already exists, if not deploy a new one -->
echo "create new app automatically"
mkdir deployments
copy "${deployed.file.path}" deployments
${deployed.container.ocHome}/oc new-build --image-stream=${deployed.imageStream} --binary=true --name=${deployed.appName} || goto :error
${deployed.container.ocHome}/oc start-build ${deployed.appName} --from-dir=. || goto :error
${deployed.container.ocHome}/oc new-app --name=${deployed.appName} || goto :error
${deployed.container.ocHome}/oc expose svc ${deployed.appName} || goto :error
${deployed.container.ocHome}/oc status || goto :error
${deployed.container.server.ocHome}/oc new-build --image-stream=${deployed.imageStream} --binary=true --name=${deployed.appName} || goto :error
${deployed.container.server.ocHome}/oc start-build ${deployed.appName} --from-dir=. || goto :error
${deployed.container.server.ocHome}/oc new-app --name=${deployed.appName} || goto :error
${deployed.container.server.ocHome}/oc expose svc ${deployed.appName} || goto :error
${deployed.container.server.ocHome}/oc status || goto :error
rmdir /s /q deployments
${deployed.container.ocHome}/oc logout || goto :error
${deployed.container.server.ocHome}/oc logout || goto :error
goto :EOF

<#include "/openshift/error.bat.ftl">
16 changes: 8 additions & 8 deletions src/main/resources/openshift/deploy-binary-app-module.sh.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
-->
#!/bin/sh
set -e
<#assign container=deployed.container />
<#assign container=deployed.container.server />
<#include "/openshift/oc-login-container.ftl">

${deployed.container.ocHome}/oc project ${deployed.project}
${deployed.container.server.ocHome}/oc project ${deployed.container.projectName}

# determine if this app already exists, if not deploy a new one
echo "create new app automatically"
mkdir -p deployments
cp "${deployed.file.path}" deployments
${deployed.container.ocHome}/oc new-build --image-stream=${deployed.imageStream} --binary=true --name=${deployed.appName}
${deployed.container.ocHome}/oc start-build ${deployed.appName} --from-dir=.
${deployed.container.ocHome}/oc new-app --name=${deployed.appName}
${deployed.container.ocHome}/oc expose svc ${deployed.appName}
${deployed.container.ocHome}/oc status
${deployed.container.server.ocHome}/oc new-build --image-stream=${deployed.imageStream} --binary=true --name=${deployed.appName}
${deployed.container.server.ocHome}/oc start-build ${deployed.appName} --from-dir=.
${deployed.container.server.ocHome}/oc new-app --name=${deployed.appName}
${deployed.container.server.ocHome}/oc expose svc ${deployed.appName}
${deployed.container.server.ocHome}/oc status
rm -rf deployments
${deployed.container.ocHome}/oc logout
${deployed.container.server.ocHome}/oc logout
20 changes: 10 additions & 10 deletions src/main/resources/openshift/deploy-dockerfile-app-module.bat.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@
FOR A PARTICULAR PURPOSE. THIS CODE AND INFORMATION ARE NOT SUPPORTED BY XEBIALABS.
-->
<#assign container=deployed.container />
<#assign container=deployed.container.server />
<#include "/openshift/oc-login-container.ftl">

${deployed.container.ocHome}/oc project ${deployed.project} || goto :error
${deployed.container.server.ocHome}/oc project ${deployed.container.projectName} || goto :error

echo "Check if build config already exists"
SET check=${deployed.container.ocHome}/oc get bc ${deployed.appName} --output=name | grep ${deployed.appName} || echo "nobuildconfig"
SET check=${deployed.container.server.ocHome}/oc get bc ${deployed.appName} --output=name | grep ${deployed.appName} || echo "nobuildconfig"
SET expected=buildconfig/${deployed.appName}
if "%check%"=="%expected%" (
echo "Build config already exists"
${deployed.container.ocHome}/oc start-build ${deployed.appName} --from-file=${deployed.file.path} --follow=true || goto :error
${deployed.container.server.ocHome}/oc start-build ${deployed.appName} --from-file=${deployed.file.path} --follow=true || goto :error
) else (
echo "Build config doesn't exist yet. Creating."
${deployed.container.ocHome}/oc new-build --strategy=docker --binary=true --name=${deployed.appName} || goto :error
${deployed.container.ocHome}/oc start-build ${deployed.appName} --from-file=${deployed.file.path} --follow=true || goto :error
${deployed.container.ocHome}/oc new-app --name=${deployed.appName} || goto :error
${deployed.container.ocHome}/oc expose svc ${deployed.appName} || goto :error
${deployed.container.server.ocHome}/oc new-build --strategy=docker --binary=true --name=${deployed.appName} || goto :error
${deployed.container.server.ocHome}/oc start-build ${deployed.appName} --from-file=${deployed.file.path} --follow=true || goto :error
${deployed.container.server.ocHome}/oc new-app --name=${deployed.appName} || goto :error
${deployed.container.server.ocHome}/oc expose svc ${deployed.appName} || goto :error
)

${deployed.container.ocHome}/oc status || goto :error
${deployed.container.ocHome}/oc logout || goto :error
${deployed.container.server.ocHome}/oc status || goto :error
${deployed.container.server.ocHome}/oc logout || goto :error
goto :EOF

<#include "/openshift/error.bat.ftl">
Expand Down
20 changes: 10 additions & 10 deletions src/main/resources/openshift/deploy-dockerfile-app-module.sh.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@
-->
#!/bin/sh
set -e
<#assign container=deployed.container />
<#assign container=deployed.container.server />
<#include "/openshift/oc-login-container.ftl">

${deployed.container.ocHome}/oc project ${deployed.project}
${deployed.container.server.ocHome}/oc project ${deployed.container.projectName}

echo "Check if build config already exists"
check=$(${deployed.container.ocHome}/oc get bc ${deployed.appName} --output=name | grep ${deployed.appName}) || echo "nobuildconfig"
check=$(${deployed.container.server.ocHome}/oc get bc ${deployed.appName} --output=name | grep ${deployed.appName}) || echo "nobuildconfig"
expected=buildconfig/${deployed.appName}
if [ "$check" = "$expected" ] ; then
echo "Build config already exists"
${deployed.container.ocHome}/oc start-build ${deployed.appName} --from-file=${deployed.file.path} --follow=true
${deployed.container.server.ocHome}/oc start-build ${deployed.appName} --from-file=${deployed.file.path} --follow=true
else
echo "Build config doesn't exist yet. Creating."
${deployed.container.ocHome}/oc new-build --strategy=docker --binary=true --name=${deployed.appName}
${deployed.container.ocHome}/oc start-build ${deployed.appName} --from-file=${deployed.file.path} --follow=true
${deployed.container.ocHome}/oc new-app --name=${deployed.appName}
${deployed.container.ocHome}/oc expose svc ${deployed.appName}
${deployed.container.server.ocHome}/oc new-build --strategy=docker --binary=true --name=${deployed.appName}
${deployed.container.server.ocHome}/oc start-build ${deployed.appName} --from-file=${deployed.file.path} --follow=true
${deployed.container.server.ocHome}/oc new-app --name=${deployed.appName}
${deployed.container.server.ocHome}/oc expose svc ${deployed.appName}
fi

${deployed.container.ocHome}/oc status
${deployed.container.ocHome}/oc logout
${deployed.container.server.ocHome}/oc status
${deployed.container.server.ocHome}/oc logout
10 changes: 5 additions & 5 deletions src/main/resources/openshift/deploy-resource-module.bat.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
FOR A PARTICULAR PURPOSE. THIS CODE AND INFORMATION ARE NOT SUPPORTED BY XEBIALABS.
-->
<#assign container=deployed.container />
<#assign container=deployed.container.server />
<#include "/openshift/oc-login-container.ftl">

${deployed.container.ocHome}/oc project ${deployed.project} || goto :error
${deployed.container.server.ocHome}/oc project ${deployed.container.projectName} || goto :error

<#-- determine if this app already exists, if not deploy a new one -->
echo "create new resource"
${deployed.container.ocHome}/oc create -f ${deployed.file.path} -n ${deployed.project} || goto :error
${deployed.container.ocHome}/oc status || goto :error
${deployed.container.ocHome}/oc logout || goto :error
${deployed.container.server.ocHome}/oc create -f ${deployed.file.path} -n ${deployed.container.projectName} || goto :error
${deployed.container.server.ocHome}/oc status || goto :error
${deployed.container.server.ocHome}/oc logout || goto :error
goto :EOF

<#include "/openshift/error.bat.ftl">
Loading

0 comments on commit 236df2c

Please sign in to comment.