Skip to content

Commit 373b83b

Browse files
authored
feat!: added spec2 support
- removed artifacts - new endpoints
2 parents d3c0e41 + d10a953 commit 373b83b

File tree

5 files changed

+31
-38
lines changed

5 files changed

+31
-38
lines changed

src/commands/end-sandbox.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ steps:
2626
name: End Torque Sandbox
2727
command: |
2828
curl --silent -X DELETE "$<<parameters.torque-url>>/api/spaces/$<<parameters.space>>/sandbox/$<<parameters.sandbox-id>>" \
29-
--header "User-Agent: Torque-Plugin-CirceCI/1.0.X" \
29+
--header "User-Agent: Torque-Plugin-CirceCI/1.1.X" \
3030
--header "accept: text/plain" \
3131
--header "Authorization: bearer $<<parameters.torque-token>>" || exit 1

src/commands/start-sandbox.yml

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,6 @@ parameters:
4242
Json format {'key1': 'value1', ..., 'keyN': 'valueN'}
4343
type: string
4444
default: "{}"
45-
artifacts:
46-
description: |
47-
String with the list of artifacts.
48-
Json format {'key1': 'value1', ..., 'keyN': 'valueN'}
49-
type: string
50-
default: "{}"
5145
timeout:
5246
description: >
5347
Timeout for this step in minutes. If the sandbox will not be ready when the timeout is reached,
@@ -69,15 +63,14 @@ steps:
6963
'blueprint_name':'<<parameters.blueprint>>',
7064
'duration': '<<parameters.duration>>',
7165
'inputs': <<parameters.inputs>>,
72-
'artifacts': <<parameters.artifacts>>,
7366
'automation': true
7467
}"
7568
)
7669
echo $PAYLOAD
7770
7871
status_code=`curl --write-out "%{http_code}\n" --output result.txt \
79-
--silent -X POST "$<<parameters.torque-url>>/api/spaces/$<<parameters.space>>/sandbox" \
80-
--header "User-Agent: Torque-Plugin-CirceCI/1.0.X" \
72+
--silent -X POST "$<<parameters.torque-url>>/api/spaces/$<<parameters.space>>/environments" \
73+
--header "User-Agent: Torque-Plugin-CirceCI/1.1.X" \
8174
--header "accept: text/plain" \
8275
--header "Authorization: bearer $<<parameters.torque-token>>" \
8376
--header "Content-Type: application/json" -d "$PAYLOAD"` || exit 1
@@ -96,26 +89,36 @@ steps:
9689
echo "Waiting for sandbox $<<parameters.sandbox-id-variable>>"
9790
timeout=`date --date="<<parameters.timeout>> minutes" +%s`
9891
status=''
99-
while [[ $(date +%s) -le $timeout && $status != "Active" ]]; do
92+
prev_status=''
93+
while [[ $(date +%s) -le $timeout ]]; do
94+
url="$<<parameters.torque-url>>/api/spaces/$<<parameters.space>>/environments/$<<parameters.sandbox-id-variable>>"
10095
echo "****"
101-
sleep 25
10296
details=`curl --silent \
103-
-X GET "$<<parameters.torque-url>>/api/spaces/$<<parameters.space>>/sandbox/$<<parameters.sandbox-id-variable>>" \
104-
--header "User-Agent: Torque-Plugin-CirceCI/1.0.X" \ \
97+
-X GET "${url}" \
98+
--header "User-Agent: Torque-Plugin-CirceCI/1.1.X" \
10599
--header "accept: text/plain" \
106100
--header "Authorization: bearer $<<parameters.torque-token>>"`
107-
status=`echo $details | sed "s/.*\"sandbox_status\":\"//" | sed "s/\".*//"`
108-
echo "Status is $status"
101+
status=`echo $details | sed "s/.*\"computed_status\":\"//" | sed "s/\".*//"`
102+
if [[ $status != $prev_status ]]; then
103+
echo "Status is $status"
104+
prev_status=$status
105+
fi
106+
if [[ $status == "Active" ]]; then
107+
break
108+
fi
109+
if [[ $status == "Ended" ]]; then
110+
echo "Error: sandbox is ended"
111+
exit 1
112+
fi
113+
if [[ $status == "Active With Error" ]]; then
114+
echo "Error: sandbox is active with error!"
115+
exit 1
116+
fi
117+
sleep 20
109118
done
110119
if [[ $status != "Active" ]]; then
111120
echo "Timeout was reached or Sandbox is active with errors"
112121
exit 1
113122
fi
123+
114124
echo "export <<parameters.sandbox-details-variable>>=$details" >> $BASH_ENV
115-
var=1
116-
for link in `echo $details | egrep -o '\["http?://[^ ]+*."\]' | sed 's/"//g' | tr -d '[],'`
117-
do
118-
echo "Writing quick link $link to environment variable SB_${<<parameters.sandbox-id-variable>>}_SHORTCUT_${var}"
119-
echo "export SB_${<<parameters.sandbox-id-variable>>}_SHORTCUT_${var}=$link" >> $BASH_ENV
120-
var=$((var+1))
121-
done

