Skip to content

sdk(elixir): returns {:ok, result} instead of just result - #5372

Merged
gerhard merged 1 commit into
dagger:mainfrom
wingyplus:execute-result
Jun 30, 2023
Merged

gerhard merged 1 commit into
dagger:mainfrom
wingyplus:execute-result

Conversation

@wingyplus

Copy link
Copy Markdown
Contributor

Make any api that perform graphql request return in pattern of {:ok, result} | {:error, reason} pattern. Lets take a look at the example:

Mix.install([
  {:dagger, path: "."}
])

client = Dagger.connect!()

client
|> Dagger.Query.container()
|> Dagger.Container.from("nginx")
|> Dagger.Container.env_variables()
|> IO.inspect()

Dagger.close(client)

Then run:

$ elixir test.exs
Connected to engine f63d9f1488ba
#1 resolve image config for docker.io/library/nginx:latest
{:ok,
 [
   %{
     "name" => "PATH",
     "value" => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
   },
   %{"name" => "NGINX_VERSION", "value" => "1.25.1"},
   %{"name" => "NJS_VERSION", "value" => "0.7.12"},
   %{"name" => "PKG_RELEASE", "value" => "1~bookworm"}
 ]}

NOTE: this must be executed under sdk/elixir directory.

Signed-off-by: Thanabodee Charoenpiriyakij <[email protected]>
@wingyplus
wingyplus requested a review from a team as a code owner June 28, 2023 14:35
@wingyplus wingyplus changed the title sdk(elixir): returns result instead of single value sdk(elixir): returns {:ok, result} instead of just result Jun 28, 2023
@gerhard

gerhard commented Jun 30, 2023

Copy link
Copy Markdown
Contributor

Just started looking into this.

@gerhard gerhard left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 🚀

> elixir test.exs
Connected to engine 80ef0fba4cb4
#1 resolve image config for cgr.dev/chainguard/git:latest
{:ok,
 [
   %{
     "name" => "PATH",
     "value" => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
   },
   %{"name" => "SSL_CERT_FILE", "value" => "/etc/ssl/certs/ca-certificates.crt"}
 ]}

@gerhard
gerhard merged commit 2212550 into dagger:main Jun 30, 2023
@wingyplus
wingyplus deleted the execute-result branch June 30, 2023 16:12
@gerhard gerhard mentioned this pull request Jun 30, 2023
kjuulh added a commit that referenced this pull request Jul 1, 2023
* Fix Rust SDK errors

They started happening right after
#5372 got merged, even though this
commit didn't change anything in the Rust SDK.

Updating all dependencies to latest via `cargo update` & re-running
the Rust SDK codegen (which seems to create incorrect comments) fixed
the issue for both lint & test.

Signed-off-by: Gerhard Lazu <[email protected]>

* feat: temporary fix waiting for: udoprog/genco/issues/39

Signed-off-by: kjuulh <[email protected]>

* feat: with stable version

Signed-off-by: kjuulh <[email protected]>

* feat: with common variables

Signed-off-by: kjuulh <[email protected]>

* feat: with rustfmt in base image

Signed-off-by: kjuulh <[email protected]>

---------

Signed-off-by: Gerhard Lazu <[email protected]>
Signed-off-by: kjuulh <[email protected]>
Co-authored-by: kjuulh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants