Skip to content

Commit

Permalink
Adding custom preparation step for provisioning service
Browse files Browse the repository at this point in the history
  • Loading branch information
adarshdubey-star committed Dec 9, 2024
1 parent 244517f commit 0b6f396
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 5 deletions.
32 changes: 30 additions & 2 deletions pipelines/basic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ spec:
- name: URL
type: string
description: URL of the Git repository use for fetching the tasks
default: 'https://github.com/RedHatInsights/bonfire-tekton'
default: 'https://github.com/RHEnVision/bonfire-tekton'
- name: REVISION
type: string
description: Git commit revision to use for fetching the tasks
Expand Down Expand Up @@ -132,6 +132,10 @@ spec:
type: string
description: "Tag of the iqe image to run tests from"
default: ""
- name: CUSTOM_PREPARATION_TASK_NAME
type: string
description: "Custom preparation task to run before running the tests"
default: "noop"
results:
- name: ARTIFACTS_URL
description: URL for the test's artifacts
Expand Down Expand Up @@ -213,6 +217,27 @@ spec:
value: "$(params.REVISION)"
- name: pathInRepo
value: tasks/deploy.yaml
- name: custom-preparation
params:
- name: NS
value: "$(tasks.reserve-namespace.results.NS)"
- name: NS_REQUESTER
value: "$(context.pipelineRun.name)"
- name: EPHEMERAL_ENV_PROVIDER_SECRET
value: "$(params.EPHEMERAL_ENV_PROVIDER_SECRET)"
- name: BONFIRE_IMAGE
value: "$(params.BONFIRE_IMAGE)"
taskRef:
resolver: git
params:
- name: url
value: "$(params.URL)"
- name: revision
value: "$(params.REVISION)"
- name: pathInRepo
value: tasks/$(params.CUSTOM_PREPARATION_TASK_NAME).yaml
runAfter:
- deploy-application
- name: run-iqe-cji
params:
- name: BONFIRE_IMAGE
Expand Down Expand Up @@ -245,6 +270,8 @@ spec:
value: "$(params.IQE_ENV)"
- name: IQE_ENV_VARS
value: "$(params.IQE_ENV_VARS)"
- name: IQE_ENV_VARS_SUBSTITUTE
value: "$(tasks.custom-preparation.results.iqe-additional-env-vars)"
- name: IQE_SELENIUM
value: "$(params.IQE_SELENIUM)"
- name: IQE_PARALLEL_ENABLED
Expand All @@ -259,6 +286,7 @@ spec:
value: "$(params.IQE_IMAGE_TAG)"
runAfter:
- deploy-application
- custom-preparation
taskRef:
resolver: git
params:
Expand All @@ -267,4 +295,4 @@ spec:
- name: revision
value: "$(params.REVISION)"
- name: pathInRepo
value: tasks/run-iqe-cji.yaml
value: tasks/run-iqe-cji.yaml
3 changes: 2 additions & 1 deletion pipelines/basic_no_iqe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ spec:
- name: URL
type: string
description: URL of the Git repository use for fetching the tasks
default: 'https://github.com/RedHatInsights/bonfire-tekton'
default: 'https://github.com/RHEnVision/bonfire-tekton'
- name: REVISION
type: string
description: Git commit revision to use for fetching the tasks
Expand Down Expand Up @@ -154,3 +154,4 @@ spec:
value: "$(params.REVISION)"
- name: pathInRepo
value: tasks/deploy.yaml

