|
2 | 2 |
|
3 | 3 | set -e |
4 | 4 |
|
5 | | -# default configure URL |
6 | | -DEFAULT_CONFIG_URL=https://api.github.com/repos/packethost/cluster-api-provider-packet/releases/latest |
7 | | -TMPYAML=/tmp/clusterctl-packet.yaml |
8 | | - |
9 | 5 | # might want to use a specific path to clusterctl |
10 | 6 | CLUSTERCTL=${CLUSTERCTL:-clusterctl} |
11 | 7 |
|
| 8 | +# might want to use a specific config URL |
12 | 9 | CONFIG_URL=${CONFIG_URL:-""} |
13 | | - |
14 | | -# if the config url was not provided, download it |
15 | | -if [ -z "${CONFIG_URL}" ]; then |
16 | | - # because github does not have a direct link to an asset |
17 | | - # this would be easier with jq, but not everyone has jq installed |
18 | | - YAML_URL=$(curl -s ${DEFAULT_CONFIG_URL} | grep clusterctl.yaml | grep browser_download_url | cut -d ":" -f 2,3 | tr -d "\"") |
19 | | - curl -L -o ${TMPYAML} ${YAML_URL} |
20 | | - CONFIG_URL=${TMPYAML} |
| 10 | +CONFIG_OPT=${CONFIG_OPT:-""} |
| 11 | +if [ -n "$CONFIG_URL" ]; then |
| 12 | + CONFIG_OPT="--config ${CONFIG_URL}" |
21 | 13 | fi |
22 | 14 |
|
23 | 15 | TEMPLATE_OUT=./out/cluster.yaml |
@@ -65,9 +57,7 @@ FACILITY=${PACKET_FACILITY} |
65 | 57 |
|
66 | 58 | # and now export them all so envsubst can use them |
67 | 59 | export PROJECT_ID FACILITY NODE_OS WORKER_NODE_TYPE MASTER_NODE_TYPE POD_CIDR SERVICE_CIDR SSH_KEY KUBERNETES_VERSION |
68 | | -${CLUSTERCTL} --config=${CONFIG_URL} config cluster ${CLUSTER_NAME} > $TEMPLATE_OUT |
69 | | -# remove any lingering config file |
70 | | -rm -f ${TMPYAML} |
| 60 | +${CLUSTERCTL} ${CONFIG_OPT} config cluster ${CLUSTER_NAME} > $TEMPLATE_OUT |
71 | 61 |
|
72 | 62 | echo "Done! See output file at ${TEMPLATE_OUT}. Run:" |
73 | 63 | echo " kubectl apply -f ${TEMPLATE_OUT}" |
|
0 commit comments