Skip to content

Commit

Permalink
Merge pull request #58 from bcgov/update-docker-for-201
Browse files Browse the repository at this point in the history
update install.sh with github PAT
  • Loading branch information
w8896699 authored Mar 19, 2024
2 parents 7a74ffd + 984bace commit 02e1cdf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
4 changes: 2 additions & 2 deletions tekton/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ WORKDIR /var/opt/tekton
COPY . .

# clean up this form
RUN sed -i 's/sonar-token=.*/sonar-token=/g ; s/ssh-key-path=.*/ssh-key-path=/g' ./overlays/secrets/secrets.ini
RUN sed -i 's/sonar-token=.*/sonar-token=/g ; s/ssh-key-path=.*/ssh-key-path=/g ; s/github-pat-token=.*/github-pat-token=/g' ./overlays/secrets/secrets.ini

RUN sed -i 's/ssh-key-path=/ssh-key-path=\/var\/opt\/tekton\/id_rsa/g' ./overlays/secrets/secrets.ini
# RUN sed -i 's/ssh-key-path=/ssh-key-path=\/var\/opt\/tekton\/id_rsa/g' ./overlays/secrets/secrets.ini
RUN echo $CONTEXT

COPY ./scripts/install.sh /docker-entrypoint-installTekton.sh
Expand Down
22 changes: 17 additions & 5 deletions tekton/scripts/install.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/bin/bash



trap exit SIGINT;
# set -o errexit

readonly REQUIRED_ENV_VARS=(
"NAMESPACE"
"OC_LOGIN_STRING")\
"OC_LOGIN_STRING"
"GITHUB_PAT")\

# ask user to input value so that we don't leave secrets in any plain text
ask-for-env(){
Expand All @@ -18,13 +19,24 @@ ask-for-env(){
export NAMESPACE=$NAMESPACE

read -p 'OC login string that you can find on your console page:(whole string including oc) ' OC_LOGIN_STRING
# Use the ${variable/pattern/replacement} syntax to replace the first occurrence of the string " login " (note the spaces) with namespace
modified_string="${OC_LOGIN_STRING/ login / login -n $NAMESPACE }"
echo "$modified_string"

output=$(eval "$modified_string"|tr -d '\n' )

while ! $OC_LOGIN_STRING
while [[ $output != *"Using project \"$NAMESPACE\"."* ]]
do
echo Your login strying is not valid, please try again
echo Your login string is not valid, please try again
read -p 'OC login string that you can find on your console page:(whole string including oc) ' OC_LOGIN_STRING
modified_string="${OC_LOGIN_STRING/ login / login -n $NAMESPACE }"
output=$(eval "$modified_string" | tail -n 1)
echo "$output"
done
oc project $NAMESPACE
echo "Login successed!"
read -p 'Your Github Personal Access Token(required): ' GITHUB_PAT
export GITHUB_PAT=$GITHUB_PAT
sed -i "s/github-pat-token=/github-pat-token=$GITHUB_PAT/g" ./overlays/secrets/secrets.ini

read -p 'Your sonar Token(not mandatory): ' SONAR_TOKEN
sed -i "s/sonar-token=/sonar-token=$SONAR_TOKEN/g" ./overlays/secrets/secrets.ini
Expand Down

0 comments on commit 02e1cdf

Please sign in to comment.