Skip to content

Commit 0a11b47

Browse files
committed
Added scaleway provider
1 parent d860295 commit 0a11b47

File tree

3 files changed

+104
-1
lines changed

3 files changed

+104
-1
lines changed

app/server.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,12 @@ async def vultr_regions(request):
192192
json_body = await r.json()
193193
return web.json_response(json_body)
194194

195+
196+
@routes.get('/scaleway_config')
197+
async def check_scaleway_config(request):
198+
return web.json_response({"ok": 'SCW_TOKEN' in os.environ})
199+
200+
195201
app = web.Application()
196202
app.router.add_routes(routes)
197203
app.add_routes([web.static('/static', join(PROJECT_ROOT, 'app', 'static'))])

app/static/provider-scaleway.vue

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<template>
2+
<div>
3+
4+
<div class="form-group">
5+
<label
6+
>Enter your auth token
7+
<a
8+
href="https://trailofbits.github.io/algo/cloud-scaleway.html"
9+
title="https://trailofbits.github.io/algo/cloud-scaleway.html"
10+
target="_blank"
11+
rel="noreferrer noopener"
12+
class="badge bagde-pill badge-primary"
13+
>?</a
14+
></label
15+
>
16+
<input
17+
type="text"
18+
class="form-control"
19+
name="scaleway_token"
20+
v-bind:disabled="ui_loading_check || ui_token_from_env"
21+
v-model="scaleway_token"
22+
/>
23+
<p v-if="ui_token_from_env">Token was read from the environment</p>
24+
</div>
25+
26+
<div class="form-group">
27+
<region-select v-model="region" v-bind:options="ui_region_options">
28+
</region-select>
29+
</div>
30+
31+
<button
32+
class="btn btn-primary"
33+
type="button"
34+
v-on:click="submit"
35+
v-bind:disabled="!is_valid"
36+
>
37+
Next
38+
</button>
39+
</div>
40+
</template>
41+
42+
<script>
43+
module.exports = {
44+
data: function () {
45+
return {
46+
scaleway_token: null,
47+
region: null,
48+
// helper variables
49+
ui_token_from_env: false,
50+
ui_loading_check: false,
51+
ui_region_options: [
52+
{value: 'Paris 1', key: 'par1'},
53+
{value: 'Amsterdam 1', key: 'ams1'}
54+
]
55+
};
56+
},
57+
created: function() {
58+
this.check_config();
59+
},
60+
computed: {
61+
is_valid() {
62+
return this.region && (this.scaleway_token || this.ui_token_from_env);
63+
}
64+
},
65+
methods: {
66+
check_config() {
67+
this.ui_loading_check = true;
68+
fetch("/scaleway_config")
69+
.then(r => r.json())
70+
.then(response => {
71+
if (response.ok) {
72+
this.ui_token_from_env = true;
73+
}
74+
})
75+
.finally(() => {
76+
this.ui_loading_check = false;
77+
});
78+
},
79+
submit() {
80+
if (this.ui_token_from_env) {
81+
this.$emit("submit", {
82+
region: this.region
83+
});
84+
} else {
85+
this.$emit("submit", {
86+
scaleway_token: this.scaleway_token,
87+
region: this.region
88+
});
89+
}
90+
},
91+
},
92+
components: {
93+
"region-select": window.httpVueLoader("/static/region-select.vue")
94+
},
95+
};
96+
</script>

app/static/provider-setup.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ module.exports = {
6161
'lightsail': window.httpVueLoader('/static/provider-lightsail.vue'),
6262
'ec2': window.httpVueLoader('/static/provider-ec2.vue'),
6363
'gce': window.httpVueLoader('/static/provider-gce.vue'),
64-
'vultr': window.httpVueLoader('/static/provider-vultr.vue')
64+
'vultr': window.httpVueLoader('/static/provider-vultr.vue'),
65+
'scaleway': window.httpVueLoader('/static/provider-scaleway.vue')
6566
}
6667
};
6768
</script>

0 commit comments

Comments
 (0)