Skip to content
Snippets Groups Projects
Commit 2850276b authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

refactor: use $environment_type & $environment_name

Deprecated $appname and $env dynamic variables with $environment_name & $environment_type
With backward compatibility (legacy vars still usable)
parent e8a6e546
No related branches found
No related tags found
No related merge requests found
......@@ -73,8 +73,8 @@ The OpenShift template uses some global configuration used throughout all jobs.
| `OS_BASE_APP_NAME` | Base application name | `$CI_PROJECT_NAME` ([see GitLab doc](https://docs.gitlab.com/ee/ci/variables/predefined_variables.html)) |
| `OS_SCRIPTS_DIR` | directory where OpenShift scripts (templates, hook scripts) are located | `.` _(root project dir)_ |
| `OS_BASE_TEMPLATE_NAME` | Base OpenShift template name | `openshift` |
| `OS_APP_LABEL` | The OpenShift [label](https://docs.openshift.com/container-platform/3.11/dev_guide/templates.html#writing-labels) set with the `$appname` [dynamic variable](#environment-variables) value. _Advanced usage_ | `app` |
| `OS_ENV_LABEL` | The OpenShift [label](https://docs.openshift.com/container-platform/3.11/dev_guide/templates.html#writing-labels) set with the `$env` [dynamic variable](#environment-variables) value (`review`, `integration`, `staging` or `prod`). _Advanced usage_ | `env` |
| `OS_APP_LABEL` | The OpenShift [label](https://docs.openshift.com/container-platform/3.11/dev_guide/templates.html#writing-labels) set with the `$environment_name` [dynamic variable](#environment-variables) value. _Advanced usage_ | `app` |
| `OS_ENV_LABEL` | The OpenShift [label](https://docs.openshift.com/container-platform/3.11/dev_guide/templates.html#writing-labels) set with the `$environment_type` [dynamic variable](#environment-variables) value (`review`, `integration`, `staging` or `prod`). _Advanced usage_ | `env` |
### Secrets management
......@@ -200,7 +200,7 @@ In this mode, you only have to provide a shell script that fully implements the
The deployment script is searched as follows:
1. look for a specific `os-deploy-$env.sh` in the `$OS_SCRIPTS_DIR` directory in your project (e.g. `os-deploy-staging.sh` for staging environment),
1. look for a specific `os-deploy-$environment_type.sh` in the `$OS_SCRIPTS_DIR` directory in your project (e.g. `os-deploy-staging.sh` for staging environment),
2. if not found: look for a default `os-deploy.sh` in the `$OS_SCRIPTS_DIR` directory in your project,
3. if not found: the GitLab CI template assumes you're using the template-based deployment policy.
......@@ -216,7 +216,7 @@ The template processes the following steps:
1. _optionally_ executes the `os-pre-apply.sh` script in your project to perform specific environment pre-initialization (for e.g. create required services),
2. looks for your OpenShift [template](https://docs.openshift.com/container-platform/3.11/dev_guide/templates.html) file,
[substitutes variables](#environment-variables) and `oc apply` it,
1. look for a specific `openshift-$env.yml` in your project (e.g. `openshift-staging.yml` for staging environment),
1. look for a specific `openshift-$environment_type.yml` in your project (e.g. `openshift-staging.yml` for staging environment),
2. fallbacks to default `openshift.yml`.
3. _optionally_ executes the `os-post-apply.sh` script in your project to perform specific environment post-initialization stuff,
4. _optionally_ executes the `os-readiness-check` to wait & check for the application to be ready (if not found, the template assumes the application was successfully started).
......@@ -243,15 +243,15 @@ In this mode, you only have to provide a shell script that fully implements the
The a deployment script is searched as follows:
1. look for a specific `os-cleanup-$env.sh` in the `$OS_SCRIPTS_DIR` directory in your project (e.g. `os-cleanup-staging.sh` for staging environment),
1. look for a specific `os-cleanup-$environment_type.sh` in the `$OS_SCRIPTS_DIR` directory in your project (e.g. `os-cleanup-staging.sh` for staging environment),
2. if not found: look for a default `os-cleanup.sh` in the `$OS_SCRIPTS_DIR` directory in your project,
3. if not found: the GitLab CI template assumes you're using the template-based cleanup policy.
Your script(s) may/shall use [variables](#environment-variables).
> TIP: a nice way to implement environment cleanup is to declare the label `app=${appname}` on every OpenShift
> TIP: a nice way to implement environment cleanup is to declare the label `app=${environment_name}` on every OpenShift
> object associated to your environment.
> Then environment cleanup can be implemented very easily with command `oc delete all,pvc,is,secret -l "app=${appname}"`
> Then environment cleanup can be implemented very easily with command `oc delete all,pvc,is,secret -l "app=${environment_name}"`
#### 2: template-based cleanup
......@@ -260,7 +260,7 @@ In this mode, you mainly let OpenShift delete all objects from your OpenShift de
The template processes the following steps:
1. _optionally_ executes the `os-pre-cleanup.sh` script in your project to perform specific environment pre-cleanup stuff,
2. deletes **all** objects with label `app=${appname}`<br/>
2. deletes **all** objects with label `app=${environment_name}`<br/>
_works well with template-based deployment as this label is forced during `oc apply`_
3. _optionally_ executes the `os-post-cleanup.sh` script in your project to perform specific environment post-cleanup (for e.g. delete bound services).
......@@ -276,7 +276,7 @@ This is pretty annoying, but as you may see above, deleting an env _may_ require
So, what can be done about that?
1. if your project doesn't require any delete script (in other words deleting all objects with label `app=${appname}` is
1. if your project doesn't require any delete script (in other words deleting all objects with label `app=${environment_name}` is
enough to clean-up everything): you could simply override the cleanup job Git strategy to prevent from fetching the
branch code:
```yaml
......@@ -297,16 +297,16 @@ Part of this complexity can be handled by the lookup policies described above (e
In order to be able to implement some **genericity** in your scripts and templates, you should use environment variables:
1. any [GitLab CI variable](https://docs.gitlab.com/ee/ci/variables/#predefined-environment-variables)
1. any [GitLab CI variable](https://docs.gitlab.com/ee/ci/variables/predefined_variables.html)
(ex: `${CI_ENVIRONMENT_URL}` to retrieve the actual environment exposed route)
2. any [custom variable](https://docs.gitlab.com/ee/ci/variables/#custom-environment-variables)
2. any [custom variable](https://docs.gitlab.com/ee/ci/variables/#add-a-cicd-variable-to-a-project)
(ex: `${SECRET_TOKEN}` that you have set in your project CI/CD variables)
3. **dynamic variables** set by the template:
* `${project}`: the OpenShift project in which application is deployed (ex: `my-openshift-project`)
* `${appname}`: the application target name to use in this environment (ex: `myproject-review-fix-bug-12` or `myproject-staging`)
* `${appname_ssc}`: the application target name in [SCREAMING_SNAKE_CASE](https://en.wikipedia.org/wiki/Snake_case) format
* `${environment_name}`: the application target name to use in this environment (ex: `myproject-review-fix-bug-12` or `myproject-staging`)
* `${environment_name_ssc}`: the application target name in [SCREAMING_SNAKE_CASE](https://en.wikipedia.org/wiki/Snake_case) format
(ex: `MYPROJECT_REVIEW_FIX_BUG_12` or `MYPROJECT_STAGING`)
* `${env}`: the environment type (`review`, `integration`, `staging` or `production`)
* `${environment_type}`: the environment type (`review`, `integration`, `staging` or `production`)
* `${hostname}`: the environment hostname, extracted from `${CI_ENVIRONMENT_URL}` (got from [`environment:url`](https://docs.gitlab.com/ee/ci/yaml/#environmenturl) - see `OS_REVIEW_ENVIRONMENT_SCHEME`, `OS_REVIEW_ENVIRONMENT_DOMAIN`, `OS_STAGING_ENVIRONMENT_URL` and `OS_PROD_ENVIRONMENT_URL`)
#### OpenShift template parameters evaluation
......@@ -316,7 +316,7 @@ shall be variabilized using [parameters](https://docs.openshift.com/container-pl
Parameters are evaluated in the following order:
1. from a (optional) specific `openshift-$env.env` file found in the `$OS_SCRIPTS_DIR` directory of your project,
1. from a (optional) specific `openshift-$environment_type.env` file found in the `$OS_SCRIPTS_DIR` directory of your project,
2. from the (optional) default `openshift.env` file found in the `$OS_SCRIPTS_DIR` directory of your project,
3. from the [environment](#environment-variables) (either predefined GitLab CI, custom or dynamic variables).
......@@ -324,7 +324,7 @@ For example, with the following parameters in your template:
```yaml
parameters:
- name: appname
- name: environment_name
description: "the application target name to use in this environment (provided by GitLab CI template)"
required: true
- name: hostname
......@@ -360,7 +360,7 @@ Then, when deploying to `production`, the parameters will be evaluated as follow
| Parameter | Evaluated from |
| -------------- | --------------------------------------------- |
| `appname` | dynamic variable set by the deployment script |
| `environment_name` | dynamic variable set by the deployment script |
| `hostname` | dynamic variable set by the deployment script |
| `MEMORY` | default `openshift.env` file (undefined in specific `openshift-production.env` file) |
| `INSTANCES` | specific `openshift-production.env` file |
......@@ -518,10 +518,10 @@ stages:
```yaml
# This generic template instantiates all required OpenShift objects
# It uses the following parameters that will be dynamically replaced by the deployment script:
# - ${appname}
# - ${appname_ssc}
# - ${environment_name}
# - ${environment_name_ssc}
# - ${hostname}
# - ${appname}
# - ${environment_name}
apiVersion: v1
kind: Template
metadata:
......@@ -529,10 +529,10 @@ metadata:
description: an OpenShift template for my application
# template parameters
parameters:
- name: appname
- name: environment_name
description: "the application target name to use in this environment (provided by GitLab CI template)"
required: true
- name: appname_ssc
- name: environment_name_ssc
description: "the application target name in SCREAMING_SNAKE_CASE format (provided by GitLab CI template)"
required: true
- name: hostname
......@@ -549,8 +549,8 @@ objects:
annotations:
description: Exposes and load balances the application pods.
labels:
app: ${appname}
name: ${appname}
app: ${environment_name}
name: ${environment_name}
spec:
ports:
- name: http
......@@ -558,7 +558,7 @@ objects:
protocol: TCP
targetPort: 8080
selector:
app: ${appname}
app: ${environment_name}
# === DeploymentConfig
- apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
......@@ -566,13 +566,13 @@ objects:
annotations:
description: The deployment configuration of application.
labels:
app: ${appname}
name: ${appname}
app: ${environment_name}
name: ${environment_name}
spec:
replicas: 1
revisionHistoryLimit: 2
selector:
app: ${appname}
app: ${environment_name}
strategy:
type: Rolling
rollingParams:
......@@ -580,7 +580,7 @@ objects:
template:
metadata:
labels:
app: ${appname}
app: ${environment_name}
spec:
containers:
- image: ${docker_image}
......@@ -601,15 +601,15 @@ objects:
annotations:
description: The route exposes the service at a hostname.
labels:
app: ${appname}
name: ${appname}
app: ${environment_name}
name: ${environment_name}
spec:
host: ${hostname}
port:
targetPort: 8080
to:
kind: Service
name: ${appname}
name: ${environment_name}
```
#### hook scripts
......@@ -625,16 +625,16 @@ post-initialization (for e.g. start build).
set -e
# create a source-to-image binary build if does not exist
oc get buildconfig "$appname" 2> /dev/null || oc new-build openshift/redhat-openjdk18-openshift:1.4 --binary="true" --name="$appname" --labels="app=$appname"
oc get buildconfig "$environment_name" 2> /dev/null || oc new-build openshift/redhat-openjdk18-openshift:1.4 --binary="true" --name="$environment_name" --labels="app=$environment_name"
# prepare build resources
mkdir -p target/openshift/deployments && cp target/my-application-1.0.0-SNAPSHOT.jar target/openshift/deployments/
# trigger build: this will trigger a deployment
oc start-build "$appname" --from-dir=target/openshift --wait --follow
oc start-build "$environment_name" --from-dir=target/openshift --wait --follow
# example for force_rollout
force_rollout $appname
force_rollout $environment_name
```
##### `os-readiness-check.sh`
......
......@@ -35,13 +35,13 @@
},
{
"name": "OS_APP_LABEL",
"description": "The OpenShift [label](https://docs.openshift.com/container-platform/3.11/dev_guide/templates.html#writing-labels) set with the `$appname` dynamic variable.",
"description": "The OpenShift [label](https://docs.openshift.com/container-platform/3.11/dev_guide/templates.html#writing-labels) set with the `$environment_name` dynamic variable.",
"default": "app",
"advanced": true
},
{
"name": "OS_ENV_LABEL",
"description": "The OpenShift [label](https://docs.openshift.com/container-platform/3.11/dev_guide/templates.html#writing-labels) set with the `$env` dynamic variable.",
"description": "The OpenShift [label](https://docs.openshift.com/container-platform/3.11/dev_guide/templates.html#writing-labels) set with the `$environment_type` dynamic variable.",
"default": "env",
"advanced": true
}
......
......@@ -313,11 +313,11 @@ stages:
log_info "--- template: \\e[33;1m${templatefile}\\e[0m"
# evaluate template parameters from environment and dotenv files
param_args=$(build_template_param_args "${OS_SCRIPTS_DIR}/${OS_BASE_TEMPLATE_NAME}.env" "${OS_SCRIPTS_DIR}/${OS_BASE_TEMPLATE_NAME}-${env}.env" < "$templatefile")
param_args=$(build_template_param_args "${OS_SCRIPTS_DIR}/${OS_BASE_TEMPLATE_NAME}.env" "${OS_SCRIPTS_DIR}/${OS_BASE_TEMPLATE_NAME}-${environment_type}.env" < "$templatefile")
# set label 'app' and 'env' on all created objects ($OS_STAGE_LABEL for backwards compatibility)
echo "oc process --labels \"${OS_ENV_LABEL:-${OS_STAGE_LABEL:-env}}=$env,${OS_APP_LABEL:-app}=$appname\" $param_args -f $templatefile"
eval oc process --labels "${OS_ENV_LABEL:-${OS_STAGE_LABEL:-env}}=$env,${OS_APP_LABEL:-app}=$appname" "$param_args" -f "$templatefile" | oc ${TRACE+--loglevel=6} apply -f -
echo "oc process --labels \"${OS_ENV_LABEL:-${OS_STAGE_LABEL:-env}}=$environment_type,${OS_APP_LABEL:-app}=$environment_name\" $param_args -f $templatefile"
eval oc process --labels "${OS_ENV_LABEL:-${OS_STAGE_LABEL:-env}}=$environment_type,${OS_APP_LABEL:-app}=$environment_name" "$param_args" -f "$templatefile" | oc ${TRACE+--loglevel=6} apply -f -
}
function check_readiness() {
......@@ -350,27 +350,35 @@ stages:
# export project as it may be usefull to build image name based on internal registry (ex: docker-registry.default.svc:5000/${project}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_LABEL} )
project=$(oc project -q)
export project
export env=$1
# for backward compatibility
export stage=$1
export appname=$2
# also export appname in SCREAMING_SNAKE_CASE format (may be useful with OpenShift env variables)
appname_ssc=$(to_ssc "$2")
export appname_ssc
export environment_type=$1
export environment_name=$2
# also export environment_name in SCREAMING_SNAKE_CASE format (may be useful with OpenShift env variables)
environment_name_ssc=$(to_ssc "$2")
export environment_name_ssc
# backward compatibility
export env=$environment_type
export stage=$environment_type
export appname=$environment_name
export appname_scc=$environment_name_ssc
# extract hostname from $CI_ENVIRONMENT_URL
hostname=$(echo "$CI_ENVIRONMENT_URL" | awk -F[/:] '{print $4}')
export hostname
log_info "--- \\e[32mdeploy\\e[0m (env: \\e[33;1m${env}\\e[0m)"
log_info "--- looking for OS scripts in directory: \\e[33;1m${OS_SCRIPTS_DIR}\\e[0m"
log_info "--- project: \\e[33;1m${project}\\e[0m"
log_info "--- appname: \\e[33;1m${appname}\\e[0m"
log_info "--- appname_ssc: \\e[33;1m${appname_ssc}\\e[0m"
log_info "--- env: \\e[33;1m${env}\\e[0m"
log_info "--- hostname: \\e[33;1m${hostname}\\e[0m"
log_info "--- \\e[32mdeploy\\e[0m"
log_info "--- \$project: \\e[33;1m${project}\\e[0m"
log_info "--- \$environment_type: \\e[33;1m${environment_type}\\e[0m"
log_info "--- \$environment_name: \\e[33;1m${environment_name}\\e[0m"
log_info "--- \$environment_name_ssc: \\e[33;1m${environment_name_ssc}\\e[0m"
log_info "--- \$hostname: \\e[33;1m${hostname}\\e[0m"
# unset any upstream deployment env & artifacts
rm -f openshift.env
rm -f environment_url.txt
# maybe execute deploy script
deployscript=$(ls -1 "$OS_SCRIPTS_DIR/os-deploy-${env}.sh" 2>/dev/null || ls -1 "$OS_SCRIPTS_DIR/os-deploy.sh" 2>/dev/null || echo "")
deployscript=$(ls -1 "$OS_SCRIPTS_DIR/os-deploy-${environment_type}.sh" 2>/dev/null || ls -1 "$OS_SCRIPTS_DIR/os-deploy.sh" 2>/dev/null || echo "")
if [[ -f "$deployscript" ]]
then
log_info "--- deploy script (\\e[33;1m${deployscript}\\e[0m) found: execute"
......@@ -380,7 +388,7 @@ stages:
log_info "--- no deploy script found: run template-based deployment"
# find template
templatefile=$(ls -1 "$OS_SCRIPTS_DIR/${OS_BASE_TEMPLATE_NAME}-${env}.yml" 2>/dev/null || ls -1 "$OS_SCRIPTS_DIR/${OS_BASE_TEMPLATE_NAME}.yml" 2>/dev/null || echo "")
templatefile=$(ls -1 "$OS_SCRIPTS_DIR/${OS_BASE_TEMPLATE_NAME}-${environment_type}.yml" 2>/dev/null || ls -1 "$OS_SCRIPTS_DIR/${OS_BASE_TEMPLATE_NAME}.yml" 2>/dev/null || echo "")
if [[ -z "$templatefile" ]]
then
log_error "--- no template"
......@@ -398,7 +406,7 @@ stages:
# finally persist environment url
echo "$CI_ENVIRONMENT_URL" > environment_url.txt
echo -e "environment_type=$env\\nenvironment_name=$appname\\nenvironment_url=$CI_ENVIRONMENT_URL" > openshift.env
echo -e "environment_type=$environment_type\\nenvironment_name=$environment_name\\nenvironment_url=$CI_ENVIRONMENT_URL" > openshift.env
}
# $1 deployment name
......@@ -463,21 +471,25 @@ stages:
}
function delete() {
export env=$1
# for backward compatibility
export stage=$1
export appname=$2
# also export appname in SCREAMING_SNAKE_CASE format (may be useful with OpenShift env variables)
appname_ssc=$(to_ssc "$2")
export appname_ssc
log_info "--- \\e[32mdelete\\e[0m (env: ${env})"
log_info "--- appname: \\e[33;1m${appname}\\e[0m"
log_info "--- appname_ssc: \\e[33;1m${appname_ssc}\\e[0m"
log_info "--- env: \\e[33;1m${env}\\e[0m"
export environment_type=$1
export environment_name=$2
# also export environment_name in SCREAMING_SNAKE_CASE format (may be useful with OpenShift env variables)
environment_name_ssc=$(to_ssc "$2")
export environment_name_ssc
# backward compatibility
export env=$environment_type
export stage=$environment_type
export appname=$environment_name
export appname_scc=$environment_name_ssc
log_info "--- \\e[32mdelete"
log_info "--- \$environment_type: \\e[33;1m${environment_type}\\e[0m"
log_info "--- \$environment_name: \\e[33;1m${environment_name}\\e[0m"
log_info "--- \$environment_name_ssc: \\e[33;1m${environment_name_ssc}\\e[0m"
# maybe execute cleanup script
cleanupscript=$(ls -1 "$OS_SCRIPTS_DIR/os-cleanup-${env}.sh" 2>/dev/null || ls -1 "$OS_SCRIPTS_DIR/os-cleanup.sh" 2>/dev/null || echo "")
cleanupscript=$(ls -1 "$OS_SCRIPTS_DIR/os-cleanup-${environment_type}.sh" 2>/dev/null || ls -1 "$OS_SCRIPTS_DIR/os-cleanup.sh" 2>/dev/null || echo "")
if [[ -f "$cleanupscript" ]]
then
log_info "--- cleanup script (\\e[33;1m${cleanupscript}\\e[0m) found: execute"
......@@ -499,8 +511,8 @@ stages:
# delete app
log_info "--- \\e[32moc delete\\e[0m"
# delete all objects with label 'app=$appname'
oc ${TRACE+--loglevel=6} delete "${OS_CLEANUP_OBJECT_TYPES}" --selector "${OS_APP_LABEL:-app}=$appname"
# delete all objects with label 'app=$environment_name'
oc ${TRACE+--loglevel=6} delete "${OS_CLEANUP_OBJECT_TYPES}" --selector "${OS_APP_LABEL:-app}=$environment_name"
# maybe execute post cleanup script
postscript="$OS_SCRIPTS_DIR/os-post-cleanup.sh"
......@@ -516,23 +528,25 @@ stages:
}
function delete_all() {
export env=$1
appnameproto=$2
# make appname regex by replacing $CI_COMMIT_REF_SLUG with .*
appnameregex=$(echo "$appnameproto" | sed -r "s/$CI_COMMIT_REF_SLUG/.*/g")
export environment_type=$1
environment_nameproto=$2
# make environment_name regex by replacing $CI_COMMIT_REF_SLUG with .*
environment_nameregex=$(echo "$environment_nameproto" | sed -r "s/$CI_COMMIT_REF_SLUG/.*/g")
# list services | remove 1st line | pick 7th column (selector) | filter services with label "app=$regex"
matchingselectors=$(oc get svc -o wide | tail -n +2 | awk '{print $7}' | awk "/${OS_APP_LABEL:-app}=$appnameregex/ {print \$1}")
matchingselectors=$(oc get svc -o wide | tail -n +2 | awk '{print $7}' | awk "/${OS_APP_LABEL:-app}=$environment_nameregex/ {print \$1}")
matchcount=$(echo "$matchingselectors" | wc -w)
log_info "--- \\e[32mdelete all\\e[0m (env: \\e[33;1m${env}\\e[0m, appname matcher: \\e[33;1m${appnameregex}\\e[0m): \\e[33;1m${matchcount}\\e[0m apps found"
log_info "--- \\e[32mdelete all"
log_info "--- \$environment_type: \\e[33;1m${environment_type}\\e[0m"
log_info "--- environment name matcher: \\e[33;1m${environment_nameregex}\\e[0m (\\e[33;1m${matchcount}\\e[0m apps found)"
rc=0
for appselector in $matchingselectors
do
# extract review appname from selector (can be 'app=name,env=env,foo=bar')
# extract review environment_name from selector (can be 'app=name,env=env,foo=bar')
matchingapp=$(echo "$appselector" | sed -E "s/${OS_APP_LABEL:-app}=([^,]*).*/\\1/")
echo -e "\\e[1;93m-------------------------------------------------------------------------------\\e[0m"
if ! delete "$env" "$matchingapp"
if ! delete "$environment_type" "$matchingapp"
then
log_warn "... failed deleting review app \\e[33;1m${matchingapp}\\e[0m (see logs)"
rc=1
......
......@@ -3,4 +3,4 @@ SOURCE_REPOSITORY_URL The URL of the repository with your application source c
GITHUB_WEBHOOK_SECRET A secret string used to configure the GitHub webhook expression [a-zA-Z0-9]{40}
REPLICA_COUNT Number of replicas to run 2
TLS_CERTIFICATE TLS certificate to use by the server
appname the application target name to use in this environment (provided by GitLab CI template)
environment_name the application target name to use in this environment (provided by GitLab CI template)
......@@ -39,7 +39,7 @@ parameters:
- name: TLS_CERTIFICATE
description: TLS certificate to use by the server
required: true
- name: appname
- name: environment_name
description: Application name (dynamically provided by the template)
required: true
message: "... The GitHub webhook secret is ${GITHUB_WEBHOOK_SECRET} ..."
......@@ -22,35 +22,35 @@ function teardown() {
@test "read template parameters should read template and print only environment variables required by template" {
# GIVEN
export appname=test-app
export environment_name=test-app
# WHEN
run build_template_param_args test/fixtures/openshift.env test/fixtures/openshift-production.env < test/fixtures/template_with_parameters.yml
# THEN
assert_output '--param SOURCE_REPOSITORY_URL="the-repository-url" --param GITHUB_WEBHOOK_SECRET="prod-secret" --param REPLICA_COUNT="2" --param TLS_CERTIFICATE="$PROD_TLS_CERTIFICATE" --param appname="$appname" '
assert_output '--param SOURCE_REPOSITORY_URL="the-repository-url" --param GITHUB_WEBHOOK_SECRET="prod-secret" --param REPLICA_COUNT="2" --param TLS_CERTIFICATE="$PROD_TLS_CERTIFICATE" --param environment_name="$environment_name" '
}
@test "read template parameters with only one dotenv file" {
# GIVEN
export appname=test-app
export environment_name=test-app
# WHEN
run build_template_param_args test/fixtures/openshift.env test/fixtures/openshift-integration.env < test/fixtures/template_with_parameters.yml
# THEN
assert_output '--param SOURCE_REPOSITORY_URL="the-repository-url" --param GITHUB_WEBHOOK_SECRET="dev-secret" --param REPLICA_COUNT="1" --param TLS_CERTIFICATE="$DEV_TLS_CERTIFICATE" --param appname="$appname" '
assert_output '--param SOURCE_REPOSITORY_URL="the-repository-url" --param GITHUB_WEBHOOK_SECRET="dev-secret" --param REPLICA_COUNT="1" --param TLS_CERTIFICATE="$DEV_TLS_CERTIFICATE" --param environment_name="$environment_name" '
}
@test "read template parameters with no dotenv file" {
# GIVEN
export appname=test-app
export environment_name=test-app
# WHEN
run build_template_param_args test/fixtures/openshift-global.env test/fixtures/openshift-integration.env < test/fixtures/template_with_parameters.yml
# THEN
assert_output '--param appname="$appname" '
assert_output '--param environment_name="$environment_name" '
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment