Skip to content

Commit

Permalink
don't use scaleway script installer
Browse files Browse the repository at this point in the history
  • Loading branch information
tsirysndr committed Aug 7, 2024
1 parent 5c32dd3 commit 0ae1e79
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ Add the following command to your CI configuration file:
fluentci run --wasm scaleway setup
```

## Environment Variables

| Name | Description | Default |
| ----------- | --------------------------------------- | -------- |
| SCW_VERSION | The version of scaleway cli to install. | `2.32.1` |

## Functions

| Name | Description |
Expand Down
38 changes: 37 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,45 @@ use fluentci_pdk::dag;

#[plugin_fn]
pub fn setup(_: String) -> FnResult<String> {
let os = dag().get_os()?;
let arch = dag().get_arch()?;

match os.as_str() {
"macos" => {
dag().set_envs(vec![("OS".into(), "darwin".into())])?;
}
_ => dag().set_envs(vec![("OS".into(), os)])?,
}

match arch.as_str() {
"x86_64" => {
dag().set_envs(vec![("ARCH".into(), "amd64".into())])?;
}
"aarch64" => {
dag().set_envs(vec![("ARCH".into(), "arm64".into())])?;
}
_ => dag().set_envs(vec![("ARCH".into(), arch)])?,
}
let version = dag().get_env("SCW_VERSION")?;

if version.is_empty() {
dag().set_envs(vec![("SCW_VERSION".into(), "2.32.1".into())])?;
}

let home = dag().get_env("HOME")?;
let path = dag().get_env("PATH")?;

dag().set_envs(vec![(
"PATH".into(),
format!("{}/.local/bin:{}", home, path),
)])?;

let stdout = dag()
.pkgx()?
.with_exec(vec!["pkgx curl -s https://raw.githubusercontent.com/scaleway/scaleway-cli/master/scripts/get.sh | sh"])?
.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}"])?
.with_exec(vec!["type scw > /dev/null 2> /dev/null || chmod a+x scaleway-cli_${SCW_VERSION}_${OS}_${ARCH}"])?
.with_exec(vec!["mkdir -p $HOME/.local/bin"])?
.with_exec(vec!["type scw > /dev/null 2> /dev/null || mv scaleway-cli_${SCW_VERSION}_${OS}_${ARCH} $HOME/.local/bin/scw"])?
.stdout()?;

Ok(stdout)
Expand Down

0 comments on commit 0ae1e79

Please sign in to comment.