src/examples/fetch-info.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: |
33
usage:
44
version: 2.1
55
orbs:
6-
torque: quali/torque@1
6+
torque: quali/torque@1.1
77
jobs:
88
build:
99
docker:
@@ -13,7 +13,6 @@ usage:
1313
sandbox-name: "test-sandbox"
1414
blueprint: "my-application"
1515
inputs: "{'AWS_INSTANCE_TYPE': 'm5.large'}"
16-
artifacts: "{'app-frontend':'latest/my-app.latest.tar.gz'}"
1716
- run:
1817
name: Fetch Details
1918
command: echo "Sandbox ID is ${SANDBOX_ID}"

src/examples/test-app.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ usage:
77
version: 2.1
88

99
orbs:
10-
torque: quali/torque@1.0
10+
torque: quali/torque@1.1
1111
aws-s3: circleci/aws-s3@1.0.11
1212
jobs:
1313
build-and-publish:
@@ -32,14 +32,12 @@ usage:
3232
sandbox-name: "test-sandbox"
3333
blueprint: "my-web-application"
3434
inputs: "{'AWS_INSTANCE_TYPE': 'm5.large'}"
35-
artifacts: "{'webapp-frontend':'latest/my-webapp.latest.tar.gz'}"
3635
steps:
3736
- run: echo "Do some testing here"
3837
- run:
3938
command: |
40-
echo "Getting application endpoint"
41-
SB_ENDPOINT="SB_${SANDBOX_ID}_SHORTCUT_1"
42-
echo "Checking ${!SB_ENDPOINT}"
43-
curl --write-out "%{http_code}\n" --silent --output /dev/null "${!SB_ENDPOINT}"
39+
echo "Getting sandbox details"
40+
echo "You can process the json with jq and perform some tests"
41+
echo "${SANDBOX_DETAILS}"
4442
requires:
4543
- build-and-publish

src/jobs/sandbox.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@ parameters:
3131
Json format {'key1': 'value1', ..., 'keyN': 'valueN'}
3232
type: string
3333
default: "{}"
34-
artifacts:
35-
description: |
36-
String with the list of artifacts.
37-
Json format {'key1': 'value1', ..., 'keyN': 'valueN'}
38-
type: string
39-
default: "{}"
4034
steps:
4135
type: steps
4236
description: Steps to execute once the Torque Sandbox is available
@@ -58,7 +52,6 @@ steps:
5852
sandbox-name: <<parameters.sandbox-name>>
5953
blueprint: <<parameters.blueprint>>
6054
inputs: <<parameters.inputs>>
61-
artifacts: <<parameters.artifacts>>
6255
torque-token: <<parameters.torque-token>>
6356
torque-url: <<parameters.torque-url>>
6457
space: <<parameters.space>>

0 commit comments

Comments
 (0)