-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Alex Misstear <[email protected]>
- Loading branch information
Showing
3 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# eaas-provision-space task | ||
|
||
Provisions an ephemeral namespace on an EaaS cluster using a SpaceRequest. This namespace can then be used to provision other ephemeral environments for testing. | ||
|
||
## Parameters | ||
|name|description|default value|required| | ||
|---|---|---|---| | ||
|ownerKind|The type of resource that should own the generated SpaceRequest. Deletion of this resource will trigger deletion of the SpaceRequest. Supported values: `PipelineRun`, `TaskRun`.|PipelineRun|false| | ||
|ownerName|The name of the resource that should own the generated SpaceRequest. This should either be passed the value of `$(context.pipelineRun.name)` or `$(context.taskRun.name)` depending on the value of `ownerKind`.||true| | ||
|ownerUid|The uid of the resource that should own the generated SpaceRequest. This should either be passed the value of `$(context.pipelineRun.uid)` or `$(context.taskRun.uid)` depending on the value of `ownerKind`.||true| | ||
|
||
## Results | ||
|name|description| | ||
|---|---| | ||
|secretRef|Name of a Secret containing a kubeconfig used to access the provisioned space.| | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
--- | ||
apiVersion: tekton.dev/v1 | ||
kind: Task | ||
metadata: | ||
name: eaas-provision-space | ||
spec: | ||
description: >- | ||
Provisions an ephemeral namespace on an EaaS cluster using a SpaceRequest. | ||
This namespace can then be used to provision other ephemeral environments for testing. | ||
params: | ||
- name: ownerKind | ||
type: string | ||
default: PipelineRun | ||
description: >- | ||
The type of resource that should own the generated SpaceRequest. | ||
Deletion of this resource will trigger deletion of the SpaceRequest. | ||
Supported values: `PipelineRun`, `TaskRun`. | ||
- name: ownerName | ||
type: string | ||
description: >- | ||
The name of the resource that should own the generated SpaceRequest. | ||
This should either be passed the value of `$(context.pipelineRun.name)` | ||
or `$(context.taskRun.name)` depending on the value of `ownerKind`. | ||
- name: ownerUid | ||
type: string | ||
description: >- | ||
The uid of the resource that should own the generated SpaceRequest. | ||
This should either be passed the value of `$(context.pipelineRun.uid)` | ||
or `$(context.taskRun.uid)` depending on the value of `ownerKind`. | ||
results: | ||
- name: secretRef | ||
description: Name of a Secret containing a kubeconfig used to access the provisioned space. | ||
type: string | ||
steps: | ||
- name: request-space | ||
image: registry.redhat.io/openshift4/ose-cli:4.13@sha256:73df37794ffff7de1101016c23dc623e4990810390ebdabcbbfa065214352c7c | ||
env: | ||
- name: NAMESPACE | ||
value: $(context.taskRun.namespace) | ||
- name: OWNER_KIND | ||
value: $(params.ownerKind) | ||
- name: OWNER_NAME | ||
value: $(params.ownerName) | ||
- name: OWNER_UID | ||
value: $(params.ownerUid) | ||
- name: TIER_NAME | ||
value: appstudio-env # Temporary until the EaaS tier is ready | ||
script: | | ||
#!/bin/bash | ||
set -eo pipefail | ||
case "$OWNER_KIND" in | ||
PipelineRun|TaskRun) | ||
;; | ||
*) | ||
echo "Unsupported value for ownerKind param" | ||
exit 1 | ||
;; | ||
esac | ||
cat <<EOF > space_request.yaml | ||
apiVersion: toolchain.dev.openshift.com/v1alpha1 | ||
kind: SpaceRequest | ||
metadata: | ||
generateName: eaas-spacerequest- | ||
namespace: $NAMESPACE | ||
ownerReferences: | ||
- apiVersion: tekton.dev/v1 | ||
kind: $OWNER_KIND | ||
name: $OWNER_NAME | ||
uid: $OWNER_UID | ||
spec: | ||
tierName: $TIER_NAME | ||
EOF | ||
NAME=$(oc create -f space_request.yaml -o=jsonpath='{.metadata.name}') | ||
if oc wait spacerequests $NAME --for=condition=Ready --timeout=5m; then | ||
secretRef=$(oc get spacerequests $NAME -o=jsonpath='{.status.namespaceAccess[0].secretRef}') | ||
echo "SecretRef: $secretRef" | ||
echo -n "$secretRef" > $(results.secretRef.path) | ||
else | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# See the OWNERS docs: https://go.k8s.io/owners | ||
|
||
approvers: | ||
- amisstea | ||
- oamsalem | ||
- avi-biton | ||
- yftacherzog | ||
- hmariset |