Skip to content

Commit

Permalink
chore(KFLUXVNGD-93): Update eaas-provision-space task
Browse files Browse the repository at this point in the history
Update eaas-provision-space task to use new claim resource
instead of SpaceRequests.

Jira-Url: https://issues.redhat.com/browse/KFLUXVNGD-93
Signed-off-by: Homaja Marisetty <[email protected]>
  • Loading branch information
hmariset committed Jan 8, 2025
1 parent edd2c29 commit 07c964c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
9 changes: 5 additions & 4 deletions task/eaas-provision-space/0.1/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# 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.
Provisions an ephemeral namespace on an EaaS cluster using a namespace claim. 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|
|ownerKind|The type of resource that should own the generated namespace claim. Deletion of this resource will trigger deletion of the namespace claim. Supported values: `PipelineRun`, `TaskRun`.|PipelineRun|false|
|ownerName|The name of the resource that should own the generated namespace claim. 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 namespace claim. 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|
Expand Down
36 changes: 18 additions & 18 deletions task/eaas-provision-space/0.1/eaas-provision-space.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@ metadata:
name: eaas-provision-space
spec:
description: >-
Provisions an ephemeral namespace on an EaaS cluster using a SpaceRequest.
Provisions an ephemeral namespace on an EaaS cluster using a crossplane namespace claim.
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.
The type of resource that should own the generated namespace claim.
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.
The name of the resource that should own the generated namespace claim.
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.
The uid of the resource that should own the generated namespace claim.
This should either be passed the value of `$(context.pipelineRun.uid)`
or `$(context.taskRun.uid)` depending on the value of `ownerKind`.
results:
Expand All @@ -43,8 +43,10 @@ spec:
value: $(params.ownerName)
- name: OWNER_UID
value: $(params.ownerUid)
- name: TIER_NAME
value: konflux-eaas
- name: CLAIM_NAME
value: $(context.taskRun.name)
- name: SECRET
value: $(context.taskRun.name)-secret
script: |
#!/bin/bash
set -eo pipefail
Expand All @@ -58,29 +60,27 @@ spec:
;;
esac
cat <<EOF > space_request.yaml
apiVersion: toolchain.dev.openshift.com/v1alpha1
kind: SpaceRequest
cat <<EOF > namespace_claim.yaml
apiVersion: eaas.konflux-ci.dev/v1alpha1
kind: Namespace
metadata:
generateName: eaas-spacerequest-
name: $CLAIM_NAME
namespace: $NAMESPACE
ownerReferences:
- apiVersion: tekton.dev/v1
kind: $OWNER_KIND
name: $OWNER_NAME
uid: $OWNER_UID
spec:
tierName: $TIER_NAME
targetClusterRoles:
- cluster-role.toolchain.dev.openshift.com/eaas
writeConnectionSecretToRef:
name: $SECRET
EOF
NAME=$(oc create -f space_request.yaml -o=jsonpath='{.metadata.name}')
NAME=$(oc create -f namespace_claim.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)
if oc wait namespaces.eaas.konflux-ci.dev "$NAME" --for=condition=Ready --timeout=5m; then
echo "SecretRef: $SECRET"
echo -n "$SECRET" > "$(results.secretRef.path)"
else
exit 1
fi

0 comments on commit 07c964c

Please sign in to comment.