Skip to content

Commit

Permalink
add gleam bindings for dagger
Browse files Browse the repository at this point in the history
add gleam bindings for dagger

add gleam bindings for dagger
  • Loading branch information
tsirysndr committed Aug 15, 2024
1 parent d03d95c commit 5b053f2
Show file tree
Hide file tree
Showing 31 changed files with 1,341 additions and 0 deletions.
669 changes: 669 additions & 0 deletions sdk/gleam/demo/src/dagger.mjs

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions sdk/gleam/demo/src/demo_dagger.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import fluentci/dagger/client.{container, dag, pipeline}
import fluentci/dagger/container.{from, stdout, with_exec}
import gleam/io
import gleam/javascript/array.{from_list}
import gleam/javascript/promise.{await, resolve}

pub fn main() {
dag()
|> pipeline("demo")
|> container()
|> from("alpine:latest")
|> with_exec(from_list(["echo", "Hello, World!"]))
|> stdout
|> await(fn(value) {
io.println(value)
resolve(value)
})
}
6 changes: 6 additions & 0 deletions sdk/gleam/demo/src/fluentci/dagger/cache_volume.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import gleam/javascript/promise.{type Promise}

pub type CacheVolume

@external(javascript, "../../dagger.mjs", "id")
pub fn id(cache_volume: CacheVolume) -> Promise(String)
31 changes: 31 additions & 0 deletions sdk/gleam/demo/src/fluentci/dagger/client.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import fluentci/dagger/cache_volume.{type CacheVolume}
import fluentci/dagger/container.{type Container}
import fluentci/dagger/directory.{type Directory}
import fluentci/dagger/file.{type File}
import fluentci/dagger/host.{type Host}

pub type Client

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

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

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

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

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

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

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

@external(javascript, "../../dagger.mjs", "http")
pub fn http(client: Client, url: String) -> File
19 changes: 19 additions & 0 deletions sdk/gleam/demo/src/fluentci/dagger/container.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import gleam/javascript/array.{type Array}
import gleam/javascript/promise.{type Promise}

pub type Container

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

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

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

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

@external(javascript, "../../dagger.mjs", "stderr")
pub fn stderr(container: Container) -> Promise(String)
71 changes: 71 additions & 0 deletions sdk/gleam/demo/src/fluentci/dagger/directory.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import fluentci/dagger/container.{type Container}
import fluentci/dagger/file.{type File}
import fluentci/dagger/module.{type Module}
import gleam/javascript/array.{type Array}
import gleam/javascript/promise.{type Promise}

pub type Directory

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@external(javascript, "../../dagger.mjs", "withoutFile")
pub fn without_file(d: Directory, path: String) -> Directory
20 changes: 20 additions & 0 deletions sdk/gleam/demo/src/fluentci/dagger/enum_type_def.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import fluentci/dagger/enum_value_type_def.{type EnumValueTypeDef}
import gleam/javascript/array.{type Array}
import gleam/javascript/promise.{type Promise}

pub type EnumTypeDef

@external(javascript, "../../dagger.mjs", "id")
pub fn id(f: EnumTypeDef) -> Promise(String)

@external(javascript, "../../dagger.mjs", "description")
pub fn description(f: EnumTypeDef) -> Promise(String)

@external(javascript, "../../dagger.mjs", "name")
pub fn name(f: EnumTypeDef) -> Promise(String)

@external(javascript, "../../dagger.mjs", "sourceModuleName")
pub fn source_module_name(f: EnumTypeDef) -> Promise(String)

@external(javascript, "../../dagger.mjs", "values")
pub fn values(f: EnumTypeDef) -> Promise(Array(EnumValueTypeDef))
12 changes: 12 additions & 0 deletions sdk/gleam/demo/src/fluentci/dagger/enum_value_type_def.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import gleam/javascript/promise.{type Promise}

pub type EnumValueTypeDef

@external(javascript, "../../dagger.mjs", "id")
pub fn id(f: EnumValueTypeDef) -> Promise(String)

@external(javascript, "../../dagger.mjs", "description")
pub fn description(f: EnumValueTypeDef) -> Promise(String)

