Skip to content

address(): a unified address to load containers, directories, secrets… - #10770

Merged
shykes merged 3 commits into
dagger:mainfrom
shykes:address-api
Sep 16, 2025
Merged

shykes merged 3 commits into
dagger:mainfrom
shykes:address-api

Conversation

@shykes

@shykes shykes commented Jul 21, 2025 •

Copy link
Copy Markdown
Contributor

Extract CLI logic for loading different object types from a standard address; and expose it in the engine API. This is a requirement for #10697, which is part of #10370.

Schema diff

Examples

  • address https://github.com/dagger/dagger | git-repository
  • address env://MYTOKEN | secret
  • address ~/.zshrc | file
  • address tcp://localhost:4242 | service
  • address https://github.com/dagger/dagger#main | git-ref
  • address https://github.com/dagger/dagger#main:docs | directory

@shykes
shykes requested review from a team as code owners July 21, 2025 13:09
@shykes shykes mentioned this pull request Jul 21, 2025
@vito

This comment was marked as resolved.

@shykes

shykes commented Jul 21, 2025

Copy link
Copy Markdown
Contributor Author

A bit surprised at dropping the Host here; that made a lot of sense to me before (#10753 (comment)) from a design and security standpoint.

What's to prevent arbitrary modules from being able to do e.g. address("env://GITHUB_TOKEN").plaintext?

From a security POV, it's all sandboxed anyway. So address("env://GITHUB_TOKEN") has the same result as secret("env://GITHUB_TOKEN"). So it's purely a cosmetic choice whether to place it under Host.

Host is just a rough bucket of API calls that are obviously and exclusively executed in the context of the caller host. But the bucket is already leaky.

  • Directory.export, Container.export, File.export: write to the caller/host filesystem, but not under Host
  • secret(): load secrets from the caller/host, but not under Host
  • moduleSource(): when given a local path, load the module from the caller/host 's filesystem, but not under Host
  • git(): load auth configuration from the caller/host's system
  • container.From, container.dockerBuild: load docker auth configuration from the caller/host's system

IMO there are so many exceptions already, that there's no point in hiding from module devs that some of their API calls reach into their own context, and never into the top-level caller's context (except for LLMs). That ship has sailed. As a corollary, I think the only reason to keep Host hidden, is that it has a confusing name. As soon as we agree on a less confusing name, we should un-hide it.

And from an API standpoint, how does that differ from secret("env://GITHUB_TOKEN").plaintext?

It's a convenience wrapper. The logic for the wrapper already existed: it's currently in cmd/dagger/flags.go, so that's where you'll find the answer to your question.

For some types, the wrapper is very thin. For others, it's much thicker.

In the specific case of secrets:

  • The wrapper handles backwards compatibility with older secret formats not supported by secret()
  • The wrapper parses an optional #cacheKey=xxx from the address, and passes it as a separate argument to secret()

The general idea is: address() guarantees a single string address, with no need to pass other arguments.

Even the case of host.resource("https://example.com/git/repo") could make sense to me if you think of it like routing the network through the host, i.e. if it's pointing to a private network that the host can reach but the engine can't. (It's a bit of a stretch, though, sure.)

To reiterate and summarize my earlier point: I think it's hopeless to split the Dagger API between "parts that always interact with the caller/host" and "parts that never do". It's hopelessly entangled and I think we should embrace that.

@shykes
shykes force-pushed the address-api branch 3 times, most recently from a3acccb to 27bf81d Compare July 21, 2025 15:11
@vito

vito commented Jul 21, 2025 •

Copy link
Copy Markdown
Contributor

@shykes Ahh, I see now - it's just always sandboxed (if there is one), so the CLI would use these on the outside to gain access to values from the host, and modules can also use it, but they will just be accessing their own sandbox.

From how we got here, I assumed the intent was still for these to go through the host.

@shykes

This comment was marked as resolved.

@shykes

This comment was marked as resolved.

@shykes
shykes force-pushed the address-api branch 3 times, most recently from c8530aa to ab2d76a Compare July 22, 2025 01:05
@shykes

shykes commented Jul 22, 2025

Copy link
Copy Markdown
Contributor Author

@shykes
shykes force-pushed the address-api branch 2 times, most recently from 952ff3a to c1df9b5 Compare July 22, 2025 11:36
@shykes

shykes commented Jul 22, 2025

Copy link
Copy Markdown
Contributor Author

Update on failing tests:

  • Security scan issue was fixed in a separate PR, thank you @jedevc 🙏
  • Updated TUI viz test data (thank you @jedevc for the tip: test | telemtry --update | export .). It looks less good as before, but we can address that in a follow-up if @vito deems it worth pursuing.
  • Elixir SDK test: that's from main. Will need to be addressed separately. Ignoring.

@shykes
shykes requested a review from jedevc September 9, 2025 01:27
Comment thread core/integration/address_test.go Resolved
Comment thread core/schema/address.go Resolved
Comment thread core/schema/address.go Resolved
Comment thread core/schema/address.go Resolved
Comment thread core/schema/address.go Resolved
Comment thread core/schema/address.go Resolved
Comment thread core/schema/secret.go Resolved
@shykes
shykes force-pushed the address-api branch 4 times, most recently from c47a925 to a555511 Compare September 11, 2025 09:34

@jedevc jedevc 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.

Code LGTM, just pending on tests.

Comment thread core/integration/git_test.go Resolved
Comment thread core/integration/git_test.go Resolved
Comment thread core/schema/address.go Resolved
Comment thread core/schema/address.go Resolved
@shykes
shykes force-pushed the address-api branch 5 times, most recently from 99eac5f to 09b2fb6 Compare September 12, 2025 04:49
Comment thread core/integration/host_test.go Resolved
Comment thread core/integration/services_test.go Resolved
Comment thread core/integration/address_test.go Resolved

@jedevc jedevc 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.

Optimistically approving - see above comments!

@shykes
shykes force-pushed the address-api branch 5 times, most recently from 0ea41a6 to cb57e94 Compare September 15, 2025 06:12

@jedevc jedevc 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.

Fix the failing lint check, then good to merge.

@jedevc jedevc added the needs/changelog Pull requests that require a changelog entry label Sep 15, 2025
@shykes
shykes force-pushed the address-api branch 2 times, most recently from 6ced726 to 74b38bf Compare September 15, 2025 18:25
@shykes

shykes commented Sep 15, 2025

Copy link
Copy Markdown
Contributor Author

@jedevc you were right about the tests FYI.

@shykes

shykes commented Sep 15, 2025

Copy link
Copy Markdown
Contributor Author

I've been re-running this failed tests several times, assuming it was a flake (error message seems unrelated). But it won't go away...

FYI @sipsma @alexcb @vito @jedevc @kpenfound in case you recognize the error...

sipsma and others added 3 commits September 15, 2025 18:15
…, etc.

Signed-off-by: Solomon Hykes <[email protected]>
Co-Authored-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Solomon Hykes <[email protected]>
@shykes

shykes commented Sep 16, 2025

Copy link
Copy Markdown
Contributor Author

Just barely missed the release train 😭

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs/changelog Pull requests that require a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants