|
2 | 2 | SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
3 | 3 |
|
4 | 4 | COMPONENT=$1
|
| 5 | +PATH_TO_DOCKERFILE=$2 |
| 6 | +[ -z "$MY_GITHUB_TOKEN" ] && echo "error: MY_GITHUB_TOKEN env var is not exported" && exit 1 |
5 | 7 |
|
6 | 8 | # Configure namespace
|
7 | 9 | $SCRIPTDIR/setup-namespace.sh
|
8 | 10 |
|
9 | 11 | oc delete --ignore-not-found -f $SCRIPTDIR/templates/application.yaml
|
10 | 12 | oc create -f $SCRIPTDIR/templates/application.yaml
|
11 |
| -if ! oc wait --for=condition=Created application/test-application; then |
12 |
| - echo "Application was not created sucessfully, check:" |
13 |
| - echo "oc get applications test-application -o yaml" |
14 |
| - exit 1 |
15 |
| -fi |
| 13 | + |
| 14 | +function create-secret { |
| 15 | + yq e "(.stringData.password=\"$MY_GITHUB_TOKEN\")" $SCRIPTDIR/templates/secret.yaml | oc apply -f- |
| 16 | +} |
16 | 17 |
|
17 | 18 | function create-component {
|
18 | 19 | GIT_URL=$1
|
| 20 | + PATH_TO_DOCKERFILE=$2 |
19 | 21 | REPO=$(echo $GIT_URL | grep -o '[^/]*$')
|
20 | 22 | NAME=${REPO%%.git}
|
21 | 23 | oc delete --ignore-not-found component $NAME
|
22 | 24 | [ -n "$SKIP_INITIAL_CHECKS" ] && ANNOTATE_SKIP_INITIAL_CHECKS='| (.metadata.annotations.skip-initial-checks="true")'
|
23 | 25 | [ -n "$ENABLE_PAC" ] && ANNOTATE_PAC_PROVISION='| (.metadata.annotations."build.appstudio.openshift.io/request"="configure-pac")'
|
24 |
| - yq e "(.metadata.name=\"$NAME\") | (.spec.componentName=\"$NAME\") | (.spec.source.git.url=\"$GIT_URL\") | (.spec.containerImage=\"$IMAGE\") $ANNOTATE_PAC_PROVISION $ANNOTATE_SKIP_INITIAL_CHECKS" $SCRIPTDIR/templates/component.yaml | oc apply -f- |
| 26 | + yq e "(.metadata.name=\"$NAME\") | (.spec.componentName=\"$NAME\") | (.spec.source.git.url=\"$GIT_URL\") | (.spec.source.git.dockerfileUrl=\"$PATH_TO_DOCKERFILE\") $ANNOTATE_PAC_PROVISION $ANNOTATE_SKIP_INITIAL_CHECKS" $SCRIPTDIR/templates/component.yaml | oc apply -f- |
25 | 27 | }
|
26 | 28 |
|
27 |
| -echo Git Repo created: |
28 |
| -oc get application/test-application -o jsonpath='{.status.devfile}' | grep appModelRepository.url | cut -f2- -d':' |
| 29 | +create-secret |
29 | 30 |
|
30 | 31 | if [ -z "$COMPONENT" ]; then
|
31 |
| - create-component https://github.com/devfile-samples/devfile-sample-java-springboot-basic |
32 |
| - create-component https://github.com/devfile-samples/devfile-sample-code-with-quarkus |
33 |
| - create-component https://github.com/devfile-samples/devfile-sample-python-basic |
| 32 | + create-component https://github.com/devfile-samples/devfile-sample-java-springboot-basic docker/Dockerfile |
| 33 | + create-component https://github.com/devfile-samples/devfile-sample-code-with-quarkus src/main/docker/Dockerfile.jvm.staged |
| 34 | + create-component https://github.com/devfile-samples/devfile-sample-python-basic docker/Dockerfile |
34 | 35 | else
|
35 |
| - create-component $COMPONENT |
| 36 | + create-component $COMPONENT $PATH_TO_DOCKERFILE |
36 | 37 | fi
|
37 | 38 | echo "Run this to show running builds: tkn pr list"
|
0 commit comments