// AUTO-GENERATED BY DAGGER_GLEAM - DO NOT EDIT import dagger/types.{type Client, type Try} as types import dagger/interpreter import dagger/dsl/types as t import gleam/dynamic/decode import gleam/list import gleam/option.{type Option, None, Some} pub type Opts { Opts( ssh_known_hosts: Option(String), ssh_auth_socket: Option(t.Socket), http_auth_username: Option(String), http_auth_token: Option(t.Secret), http_auth_header: Option(t.Secret), experimental_service_host: Option(t.Service), patterns: Option(List(String)), discard_git_dir: Option(Bool), depth: Option(Int), ) } fn defaults() -> Opts { Opts( ssh_known_hosts: None, ssh_auth_socket: None, http_auth_username: None, http_auth_token: None, http_auth_header: None, experimental_service_host: None, patterns: None, discard_git_dir: None, depth: None, ) } pub fn none(opts: Opts) -> Opts { opts } pub fn ssh_known_hosts(opts: Opts, val: String) -> Opts { Opts(..opts, ssh_known_hosts: Some(val)) } pub fn ssh_auth_socket(opts: Opts, val: t.Socket) -> Opts { Opts(..opts, ssh_auth_socket: Some(val)) } pub fn http_auth_username(opts: Opts, val: String) -> Opts { Opts(..opts, http_auth_username: Some(val)) } pub fn http_auth_token(opts: Opts, val: t.Secret) -> Opts { Opts(..opts, http_auth_token: Some(val)) } pub fn http_auth_header(opts: Opts, val: t.Secret) -> Opts { Opts(..opts, http_auth_header: Some(val)) } pub fn experimental_service_host(opts: Opts, val: t.Service) -> Opts { Opts(..opts, experimental_service_host: Some(val)) } pub fn patterns(opts: Opts, val: List(String)) -> Opts { Opts(..opts, patterns: Some(val)) } pub fn discard_git_dir(opts: Opts, val: Bool) -> Opts { Opts(..opts, discard_git_dir: Some(val)) } pub fn depth(opts: Opts, val: Int) -> Opts { Opts(..opts, depth: Some(val)) } fn encode_git_repository(opts: Opts) -> List(#(String, types.Value)) { list.filter_map([ case opts.ssh_known_hosts { Some(val) -> Ok(#("sshKnownHosts", types.GString(val))) None -> Error(Nil) }, case opts.ssh_auth_socket { Some(val) -> Ok(#("sshAuthSocket", types.GDeferred(val.op))) None -> Error(Nil) }, case opts.http_auth_username { Some(val) -> Ok(#("httpAuthUsername", types.GString(val))) None -> Error(Nil) }, case opts.http_auth_token { Some(val) -> Ok(#("httpAuthToken", types.GDeferred(val.op))) None -> Error(Nil) }, case opts.http_auth_header { Some(val) -> Ok(#("httpAuthHeader", types.GDeferred(val.op))) None -> Error(Nil) }, case opts.experimental_service_host { Some(val) -> Ok(#("experimentalServiceHost", types.GDeferred(val.op))) None -> Error(Nil) } ], fn(x) { x }) } pub fn git_repository(url url: String, with with_fn: fn(Opts) -> Opts) -> t.GitRepository { let opts = with_fn(defaults()) let field = types.Field(name: "git", args: list.append([#("url", types.GString(url))], encode_git_repository(opts)), subfields: []) t.GitRepository(op: types.Pure([field])) } /// Returns details of a branch. pub fn branch(parent: t.GitRepository, name name: String) -> t.GitRef { let field = types.Field(name: "branch", args: [#("name", types.GString(name))], subfields: []) let new_op = { use q <- types.bind(parent.op) types.Pure(list.append(q, [field])) } t.GitRef(op: new_op) } fn encode_branches(opts: Opts) -> List(#(String, types.Value)) { list.filter_map([ case opts.patterns { Some(val) -> Ok(#("patterns", types.GList(list.map(val, fn(x) { types.GString(x) })))) None -> Error(Nil) } ], fn(x) { x }) } /// branches that match any of the given glob patterns. pub fn branches(parent: t.GitRepository, with with_fn: fn(Opts) -> Opts, client client: Client, then handler: fn(Try(List(String))) -> a) -> a { let opts = with_fn(defaults()) let field = types.Field(name: "branches", args: encode_branches(opts), subfields: []) let op = { use q <- types.bind(parent.op) let full_query = list.append(q, [field]) types.Fetch( fields: full_query, decoder: decode.dynamic, next: fn(dyn) { let path = types.make_path(full_query) case decode.run(dyn, decode.at(path, decode.list(decode.string))) { Ok(val) -> types.Pure(Ok(val)) Error(_) -> types.Pure(Error(types.DecodingError("branches"))) } } ) } handler(interpreter.run(op, client)) } /// Returns details of a commit. pub fn repository_commit(parent: t.GitRepository, id id: String) -> t.GitRef { let field = types.Field(name: "commit", args: [#("id", types.GString(id))], subfields: []) let new_op = { use q <- types.bind(parent.op) types.Pure(list.append(q, [field])) } t.GitRef(op: new_op) } /// Returns details for HEAD. pub fn head(parent: t.GitRepository) -> t.GitRef { let field = types.Field(name: "head", args: [], subfields: []) let new_op = { use q <- types.bind(parent.op) types.Pure(list.append(q, [field])) } t.GitRef(op: new_op) } /// A unique identifier for this GitRepository. pub fn repository_id(parent: t.GitRepository) -> t.GitRepository { let field = types.Field(name: "id", args: [], subfields: []) let new_op = { use q <- types.bind(parent.op) types.Pure(list.append(q, [field])) } t.GitRepository(op: new_op) } /// Returns details for the latest semver tag. pub fn latest_version(parent: t.GitRepository) -> t.GitRef { let field = types.Field(name: "latestVersion", args: [], subfields: []) let new_op = { use q <- types.bind(parent.op) types.Pure(list.append(q, [field])) } t.GitRef(op: new_op) } /// Returns details of a ref. pub fn repository_ref(parent: t.GitRepository, name name: String) -> t.GitRef { let field = types.Field(name: "ref", args: [#("name", types.GString(name))], subfields: []) let new_op = { use q <- types.bind(parent.op) types.Pure(list.append(q, [field])) } t.GitRef(op: new_op) } /// Returns details of a tag. pub fn tag(parent: t.GitRepository, name name: String) -> t.GitRef { let field = types.Field(name: "tag", args: [#("name", types.GString(name))], subfields: []) let new_op = { use q <- types.bind(parent.op) types.Pure(list.append(q, [field])) } t.GitRef(op: new_op) } fn encode_tags(opts: Opts) -> List(#(String, types.Value)) { list.filter_map([ case opts.patterns { Some(val) -> Ok(#("patterns", types.GList(list.map(val, fn(x) { types.GString(x) })))) None -> Error(Nil) } ], fn(x) { x }) } /// tags that match any of the given glob patterns. pub fn tags(parent: t.GitRepository, with with_fn: fn(Opts) -> Opts, client client: Client, then handler: fn(Try(List(String))) -> a) -> a { let opts = with_fn(defaults()) let field = types.Field(name: "tags", args: encode_tags(opts), subfields: []) let op = { use q <- types.bind(parent.op) let full_query = list.append(q, [field]) types.Fetch( fields: full_query, decoder: decode.dynamic, next: fn(dyn) { let path = types.make_path(full_query) case decode.run(dyn, decode.at(path, decode.list(decode.string))) { Ok(val) -> types.Pure(Ok(val)) Error(_) -> types.Pure(Error(types.DecodingError("tags"))) } } ) } handler(interpreter.run(op, client)) } /// Returns the changeset of uncommitted changes in the git repository. pub fn uncommitted(parent: t.GitRepository) -> t.Changeset { let field = types.Field(name: "uncommitted", args: [], subfields: []) let new_op = { use q <- types.bind(parent.op) types.Pure(list.append(q, [field])) } t.Changeset(op: new_op) } /// The URL of the git repository. pub fn url(parent: t.GitRepository, client client: Client, then handler: fn(Try(String)) -> a) -> a { let field = types.Field(name: "url", args: [], subfields: []) let op = { use q <- types.bind(parent.op) let full_query = list.append(q, [field]) types.Fetch( fields: full_query, decoder: decode.dynamic, next: fn(dyn) { let path = types.make_path(full_query) case decode.run(dyn, decode.at(path, decode.string)) { Ok(val) -> types.Pure(Ok(val)) Error(_) -> types.Pure(Error(types.DecodingError("url"))) } } ) } handler(interpreter.run(op, client)) } pub fn git_ref(id id: t.GitRef) -> t.GitRef { let field = types.Field(name: "loadGitRefFromID", args: [#("id", types.GDeferred(id.op))], subfields: []) t.GitRef(op: types.Pure([field])) } /// The resolved commit id at this ref. pub fn ref_commit(parent: t.GitRef, client client: Client, then handler: fn(Try(String)) -> a) -> a { let field = types.Field(name: "commit", args: [], subfields: []) let op = { use q <- types.bind(parent.op) let full_query = list.append(q, [field]) types.Fetch( fields: full_query, decoder: decode.dynamic, next: fn(dyn) { let path = types.make_path(full_query) case decode.run(dyn, decode.at(path, decode.string)) { Ok(val) -> types.Pure(Ok(val)) Error(_) -> types.Pure(Error(types.DecodingError("commit"))) } } ) } handler(interpreter.run(op, client)) } /// Find the best common ancestor between this ref and another ref. pub fn common_ancestor(parent: t.GitRef, other other: t.GitRef) -> t.GitRef { let field = types.Field(name: "commonAncestor", args: [#("other", types.GDeferred(other.op))], subfields: []) let new_op = { use q <- types.bind(parent.op) types.Pure(list.append(q, [field])) } t.GitRef(op: new_op) } /// A unique identifier for this GitRef. pub fn ref_id(parent: t.GitRef) -> t.GitRef { let field = types.Field(name: "id", args: [], subfields: []) let new_op = { use q <- types.bind(parent.op) types.Pure(list.append(q, [field])) } t.GitRef(op: new_op) } /// The resolved ref name at this ref. pub fn ref_ref(parent: t.GitRef, client client: Client, then handler: fn(Try(String)) -> a) -> a { let field = types.Field(name: "ref", args: [], subfields: []) let op = { use q <- types.bind(parent.op) let full_query = list.append(q, [field]) types.Fetch( fields: full_query, decoder: decode.dynamic, next: fn(dyn) { let path = types.make_path(full_query) case decode.run(dyn, decode.at(path, decode.string)) { Ok(val) -> types.Pure(Ok(val)) Error(_) -> types.Pure(Error(types.DecodingError("ref"))) } } ) } handler(interpreter.run(op, client)) } fn encode_tree(opts: Opts) -> List(#(String, types.Value)) { list.filter_map([ case opts.discard_git_dir { Some(val) -> Ok(#("discardGitDir", types.GBool(val))) None -> Error(Nil) }, case opts.depth { Some(val) -> Ok(#("depth", types.GInt(val))) None -> Error(Nil) } ], fn(x) { x }) } /// The filesystem tree at this ref. pub fn tree(parent: t.GitRef, with with_fn: fn(Opts) -> Opts) -> t.Directory { let opts = with_fn(defaults()) let field = types.Field(name: "tree", args: encode_tree(opts), subfields: []) let new_op = { use q <- types.bind(parent.op) types.Pure(list.append(q, [field])) } t.Directory(op: new_op) }