-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathuploadApplicationFile.sh
More file actions
executable file
·30 lines (20 loc) · 1.05 KB
/
uploadApplicationFile.sh
File metadata and controls
executable file
·30 lines (20 loc) · 1.05 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
#!/usr/bin/env bash
# ENV Variables expected
# MESHERY_SERVER_BASE_URL
# UPLOAD_TYPE: can be "Kubernetes Manifest" | "Helm Chart" | "Docker Compose" | "Meshery Design"
# PROVIDER_TOKEN: MESHERY provider token
# Get Meshery pattern file as escaped YAML string
MESHERY_PATTERN_FILE=$(pattern_file=$(cat __intermediate_file.yml) node ./action/normalize-configuration-file/index.js)
echo "Import design \n : Pattern_file_encoded: $MESHERY_PATTERN_FILE , SERVER_BASE_URL: $MESHERY_SERVER_BASE_URL " >> log.txt
# Perform the curl request and store response in a variable
RESPONSE=$(curl -s "$MESHERY_SERVER_BASE_URL/api/pattern/import" \
-H 'Accept: */*' \
-H 'Connection: close' \
-H 'Content-Type: application/json' \
-H "Cookie: meshery-provider=Layer5; token=$MESHERY_TOKEN;" \
--request POST \
--data "{ \"name\": \"autogenerated\", \"file_name\" : \"manifest.yml\", \"file\" :$MESHERY_PATTERN_FILE }" )
# Append the response to log.txt
echo "Upload Response \n : $RESPONSE" >> log.txt
# Extract and return the ID
echo "$RESPONSE" | jq -r '.[0].id'