Skip to content

Commit

Permalink
[sdk/gleam] update README.md
Browse files Browse the repository at this point in the history
[sdk/gleam] update README.md

[sdk/gleam] update README.md
  • Loading branch information
tsirysndr committed Aug 15, 2024
1 parent 5b053f2 commit f39ba35
Show file tree
Hide file tree
Showing 105 changed files with 2,688 additions and 366 deletions.
4 changes: 4 additions & 0 deletions sdk/gleam/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.beam
*.ez
/build
erl_crash.dump
19 changes: 19 additions & 0 deletions sdk/gleam/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2024 Tsiry Sandratraina <tsiry.sndr@fluentci.io>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
57 changes: 57 additions & 0 deletions sdk/gleam/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# FluentCI Gleam SDK

[![Package Version](https://img.shields.io/hexpm/v/fluentci)](https://hex.pm/packages/fluentci)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/fluentci/)

The FluentCI Gleam SDK provides a set of APIs to interact with FluentCI in Gleam, it allows you to write CI/CD pipelines in Gleam.

## 🚚 Installation

```sh
gleam add fluentci
```

## 🚀 Quick Start

```gleam
import fluentci.{dag, pipeline, set_secret}
import fluentci/pipeline.{ stdout, with_exec, with_secret_variable}
import fluentci/secret.{plaintext}
import gleam/io
import gleam/javascript/array.{from_list}
import gleam/javascript/promise.{await, resolve}
pub fn main() {
// This pipeline will print "Hello, World!" to the console
dag()
|> pipeline("hello-world")
|> with_exec(from_list(["echo", "Hello, World!"]))
|> await(fn(output) {
io.println(output)
resolve(value)
})
// This pipeline will print the value of a secret to the console
let secret = dag() |> set_secret("GITHUB", "my-github-token")
secret
|> plaintext
|> await(fn(value) {
io.println(value)
resolve(value)
})
dag()
|> pipeline("secret-demo")
|> with_secret_variable("GITHUB", secret)
|> with_exec(from_list(["echo", "$GITHUB"]))
|> stdout
|> await(fn(value) {
io.print("Secret demo: ")
io.println(value)
resolve(value)
})
}
```

Further documentation can be found at <https://hexdocs.pm/fluentci>.
23 changes: 0 additions & 23 deletions sdk/gleam/demo/.github/workflows/test.yml

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion sdk/gleam/demo/src/demo.gleam
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fluentci/client.{dag, pipeline, set_secret}
import fluentci.{dag, pipeline, set_secret}
import fluentci/mise
import fluentci/pipeline.{mise, stdout, with_exec, with_secret_variable}
import fluentci/secret.{plaintext}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ pub type NixArgs {
NixArgs(impure: Bool)
}

@external(javascript, "../fluentci.mjs", "client")
@external(javascript, "./fluentci_ffi.mjs", "client")
pub fn dag() -> Client

@external(javascript, "../fluentci.mjs", "azureSecretsManager")
@external(javascript, "./fluentci_ffi.mjs", "azureSecretsManager")
pub fn azure_secrets_manager(
client: Client,
region: String,
access_key_id: String,
secret_access_key: String,
) -> SecretManager

@external(javascript, "../fluentci.mjs", "azureKeyvault")
@external(javascript, "./fluentci_ffi.mjs", "azureKeyvault")
pub fn azure_keyvault(
client: Client,
client_id: String,
Expand All @@ -39,59 +39,59 @@ pub fn azure_keyvault(
keyvault_url: String,
) -> SecretManager

@external(javascript, "../fluentci.mjs", "cache")
@external(javascript, "./fluentci_ffi.mjs", "cache")
pub fn cache(client: Client, key: String) -> Cache

@external(javascript, "../fluentci.mjs", "devbox")
@external(javascript, "./fluentci_ffi.mjs", "devbox")
pub fn devbox(client: Client) -> Devbox

@external(javascript, "../fluentci.mjs", "devenv")
@external(javascript, "./fluentci_ffi.mjs", "devenv")
pub fn devenv(client: Client) -> Devenv

@external(javascript, "../fluentci.mjs", "directory")
@external(javascript, "./fluentci_ffi.mjs", "directory")
pub fn directory(client: Client, path: String) -> Directory

@external(javascript, "../fluentci.mjs", "file")
@external(javascript, "./fluentci_ffi.mjs", "file")
pub fn file(client: Client, path: String) -> File

@external(javascript, "../fluentci.mjs", "flox")
@external(javascript, "./fluentci_ffi.mjs", "flox")
pub fn flox(client: Client) -> Flox

@external(javascript, "../fluentci.mjs", "git")
@external(javascript, "./fluentci_ffi.mjs", "git")
pub fn git(client: Client, url: String) -> Git

@external(javascript, "../fluentci.mjs", "googleCloudSecretManager")
@external(javascript, "./fluentci_ffi.mjs", "googleCloudSecretManager")
pub fn google_cloud_secret_manager(
client: Client,
project: String,
google_credentials_file: String,
) -> SecretManager

@external(javascript, "../fluentci.mjs", "hashicorpVault")
@external(javascript, "./fluentci_ffi.mjs", "hashicorpVault")
pub fn hashicorp_vault(
client: Client,
address: String,
token: String,
cacerts: String,
) -> SecretManager

@external(javascript, "../fluentci.mjs", "http")
@external(javascript, "./fluentci_ffi.mjs", "http")
pub fn http(client: Client, url: String) -> File

@external(javascript, "../fluentci.mjs", "mise")
@external(javascript, "./fluentci_ffi.mjs", "mise")
pub fn mise(client: Client) -> Mise

@external(javascript, "../fluentci.mjs", "nix")
@external(javascript, "./fluentci_ffi.mjs", "nix")
pub fn nix(client: Client, args: NixArgs) -> Nix

@external(javascript, "../fluentci.mjs", "pipeline")
@external(javascript, "./fluentci_ffi.mjs", "pipeline")
pub fn pipeline(client: Client, name: String) -> Pipeline

@external(javascript, "../fluentci.mjs", "pixi")
@external(javascript, "./fluentci_ffi.mjs", "pixi")
pub fn pixi(client: Client) -> Pixi

@external(javascript, "../fluentci.mjs", "pkgx")
@external(javascript, "./fluentci_ffi.mjs", "pkgx")
pub fn pkgx(client: Client) -> Pkgx

@external(javascript, "../fluentci.mjs", "setSecret")
@external(javascript, "./fluentci_ffi.mjs", "setSecret")
pub fn set_secret(client: Client, name: String, value: String) -> Secret
16 changes: 4 additions & 12 deletions sdk/gleam/demo/src/fluentci/cache.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,8 @@ import gleam/javascript/promise.{type Promise}

pub type Cache

@external(javascript, "../fluentci.mjs", "id")
pub fn id_(cache: Cache) -> Promise(String)
@external(javascript, "../fluentci_ffi.mjs", "id")
pub fn id(cache: Cache) -> Promise(String)

@external(javascript, "../fluentci.mjs", "key")
pub fn key_(cache: Cache) -> Promise(String)

pub fn id(cache: Cache) -> Promise(String) {
id_(cache)
}

pub fn key(cache: Cache) -> Promise(String) {
key_(cache)
}
@external(javascript, "../fluentci_ffi.mjs", "key")
pub fn key(cache: Cache) -> Promise(String)
2 changes: 1 addition & 1 deletion sdk/gleam/demo/src/fluentci/dagger/cache_volume.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import gleam/javascript/promise.{type Promise}

pub type CacheVolume

@external(javascript, "../../dagger.mjs", "id")
@external(javascript, "../../dagger_ffi.mjs", "id")
pub fn id(cache_volume: CacheVolume) -> Promise(String)
16 changes: 8 additions & 8 deletions sdk/gleam/demo/src/fluentci/dagger/client.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@ import fluentci/dagger/host.{type Host}

pub type Client

@external(javascript, "../../dagger.mjs", "client")
@external(javascript, "../../dagger_ffi.mjs", "client")
pub fn dag() -> Client

@external(javascript, "../../dagger.mjs", "pipeline")
@external(javascript, "../../dagger_ffi.mjs", "pipeline")
pub fn pipeline(client: Client, name: String) -> Client

@external(javascript, "../../dagger.mjs", "container")
@external(javascript, "../../dagger_ffi.mjs", "container")
pub fn container(client: Client) -> Container

@external(javascript, "../../dagger.mjs", "cacheVolume")
@external(javascript, "../../dagger_ffi.mjs", "cacheVolume")
pub fn cache_volume(client: Client, key: String) -> CacheVolume

@external(javascript, "../../dagger.mjs", "emptyDirectory")
@external(javascript, "../../dagger_ffi.mjs", "emptyDirectory")
pub fn directory(client: Client) -> Directory

@external(javascript, "../../dagger.mjs", "git")
@external(javascript, "../../dagger_ffi.mjs", "git")
pub fn git(client: Client, url: String) -> Directory

@external(javascript, "../../dagger.mjs", "host")
@external(javascript, "../../dagger_ffi.mjs", "host")
pub fn host(client: Client) -> Host

@external(javascript, "../../dagger.mjs", "http")
@external(javascript, "../../dagger_ffi.mjs", "http")
pub fn http(client: Client, url: String) -> File
10 changes: 5 additions & 5 deletions sdk/gleam/demo/src/fluentci/dagger/container.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import gleam/javascript/promise.{type Promise}

pub type Container

@external(javascript, "../../dagger.mjs", "id")
@external(javascript, "../../dagger_ffi.mjs", "id")
pub fn id(container: Container) -> Promise(String)

@external(javascript, "../../dagger.mjs", "from_")
@external(javascript, "../../dagger_ffi.mjs", "from_")
pub fn from(container: Container, image: String) -> Container

@external(javascript, "../../dagger.mjs", "withExec")
@external(javascript, "../../dagger_ffi.mjs", "withExec")
pub fn with_exec(container: Container, args: Array(String)) -> Container

@external(javascript, "../../dagger.mjs", "stdout")
@external(javascript, "../../dagger_ffi.mjs", "stdout")
pub fn stdout(container: Container) -> Promise(String)

@external(javascript, "../../dagger.mjs", "stderr")
@external(javascript, "../../dagger_ffi.mjs", "stderr")
pub fn stderr(container: Container) -> Promise(String)
40 changes: 20 additions & 20 deletions sdk/gleam/demo/src/fluentci/dagger/directory.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -6,66 +6,66 @@ import gleam/javascript/promise.{type Promise}

pub type Directory

@external(javascript, "../../dagger.mjs", "id")
@external(javascript, "../../dagger_ffi.mjs", "id")
pub fn id(directory: Directory) -> Promise(String)

@external(javascript, "../../dagger.mjs", "asModule")
@external(javascript, "../../dagger_ffi.mjs", "asModule")
pub fn as_module(directory: Directory) -> Module

@external(javascript, "../../dagger.mjs", "diff")
@external(javascript, "../../dagger_ffi.mjs", "diff")
pub fn diff(directory: Directory, other: Directory) -> Directory

@external(javascript, "../../dagger.mjs", "directory")
@external(javascript, "../../dagger_ffi.mjs", "directory")
pub fn directory(d: Directory, path: String) -> Directory

@external(javascript, "../../dagger.mjs", "dockerBuild")
@external(javascript, "../../dagger_ffi.mjs", "dockerBuild")
pub fn docker_build(directory: Directory) -> Container

@external(javascript, "../../dagger.mjs", "entries")
@external(javascript, "../../dagger_ffi.mjs", "entries")
pub fn entries(directory: Directory) -> Promise(Array(String))

@external(javascript, "../../dagger.mjs", "export_")
@external(javascript, "../../dagger_ffi.mjs", "export_")
pub fn export(directory: Directory, path: String) -> Promise(String)

@external(javascript, "../../dagger.mjs", "file")
@external(javascript, "../../dagger_ffi.mjs", "file")
pub fn file(directory: Directory, path: String) -> File

@external(javascript, "../../dagger.mjs", "glob")
@external(javascript, "../../dagger_ffi.mjs", "glob")
pub fn glob(directory: Directory, pattern: String) -> Promise(Array(String))

@external(javascript, "../../dagger.mjs", "pipeline")
@external(javascript, "../../dagger_ffi.mjs", "pipeline")
pub fn pipeline(directory: Directory, name: String) -> Directory

@external(javascript, "../../dagger.mjs", "sync")
@external(javascript, "../../dagger_ffi.mjs", "sync")
pub fn sync(directory: Directory) -> Directory

@external(javascript, "../../dagger.mjs", "terminal")
@external(javascript, "../../dagger_ffi.mjs", "terminal")
pub fn terminal(directory: Directory) -> Directory

@external(javascript, "../../dagger.mjs", "withDirectory")
@external(javascript, "../../dagger_ffi.mjs", "withDirectory")
pub fn with_directory(
d: Directory,
path: String,
directory: Directory,
) -> Directory

@external(javascript, "../../dagger.mjs", "withFile")
@external(javascript, "../../dagger_ffi.mjs", "withFile")
pub fn with_file(d: Directory, source: File) -> Directory

@external(javascript, "../../dagger.mjs", "withFiles")
@external(javascript, "../../dagger_ffi.mjs", "withFiles")
pub fn with_files(d: Directory, sources: Array(File)) -> Directory

@external(javascript, "../../dagger.mjs", "withNewDirectory")
@external(javascript, "../../dagger_ffi.mjs", "withNewDirectory")
pub fn with_new_directory(d: Directory, path: String) -> Directory

@external(javascript, "../../dagger.mjs", "withNewFile")
@external(javascript, "../../dagger_ffi.mjs", "withNewFile")
pub fn with_new_file(d: Directory, path: String, contents: String) -> Directory

@external(javascript, "../../dagger.mjs", "withTimestamps")
@external(javascript, "../../dagger_ffi.mjs", "withTimestamps")
pub fn with_timestamps(d: Directory, timestamp: Int) -> Directory

@external(javascript, "../../dagger.mjs", "withoutDirectory")
@external(javascript, "../../dagger_ffi.mjs", "withoutDirectory")
pub fn without_directory(d: Directory, path: String) -> Directory

@external(javascript, "../../dagger.mjs", "withoutFile")
@external(javascript, "../../dagger_ffi.mjs", "withoutFile")
pub fn without_file(d: Directory, path: String) -> Directory
Loading

0 comments on commit f39ba35

Please sign in to comment.