-
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.
Merge branch 'main' into update-renovate
- Loading branch information
Showing
15 changed files
with
463 additions
and
96 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
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
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
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,7 @@ | ||
# See the OWNERS docs: https://go.k8s.io/owners | ||
|
||
approvers: | ||
- gbenhaim | ||
- avi-biton | ||
- amisstea | ||
- yftacherzog |
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,27 @@ | ||
# provision-env-with-ephemeral-namespace task | ||
|
||
## Description: | ||
This task generates a spaceRequest which in turn creates a namespace in the cluster. | ||
The namespace is intended to be used to run integration tests for components, in | ||
an ephemeral environment that will be completely clean of previous artifacts. | ||
|
||
|
||
## Params: | ||
|
||
| name | description | | ||
|--------------------|-------------------------------------------------------------------| | ||
| KONFLUXNAMESPACE | The namespace to create the spaceRequest from | | ||
| SPACEREQUEST_NAME | The name for the newly created space request | | ||
|
||
|
||
## Results: | ||
|
||
| name | description | | ||
|-------------------|--------------------------------------------------------------------------------------------------| | ||
| secretRef | The name of the secret with a SA token that had admin permissions in the newly created namespace | | ||
|
||
|
||
## Source repository for task: | ||
https://github.com/redhat-appstudio/tekton-tools | ||
|
||
|
5 changes: 5 additions & 0 deletions
5
task/provision-env-with-ephemeral-namespace/0.1/kustomization.yaml
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,5 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
|
||
resources: | ||
- provision-env-with-ephemeral-namespace.yaml |
50 changes: 50 additions & 0 deletions
50
task/provision-env-with-ephemeral-namespace/0.1/provision-env-with-ephemeral-namespace.yaml
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,50 @@ | ||
--- | ||
apiVersion: tekton.dev/v1 | ||
kind: Task | ||
metadata: | ||
name: provision-env-with-ephemeral-namespace | ||
spec: | ||
results: | ||
- name: secretRef | ||
description: | ||
SecretRef is the name of the secret with a SA token that has admin-like | ||
(or whatever we set in the tier template) permissions in the namespace | ||
type: string | ||
steps: | ||
- name: request-ephemeral-namespace | ||
image: registry.redhat.io/openshift4/ose-cli:4.13@sha256:73df37794ffff7de1101016c23dc623e4990810390ebdabcbbfa065214352c7c | ||
env: | ||
- name: KONFLUXNAMESPACE | ||
value: "$(context.pipelineRun.namespace)" | ||
- name: PIPELINERUN_NAME | ||
value: "$(context.pipelineRun.name)" | ||
- name: PIPELINERUN_UID | ||
value: "$(context.pipelineRun.uid)" | ||
script: | | ||
#!/bin/bash | ||
set -ex | ||
set -o pipefail | ||
cat <<EOF > space_request.yaml | ||
apiVersion: toolchain.dev.openshift.com/v1alpha1 | ||
kind: SpaceRequest | ||
metadata: | ||
generateName: task-spacerequest- | ||
namespace: $KONFLUXNAMESPACE | ||
ownerReferences: | ||
- apiVersion: tekton.dev/v1 | ||
kind: PipelineRun | ||
name: $PIPELINERUN_NAME | ||
uid: $PIPELINERUN_UID | ||
spec: | ||
tierName: appstudio-env | ||
EOF | ||
SPACEREQUEST_NAME=$(oc create -f space_request.yaml -o=jsonpath='{.metadata.name}') | ||
if oc wait spacerequests $SPACEREQUEST_NAME --for=condition=Ready --timeout=5m -n $KONFLUXNAMESPACE; then | ||
secretRef=$(oc get spacerequests $SPACEREQUEST_NAME -o=jsonpath='{.status.namespaceAccess[0].secretRef}') | ||
echo $secretRef > tee "$(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: | ||
- gbenhaim | ||
- oamsalem | ||
- amisstea | ||
- avi-biton | ||
- yftacherzog |
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 |
---|---|---|
|
@@ -22,51 +22,56 @@ spec: | |
secretName: $(params.gitops-auth-secret-name) | ||
optional: true | ||
steps: | ||
- name: patch-gitops | ||
image: quay.io/redhat-appstudio/task-toolset@sha256:931a9f7886586391ccb38d33fd15a47eb03568f9b19512b0a57a56384fa52a3c | ||
volumeMounts: | ||
- name: gitops-auth-secret | ||
mountPath: /gitops-auth-secret | ||
env: | ||
- name: PARAM_GITOPS_REPO_URL | ||
value: $(params.gitops-repo-url) | ||
- name: PARAM_IMAGE | ||
value: $(params.image) | ||
script: | | ||
if test -f /gitops-auth-secret/password ; then | ||
gitops_repo_url=${PARAM_GITOPS_REPO_URL} | ||
remote_without_protocol=${gitops_repo_url#'https://'} | ||
- name: patch-gitops | ||
image: quay.io/redhat-appstudio/task-toolset@sha256:931a9f7886586391ccb38d33fd15a47eb03568f9b19512b0a57a56384fa52a3c | ||
volumeMounts: | ||
- name: gitops-auth-secret | ||
mountPath: /gitops-auth-secret | ||
env: | ||
- name: PARAM_GITOPS_REPO_URL | ||
value: $(params.gitops-repo-url) | ||
- name: PARAM_IMAGE | ||
value: $(params.image) | ||
script: | | ||
if test -f /gitops-auth-secret/password ; then | ||
gitops_repo_url=${PARAM_GITOPS_REPO_URL} | ||
remote_without_protocol=${gitops_repo_url#'https://'} | ||
password=$(cat /gitops-auth-secret/password) | ||
if test -f /gitops-auth-secret/username ; then | ||
username=$(cat /gitops-auth-secret/username) | ||
echo "https://${username}:${password})@${hostname}" > "${HOME}/.git-credentials" | ||
origin_with_auth=https://${username}:${password}@${remote_without_protocol}.git | ||
password=$(cat /gitops-auth-secret/password) | ||
if test -f /gitops-auth-secret/username ; then | ||
username=$(cat /gitops-auth-secret/username) | ||
echo "https://${username}:${password})@${hostname}" > "${HOME}/.git-credentials" | ||
origin_with_auth=https://${username}:${password}@${remote_without_protocol}.git | ||
else | ||
origin_with_auth=https://${password}@${remote_without_protocol}.git | ||
fi | ||
else | ||
origin_with_auth=https://${password}@${remote_without_protocol}.git | ||
echo "git credentials to push into gitops repository ${PARAM_GITOPS_REPO_URL} is not configured." | ||
echo "gitops repository is not updated automatically." | ||
echo "You can update gitops repository with the new image: ${PARAM_IMAGE} manually" | ||
echo "TODO: configure git credentials to update gitops repository." | ||
exit 0 | ||
fi | ||
else | ||
echo "git credentials to push into gitops repository ${PARAM_GITOPS_REPO_URL} is not configured." | ||
echo "gitops repository is not updated automatically." | ||
echo "You can update gitops repository with the new image: ${PARAM_IMAGE} manually" | ||
echo "TODO: configure git credentials to update gitops repository." | ||
exit 0 | ||
fi | ||
# https://github.com/user-org/test-component-gitops => test-component | ||
gitops_repo_name=$(basename ${PARAM_GITOPS_REPO_URL}) | ||
component_id=${gitops_repo_name%'-gitops'} | ||
deployment_patch_filepath="components/${component_id}/overlays/development/deployment-patch.yaml" | ||
# https://github.com/user-org/test-component-gitops => test-component | ||
gitops_repo_name=$(basename ${PARAM_GITOPS_REPO_URL}) | ||
component_id=${gitops_repo_name%'-gitops'} | ||
deployment_patch_filepath="components/${component_id}/overlays/development/deployment-patch.yaml" | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "gitops-update" | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "gitops-update" | ||
git clone ${PARAM_GITOPS_REPO_URL} | ||
cd ${gitops_repo_name} | ||
git clone ${PARAM_GITOPS_REPO_URL} | ||
cd ${gitops_repo_name} | ||
sed -i "s| image: .*| image: ${PARAM_IMAGE}|" $deployment_patch_filepath | ||
sed -i "s| image: .*| image: ${PARAM_IMAGE}|" $deployment_patch_filepath | ||
git add . | ||
git commit -m "Update '${component_id}' component image to: ${PARAM_IMAGE}" | ||
git remote set-url origin $origin_with_auth | ||
git push | ||
git add . | ||
git commit -m "Update '${component_id}' component image to: ${PARAM_IMAGE}" | ||
git remote set-url origin $origin_with_auth | ||
git push 2> /dev/null || \ | ||
{ | ||
echo "Failed to push update to gitops repository: ${PARAM_GITOPS_REPO_URL}" | ||
echo 'Do you have correct git credentials configured?' | ||
exit 1 | ||
} |
Oops, something went wrong.