@@ -30,7 +30,7 @@ DEFAULT_GIT_SOURCE_NAME="default-git-source"
30
30
31
31
# Params:
32
32
check_required_param " namespace" " ${NAMESPACE} "
33
- check_required_param " csdp token" " ${CSDP_TOKEN } "
33
+ check_required_param " csdp runtime token" " ${CSDP_RUNTIME_TOKEN } "
34
34
check_required_param " runtime repo" " ${CSDP_RUNTIME_REPO} "
35
35
check_required_param " git token" " ${CSDP_RUNTIME_GIT_TOKEN} "
36
36
check_required_param " runtime cluster" " ${CSDP_RUNTIME_CLUSTER} "
@@ -66,38 +66,41 @@ create_codefresh_secret() {
66
66
COMPONENTS=` echo $COMPONENTS | tr ' ' ' ,' `
67
67
COMPONENTS=" [${COMPONENTS} ]"
68
68
69
- RUNTIME_CREATE_ARGS=" {
70
- \" repo\" : \" ${CSDP_RUNTIME_REPO} \" ,
71
- \" runtimeName\" :\" ${CSDP_RUNTIME_NAME} \" ,
72
- \" cluster\" :\" ${CSDP_RUNTIME_CLUSTER} \" ,
73
- \" ingressHost\" :\" ${CSDP_RUNTIME_INGRESS_URL} \" ,
74
- \" ingressClass\" :\" ${CSDP_INGRESS_CLASS_NAME} \" ,
75
- \" ingressController\" :\" ${CSDP_INGRESS_CONTROLLER} \" ,
76
- \" componentNames\" :${COMPONENTS} ,
77
- \" runtimeVersion\" :\" v0.0.0\" ,
78
- \" managed\" :${CSDP_MANAGED_RUNTIME}
79
- }"
80
-
81
- RUNTIME_CREATE_DATA=" {\" operationName\" :\" CreateRuntime\" ,\" variables\" :{\" args\" :$RUNTIME_CREATE_ARGS }"
82
- RUNTIME_CREATE_DATA+=$' ,"query":"mutation CreateRuntime($args: RuntimeInstallationArgs\u0021) {\\ n createRuntime(installationArgs: $args) {\\ n name\\ n newAccessToken\\ n }\\ n}\\ n"}'
83
- echo " --> Creating runtime with args:"
84
- echo " $RUNTIME_CREATE_ARGS "
85
-
86
- RUNTIME_CREATE_RESPONSE=` curl " ${CSDP_URL} /2.0/api/graphql" \
87
- -SsfL \
88
- -H " Authorization: ${CSDP_TOKEN} " \
89
- -H ' content-type: application/json' \
90
- --compressed \
91
- --insecure \
92
- --data-raw " $RUNTIME_CREATE_DATA " `
69
+ if [ -z " $CSDP_RUNTIME_TOKEN " ] ; then
70
+ RUNTIME_CREATE_ARGS=" {
71
+ \" repo\" : \" ${CSDP_RUNTIME_REPO} \" ,
72
+ \" runtimeName\" :\" ${CSDP_RUNTIME_NAME} \" ,
73
+ \" cluster\" :\" ${CSDP_RUNTIME_CLUSTER} \" ,
74
+ \" ingressHost\" :\" ${CSDP_RUNTIME_INGRESS_URL} \" ,
75
+ \" ingressClass\" :\" ${CSDP_INGRESS_CLASS_NAME} \" ,
76
+ \" ingressController\" :\" ${CSDP_INGRESS_CONTROLLER} \" ,
77
+ \" componentNames\" :${COMPONENTS} ,
78
+ \" runtimeVersion\" :\" v0.0.0\" ,
79
+ \" managed\" :${CSDP_MANAGED_RUNTIME}
80
+ }"
81
+
82
+ RUNTIME_CREATE_DATA=" {\" operationName\" :\" CreateRuntime\" ,\" variables\" :{\" args\" :$RUNTIME_CREATE_ARGS }"
83
+ RUNTIME_CREATE_DATA+=$' ,"query":"mutation CreateRuntime($args: RuntimeInstallationArgs\u0021) {\\ n createRuntime(installationArgs: $args) {\\ n name\\ n newAccessToken\\ n }\\ n}\\ n"}'
84
+ echo " --> Creating runtime with args:"
85
+ echo " $RUNTIME_CREATE_ARGS "
86
+
87
+ RUNTIME_CREATE_RESPONSE=` curl " ${CSDP_URL} /2.0/api/graphql" \
88
+ -SsfL \
89
+ -H " Authorization: ${CSDP_TOKEN} " \
90
+ -H ' content-type: application/json' \
91
+ --compressed \
92
+ --insecure \
93
+ --data-raw " $RUNTIME_CREATE_DATA " `
94
+
95
+ if ` echo " $RUNTIME_CREATE_RESPONSE " | jq -e ' has("errors")' ` ; then
96
+ echo " Failed to create runtime"
97
+ echo ${RUNTIME_CREATE_RESPONSE}
98
+ exit 1
99
+ fi
93
100
94
- if ` echo " $RUNTIME_CREATE_RESPONSE " | jq -e ' has("errors")' ` ; then
95
- echo " Failed to create runtime"
96
- echo ${RUNTIME_CREATE_RESPONSE}
97
- exit 1
101
+ CSDP_RUNTIME_TOKEN=` echo $RUNTIME_CREATE_RESPONSE | jq ' .data.createRuntime.newAccessToken' `
98
102
fi
99
103
100
- RUNTIME_ACCESS_TOKEN=` echo $RUNTIME_CREATE_RESPONSE | jq ' .data.createRuntime.newAccessToken' `
101
104
RUNTIME_ENCRYPTION_IV=` hexdump -n 16 -e ' 4/4 "%08x" 1 "\n"' /dev/urandom`
102
105
echo " --> Runtime created!"
103
106
echo " "
@@ -110,7 +113,7 @@ create_codefresh_secret() {
110
113
name: $CODEFRESH_SECRET_NAME
111
114
namespace: $NAMESPACE
112
115
stringData:
113
- token: $RUNTIME_ACCESS_TOKEN
116
+ token: $CSDP_RUNTIME_TOKEN
114
117
encryptionIV: $RUNTIME_ENCRYPTION_IV
115
118
" | kubectl apply -f -
116
119
0 commit comments