Skip to content

Commit 0ae1e79

Browse files
committed
don't use scaleway script installer
1 parent 5c32dd3 commit 0ae1e79

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ Add the following command to your CI configuration file:
1313
fluentci run --wasm scaleway setup
1414
```
1515

16+
## Environment Variables
17+
18+
| Name | Description | Default |
19+
| ----------- | --------------------------------------- | -------- |
20+
| SCW_VERSION | The version of scaleway cli to install. | `2.32.1` |
21+
1622
## Functions
1723

1824
| Name | Description |

src/lib.rs

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,45 @@ use fluentci_pdk::dag;
33

44
#[plugin_fn]
55
pub fn setup(_: String) -> FnResult<String> {
6+
let os = dag().get_os()?;
7+
let arch = dag().get_arch()?;
8+
9+
match os.as_str() {
10+
"macos" => {
11+
dag().set_envs(vec![("OS".into(), "darwin".into())])?;
12+
}
13+
_ => dag().set_envs(vec![("OS".into(), os)])?,
14+
}
15+
16+
match arch.as_str() {
17+
"x86_64" => {
18+
dag().set_envs(vec![("ARCH".into(), "amd64".into())])?;
19+
}
20+
"aarch64" => {
21+
dag().set_envs(vec![("ARCH".into(), "arm64".into())])?;
22+
}
23+
_ => dag().set_envs(vec![("ARCH".into(), arch)])?,
24+
}
25+
let version = dag().get_env("SCW_VERSION")?;
26+
27+
if version.is_empty() {
28+
dag().set_envs(vec![("SCW_VERSION".into(), "2.32.1".into())])?;
29+
}
30+
31+
let home = dag().get_env("HOME")?;
32+
let path = dag().get_env("PATH")?;
33+
34+
dag().set_envs(vec![(
35+
"PATH".into(),
36+
format!("{}/.local/bin:{}", home, path),
37+
)])?;
38+
639
let stdout = dag()
740
.pkgx()?
8-
.with_exec(vec!["pkgx curl -s https://raw.githubusercontent.com/scaleway/scaleway-cli/master/scripts/get.sh | sh"])?
41+
.with_exec(vec!["type scw > /dev/null 2> /dev/null || pkgx wget https://github.com/scaleway/scaleway-cli/releases/download/v${SCW_VERSION}/scaleway-cli_${SCW_VERSION}_${OS}_${ARCH}"])?
42+
.with_exec(vec!["type scw > /dev/null 2> /dev/null || chmod a+x scaleway-cli_${SCW_VERSION}_${OS}_${ARCH}"])?
43+
.with_exec(vec!["mkdir -p $HOME/.local/bin"])?
44+
.with_exec(vec!["type scw > /dev/null 2> /dev/null || mv scaleway-cli_${SCW_VERSION}_${OS}_${ARCH} $HOME/.local/bin/scw"])?
945
.stdout()?;
1046

1147
Ok(stdout)

0 commit comments

Comments
 (0)