@external(javascript, "../../dagger.mjs", "name")
pub fn name(f: EnumValueTypeDef) -> Promise(String)
12 changes: 12 additions & 0 deletions sdk/gleam/demo/src/fluentci/dagger/env_variable.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import gleam/javascript/promise.{type Promise}

pub type EnvVariable

@external(javascript, "../../dagger.mjs", "id")
pub fn id(env_variable: EnvVariable) -> Promise(String)

@external(javascript, "../../dagger.mjs", "name")
pub fn name(env_variable: EnvVariable) -> Promise(String)

@external(javascript, "../../dagger.mjs", "value")
pub fn value(env_variable: EnvVariable) -> Promise(String)
30 changes: 30 additions & 0 deletions sdk/gleam/demo/src/fluentci/dagger/file.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import gleam/javascript/promise.{type Promise}

pub type File

@external(javascript, "../../dagger.mjs", "id")
pub fn id(file: File) -> Promise(String)

@external(javascript, "../../dagger.mjs", "contents")
pub fn contents(file: File) -> Promise(String)

@external(javascript, "../../dagger.mjs", "digest")
pub fn digest(file: File) -> Promise(String)

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

@external(javascript, "../../dagger.mjs", "name")
pub fn name(file: File) -> Promise(String)

@external(javascript, "../../dagger.mjs", "size")
pub fn size(file: File) -> Promise(Int)

@external(javascript, "../../dagger.mjs", "sync")
pub fn sync(file: File) -> Promise(File)

@external(javascript, "../../dagger.mjs", "withName")
pub fn with_name(file: File, name: String) -> File

@external(javascript, "../../dagger.mjs", "withTimestamps")
pub fn with_timestamps(file: File, timestamp: Int) -> File
27 changes: 27 additions & 0 deletions sdk/gleam/demo/src/fluentci/dagger/function.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import fluentci/dagger/function_arg.{type FunctionArg}
import fluentci/dagger/type_def.{type TypeDef}
import gleam/javascript/array.{type Array}
import gleam/javascript/promise.{type Promise}

pub type Function

@external(javascript, "../../dagger.mjs", "id")
pub fn id(f: Function) -> Promise(String)

@external(javascript, "../../dagger.mjs", "args")
pub fn args(f: Function) -> Promise(Array(FunctionArg))

@external(javascript, "../../dagger.mjs", "description")
pub fn description(f: Function) -> Promise(String)

@external(javascript, "../../dagger.mjs", "name")
pub fn name(f: Function) -> Promise(String)

@external(javascript, "../../dagger.mjs", "returnType")
pub fn return_type(f: Function) -> TypeDef

@external(javascript, "../../dagger.mjs", "withArg")
pub fn with_arg(f: Function, arg: FunctionArg) -> Function

@external(javascript, "../../dagger.mjs", "withDescription")
pub fn with_description(f: Function, description: String) -> Function
20 changes: 20 additions & 0 deletions sdk/gleam/demo/src/fluentci/dagger/function_arg.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import gleam/javascript/promise.{type Promise}

pub type JSON

pub type FunctionArg

@external(javascript, "../../dagger.mjs", "id")
pub fn id(f: FunctionArg) -> Promise(String)

@external(javascript, "../../dagger.mjs", "defaultValue")
pub fn default_value(f: FunctionArg) -> Promise(JSON)

@external(javascript, "../../dagger.mjs", "description")
pub fn description(f: FunctionArg) -> Promise(String)

@external(javascript, "../../dagger.mjs", "name")
pub fn name(f: FunctionArg) -> Promise(String)

@external(javascript, "../../dagger.mjs", "typeDef")
pub fn type_def(f: FunctionArg) -> Promise(JSON)
25 changes: 25 additions & 0 deletions sdk/gleam/demo/src/fluentci/dagger/function_call.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import fluentci/dagger/function_arg.{type JSON}
import fluentci/dagger/function_call_arg_value.{type FunctionCallArgValue}
import fluentci/dagger/void.{type Void}
import gleam/javascript/array.{type Array}
import gleam/javascript/promise.{type Promise}

pub type FunctionCall

@external(javascript, "../../dagger.mjs", "id")
pub fn id(f: FunctionCall) -> Promise(String)