2 changes: 1 addition & 1 deletion tasks/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,4 @@ spec:
EXTRA_DEPLOY_ARGS+=" $(parse-snapshot.py) "
fi
export EXTRA_DEPLOY_ARGS
deploy.sh "$(params.NS)" "$(params.NS_REQUESTER)"
deploy.sh "$(params.NS)" "$(params.NS_REQUESTER)"
16 changes: 16 additions & 0 deletions tasks/noop.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: noop
spec:
results:
- name: iqe-additional-env-vars
description: ""
steps:
- name: noop-preparation
image: ubuntu
script: |
#!/bin/bash
echo "Noop - skipping - no preparation needed"
echo -n "" > $(results.iqe-additional-env-vars.path)
104 changes: 104 additions & 0 deletions tasks/preparation-provisioning.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: preparation-provisioning
spec:
params:
- name : BONFIRE_IMAGE
type: string
description: The container Bonfire image to use for the tekton tasks
default: quay.io/redhat-services-prod/hcm-eng-prod-tenant/cicd-tools:bb80105
- name: CUSTOM_IMAGE
type: string
description: The container image to use for the provisioning setup task
default: quay.io/envision/provisioning-cicd:latest
- name: NS
type: string
description: Namespace name to deploy the application to
- name: NS_REQUESTER
type: string
description: The name of the person/pipeline that requested the namespace
- name: EPHEMERAL_ENV_PROVIDER_SECRET
type: string
default: ephemeral-env-provider
description: "Secret for connecting to ephemeral env provider cluster"
- name: AWS_ACCOUNT_ID_SECRET
type: string
description: Secret containing the AWS Account ID
default: provisioning-aws-account-id
- name: AZURE_TENANT_ID_SECRET
type: string
description: Secret containing the AZURE Tenant ID
default: provisioning-azure-secrets
- name: AZURE_SUBSCRIPTION_ID_SECRET
type: string
description: Secret containing the AZURE Subscription ID
default: provisioning-azure-secrets
- name: AZURE_RESOURCE_GROUP_SECRET
type: string
description: Secret containing the AZURE Resource Group
default: provisioning-azure-secrets
results:
- name: iqe-additional-env-vars
description: ""
steps:
- name: provisioning-setup
image: "$(params.CUSTOM_IMAGE)"
env:
- name: OC_LOGIN_TOKEN
valueFrom:
secretKeyRef:
name: $(params.EPHEMERAL_ENV_PROVIDER_SECRET)
key: token
- name: OC_LOGIN_SERVER
valueFrom:
secretKeyRef:
name: $(params.EPHEMERAL_ENV_PROVIDER_SECRET)
key: url
- name: AWS_ACCOUNT_ID
valueFrom:
secretKeyRef:
name: $(params.AWS_ACCOUNT_ID_SECRET)
key: AWS_ACCOUNT_ID
- name: AZURE_TENANT_ID
valueFrom:
secretKeyRef:
name: $(params.AZURE_TENANT_ID_SECRET)
key: AZURE_TENANT_ID
- name: AZURE_SUBSCRIPTION_ID
valueFrom:
secretKeyRef:
name: $(params.AZURE_SUBSCRIPTION_ID_SECRET)
key: AZURE_SUBSCRIPTION_ID
- name: AZURE_RESOURCE_GROUP
valueFrom:
secretKeyRef:
name: $(params.AZURE_RESOURCE_GROUP_SECRET)
key: AZURE_RESOURCE_GROUP
- name: BONFIRE_BOT
value: "true"
script: |
#!/bin/bash
set -ex
echo "Running login.sh script"
# running login directly
# TODO: switch to using https://github.com/RedHatInsights/cicd-tools/blob/aea5d464a40d9ada1e03f76ff85cb6c5d0deb7e2/konflux_scripts/login.sh
echo "Login to ephemeral cluster"
server="${OC_LOGIN_SERVER:?OC_LOGIN_SERVER env var was not defined}"
token="${OC_LOGIN_TOKEN:?OC_LOGIN_SERVER env var was not defined}"
oc login --token="$token" --server="$server"
oc project "$(params.NS)"
export AWS_ACCOUNT_ID
export AZURE_TENANT_ID
export AZURE_SUBSCRIPTION_ID
export AZURE_RESOURCE_GROUP
source /images_db_stub.sh
echo "Storing iqe variables to results"
echo -n "$IQE_ENV_VARS" > $(results.iqe-additional-env-vars.path)
11 changes: 11 additions & 0 deletions tasks/run-iqe-cji.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ spec:
type: string
description: "Comma delimited string with additional values, such as IQE_ENV_VARS='DYNACONF_USER_PROVIDER__rbac_enabled=false,foo=bar'"
default: ""
- name: IQE_ENV_VARS_SUBSTITUTE
type: string
description: "Comma delimited string with additional values used when IQE_ENV_VARS are empty,i.e:IQE_ENV_VARS_SUBSTITUTE='DYNACONF_ephemeral_images__aws__image_uuid=<image_uuid>"
default: ""
- name: IQE_SELENIUM
type: string
description: "true -- whether to run IQE pod with a selenium container, default is false"
Expand Down Expand Up @@ -119,6 +123,8 @@ spec:
value: $(params.IQE_ENV)
- name: IQE_ENV_VARS
value: $(params.IQE_ENV_VARS)
- name: IQE_ENV_VARS_SUBSTITUTE
value: $(params.IQE_ENV_VARS_SUBSTITUTE)
- name: IQE_SELENIUM
value: $(params.IQE_SELENIUM)
- name: IQE_PARALLEL_ENABLED
Expand All @@ -137,8 +143,13 @@ spec:
#!/bin/bash
set -ex
if [ -z "$IQE_ENV_VARS" ]; then
export IQE_ENV_VARS="$IQE_ENV_VARS_SUBSTITUTE"
fi
echo "Connecting to the ephemeral namespace cluster"
login.sh
echo "Deploying the IQE CJI test"
deploy-iqe-cji.sh "$(params.NS)" "$(params.NS_REQUESTER)"
2 changes: 1 addition & 1 deletion tasks/teardown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,4 @@ spec:
login.sh
echo "Releasing ephemeral namespace"
release-ns.sh "$(params.NS)" "$(params.NS_REQUESTER)"
release-ns.sh "$(params.NS)" "$(params.NS_REQUESTER)"

0 comments on commit 0b6f396

Please sign in to comment.