forked from IBM/CodeEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun
More file actions
executable file
·52 lines (39 loc) · 1.54 KB
/
run
File metadata and controls
executable file
·52 lines (39 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
# Env Vars:
# REGISTRY: name of the image registry/namespace to get the images
# Clean up previous run
function clean() {
set +ex
echo Cleaning...
(
ibmcloud ce app delete -n lister -f
ibmcloud ce secret delete -n cecli-keys -f
ibmcloud iam api-keys | grep cecli | sed "s/.*\(ApiKey\)/\1/" | while read a
do ibmcloud iam api-key-delete -f $a
done
) > /dev/null 2>&1
}
clean
[[ "$1" == "clean" ]] && exit 0
export REGISTRY=${REGISTRY:-icr.io/codeengine}
set -ex
# Create an API Key so that our App can use it to talk to Code Engine
apikey="$(ibmcloud iam api-key-create cecli -q -o json|jq -r '.apikey')"
# Create a 'secret' to hold our API Key, Project name, Resource Group and
# Region
ibmcloud ce secret create -n cecli-keys \
--from-literal "APIKEY=$apikey" \
--from-literal "GROUP=$(ibmcloud target -o json|jq -r '.resource_group.name')"
# Create our application that will kick off the "ibmcloud ce app list".
# Note that the App will take a little longer than normal to start-up because we
# setup the cloud CLI environment (eg. login) before starting the HTTP server.
# Need to give it a little more CPU than the default.
ibmcloud ce app create -n lister --image $REGISTRY/cecli --env-sec cecli-keys --cpu .125 --memory 0.25G
# Save App's URL for later
APP=$(ibmcloud ce app get -n lister -o url)
# Call the app - if it works it should return the output of the 'app list' cmd
curl -fsw "%{http_code}\n" $APP/list | tee out
[[ "${PIPESTATUS[0]}" == "0" ]]
# Verify we see our App in the output
grep "^lister " out
clean