Skip to content

Commit 58254f1

Browse files
Jake ChampionJakeChampion
authored andcommitted
activate latest version after configuring or removing the secret store
1 parent efc6c3f commit 58254f1

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

integration-tests/js-compute/fixtures/secret-store/setup.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ let stores = await (async function() {
2929
}
3030
}())
3131

32-
process.env.STORE_ID = stores.data.find(({ name }) => name === 'example-test-secret-store')?.id
33-
if (!process.env.STORE_ID) {
32+
const STORE_ID = stores.data.find(({ name }) => name === 'example-test-secret-store')?.id
33+
if (!STORE_ID) {
3434
process.env.STORE_ID = JSON.parse(await zx`fastly secret-store create --name=example-test-secret-store --json --token $FASTLY_API_TOKEN`).id
35+
} else {
36+
process.env.STORE_ID = STORE_ID;
3537
}
3638

3739
try {
@@ -43,5 +45,6 @@ let key = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
4345
} catch {}
4446

4547
await zx`fastly resource-link create --version latest --resource-id $STORE_ID --token $FASTLY_API_TOKEN --autoclone`
48+
await zx`fastly service-version activate --version latest --token $FASTLY_API_TOKEN`
4649

4750
console.log(`Set up has finished! Took ${(Date.now() - startTime) / 1000} seconds to complete`);

integration-tests/js-compute/fixtures/secret-store/teardown.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,25 @@ let stores = await (async function() {
2323
return {data:[]}
2424
}
2525
}())
26-
27-
process.env.STORE_ID = stores.data.find(({ name }) => name === 'example-test-secret-store')?.id
28-
if (process.env.STORE_ID) {
26+
let links = await (async function() {
2927
try {
30-
await zx`fastly resource-link delete --version latest --autoclone --id=$STORE_ID --token $FASTLY_API_TOKEN`
31-
} catch {}
28+
return JSON.parse(await zx`fastly resource-link list --json --version latest --token $FASTLY_API_TOKEN`)
29+
} catch {
30+
return []
31+
}
32+
}())
33+
34+
const STORE_ID = stores.data.find(({ name }) => name === 'example-test-secret-store')?.id
35+
if (STORE_ID) {
36+
process.env.STORE_ID = STORE_ID;
37+
let LINK_ID = links.find(({resource_id}) => resource_id == STORE_ID)?.id;
38+
if (LINK_ID) {
39+
process.env.LINK_ID = LINK_ID;
40+
try {
41+
await zx`fastly resource-link delete --version latest --autoclone --id=$LINK_ID --token $FASTLY_API_TOKEN`
42+
await zx`fastly service-version activate --version latest --token $FASTLY_API_TOKEN`
43+
} catch {}
44+
}
3245
try {
3346
await zx`fastly secret-store delete --store-id=$STORE_ID --token $FASTLY_API_TOKEN`
3447
} catch {}

0 commit comments

Comments
 (0)