Skip to content

Commit

Permalink
Set integration with SPI in preview mode (#105)
Browse files Browse the repository at this point in the history
* Set integration with SPI in preview mode

- Allow to configure SPI integration using preview mode
Michkov authored Feb 15, 2022
1 parent 2e411d8 commit e5d1323
Showing 3 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -80,6 +80,8 @@ SPI components fails to start right after the bootstrap. It requires manual conf
3) In CRC setup add a random string for value of `sharedSecret`
4) In few moments, SPI pods should start

This process is automated in `preview mode` see below.

### Install Toolchain (Sandbox) Operators
There are two scripts which you can use:
- `./hack/sandbox-development-mode.sh` for development mode
7 changes: 7 additions & 0 deletions hack/preview-template.env
Original file line number Diff line number Diff line change
@@ -11,3 +11,10 @@ export MY_GIT_FORK_REMOTE=
export MY_GITHUB_ORG=
### Personal API token with repo and delete_repo permission
export MY_GITHUB_TOKEN=

## SPI integration
### Based on https://github.com/redhat-appstudio/service-provider-integration-operator#configuration
export SHARED_SECRET= # Random string
export SPI_TYPE= # GitHub
export SPI_CLIENT_ID=
export SPI_CLIENT_SECRET=
13 changes: 13 additions & 0 deletions hack/preview.sh
Original file line number Diff line number Diff line change
@@ -40,6 +40,19 @@ if [ -n "$MY_GITHUB_ORG" ]; then
$ROOT/hack/util-set-github-org $MY_GITHUB_ORG
fi

if [ -n "$SHARED_SECRET" ] && [ -n "$SPI_TYPE" ] && [ -n "$SPI_CLIENT_ID" ] && [ -n "$SPI_CLIENT_SECRET" ]; then
TMP_FILE=$(mktemp)
ROUTE="https://$(oc get routes -n spi-system spi-oauth-route -o yaml -o jsonpath='{.spec.host}')"
yq e ".sharedSecret=\"$SHARED_SECRET\"" $ROOT/components/spi/config.yaml | \
yq e ".serviceProviders[0].type=\"$SPI_TYPE\"" - | \
yq e ".serviceProviders[0].clientId=\"$SPI_CLIENT_ID\"" - | \
yq e ".serviceProviders[0].clientSecret=\"$SPI_CLIENT_SECRET\"" - | \
yq e ".baseUrl=\"$ROUTE\"" - > $TMP_FILE
oc create -n spi-system secret generic oauth-config --from-file=config.yaml=$TMP_FILE --dry-run=client -o yaml | oc apply -f -
echo "SPI configurared, set Authorization callback URL to $ROUTE"
rm $TMP_FILE
fi

if ! git diff --exit-code --quiet; then
git commit -a -m "Preview mode, do not merge into main"
git push -f --set-upstream $MY_GIT_FORK_REMOTE $PREVIEW_BRANCH

0 comments on commit e5d1323

Please sign in to comment.