Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolves the issue of the user not able to add pipelines to the kabanero custom resource file #13

Merged
merged 4 commits into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,4 @@ What if the default Kabanero pipelines are not enough? You've spent some time de
6) Add a stable pipeline release version to the Kabanero custom resource?
enter a number >

Here is a quick demo I made https://asciinema.org/a/315675
89
9
Here is a quick demo I made https://asciinema.org/a/315675
24 changes: 20 additions & 4 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -171,33 +171,49 @@ update_kabanero_cr() {


add_pipeline_kabanero_cr() {
# switch to the kabanero namespace
oc project kabanero

oc get kabaneros kabanero -o json > ./json/temp.json
# save the kabanero cr to a kabanero.json file
oc get kabaneros kabanero -o json > ./json/kabanero.json

read -p "Enter label for pipeline [i.e mcm-pipelines] " name_of_pipeline
read -p "Where are the pipelines being hosted? [i.e www.github.com/org/repo-pipelines/kabanero.tar.gz] " host_url
read -p "Enter name of tar file " tar_file_name

# save the tar file locally
wget $host_url

# generate sha256 on the zip file
get_sha=$(shasum -a 256 ./$tar_file_name | grep -Eo '^[^ ]+' )

echo $get_sha
echo "sha256 value: "$get_sha

# add double quotes to the sha256
new_sha=\"${get_sha}\"
generate_sha=

# get the add_pipeline_template.json and replace the url, id and sha256 values and store it in another file
jq '.https.url="'$host_url'" | .id="'$name_of_pipeline'" | .sha256="'$get_sha'"' ./json/add_pipeline_template.json > ./json/add_pipeline_modified_template.json

cat ./json/add_pipeline_modified_template.json

rm ./default-kabanero-pipelines.tar.gz

result=$(jq '.spec.stacks.pipelines[1]='"$(cat ./json/add_pipeline_modified_template.json)"'' ./json/kabanero.json)
# Get the number of pipelines we currently have on the kabanero CR and increment by 1
num_of_pipelines=$(jq '.spec.stacks.pipelines | length' ./json/kabanero.json)+1

# add the add_pipeline_modified_template.json to the kabanero.json file
result=$(jq '.spec.stacks.pipelines['$num_of_pipelines']='"$(cat ./json/add_pipeline_modified_template.json)"'' ./json/kabanero.json)

# prettify and store the result in another file
echo $result | json_pp > ./json/kabanero-2.json

cd ./json

cat ./kabanero-2.json

# apply your new changes to the kabanero custom resource
oc apply -f kabanero-2.json
}

printf "===========================================================================\n\n"
Expand Down