@external(javascript, "../../dagger.mjs", "inputArgs")
pub fn input_args(f: FunctionCall) -> Promise(Array(FunctionCallArgValue))

@external(javascript, "../../dagger.mjs", "name")
pub fn name(f: FunctionCall) -> Promise(String)

@external(javascript, "../../dagger.mjs", "parent")
pub fn parent(f: FunctionCall) -> Promise(JSON)

@external(javascript, "../../dagger.mjs", "parentName")
pub fn parent_name(f: FunctionCall) -> Promise(String)

@external(javascript, "../../dagger.mjs", "returnValue")
pub fn return_value(f: FunctionCall, value: JSON) -> Promise(Void)
13 changes: 13 additions & 0 deletions sdk/gleam/demo/src/fluentci/dagger/function_call_arg_value.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import fluentci/dagger/function_arg.{type JSON}
import gleam/javascript/promise.{type Promise}

pub type FunctionCallArgValue

@external(javascript, "../../dagger.mjs", "id")
pub fn id(f: FunctionCallArgValue) -> Promise(String)

@external(javascript, "../../dagger.mjs", "name")
pub fn name(f: FunctionCallArgValue) -> Promise(String)

@external(javascript, "../../dagger.mjs", "value")
pub fn value(f: FunctionCallArgValue) -> Promise(JSON)
29 changes: 29 additions & 0 deletions sdk/gleam/demo/src/fluentci/dagger/generated_code.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import fluentci/dagger/directory.{type Directory}
import gleam/javascript/array.{type Array}
import gleam/javascript/promise.{type Promise}

pub type GeneratedCode

@external(javascript, "../../dagger.mjs", "id")
pub fn id(f: GeneratedCode) -> Promise(String)

@external(javascript, "../../dagger.mjs", "code")
pub fn code(f: GeneratedCode) -> Directory

@external(javascript, "../../dagger.mjs", "vcsGeneratedPaths")
pub fn vcs_generated_paths(f: GeneratedCode) -> Promise(Array(String))

@external(javascript, "../../dagger.mjs", "vcsIgnoredPaths")
pub fn vcs_ignored_paths(f: GeneratedCode) -> Promise(Array(String))

@external(javascript, "../../dagger.mjs", "withVSCGeneratedPaths")
pub fn with_vsc_generated_paths(
f: GeneratedCode,
paths: Array(String),
) -> GeneratedCode

@external(javascript, "../../dagger.mjs", "withVSCIgnoredPaths")
pub fn with_vsc_ignored_paths(
f: GeneratedCode,
paths: Array(String),
) -> GeneratedCode
33 changes: 33 additions & 0 deletions sdk/gleam/demo/src/fluentci/dagger/git.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import fluentci/dagger/git_ref.{type GitRef}
import fluentci/dagger/secret.{type Secret}
import gleam/javascript/array.{type Array}
import gleam/javascript/promise.{type Promise}

pub type GitRepository

@external(javascript, "../../dagger.mjs", "id")
pub fn id(git: GitRepository) -> Promise(String)

@external(javascript, "../../dagger.mjs", "branch")
pub fn branch(git: GitRepository, name: String) -> GitRef

@external(javascript, "../../dagger.mjs", "commit")
pub fn commit(git: GitRepository, id: String) -> GitRef

@external(javascript, "../../dagger.mjs", "head")
pub fn head(git: GitRepository) -> GitRef

@external(javascript, "../../dagger.mjs", "ref")
pub fn ref(git: GitRepository, name: String) -> GitRef

@external(javascript, "../../dagger.mjs", "tag")
pub fn tag(git: GitRepository, name: String) -> GitRef

@external(javascript, "../../dagger.mjs", "tags")
pub fn tags(git: GitRepository) -> Array(String)

@external(javascript, "../../dagger.mjs", "withAuthHeader")
pub fn with_auth_header(git: GitRepository, header: Secret) -> GitRepository

@external(javascript, "../../dagger.mjs", "withAuthToken")
pub fn with_auth_token(git: GitRepository, token: Secret) -> GitRepository
Loading

0 comments on commit 5b053f2

Please sign in to comment.