Skip to content

add new Host API with directory + env access, update projects - #3304

Merged
vito merged 4 commits into
dagger:cloakfrom
vito:host
Oct 12, 2022
Merged

vito merged 4 commits into
dagger:cloakfrom
vito:host

Conversation

@vito

@vito vito commented Oct 11, 2022 •

Copy link
Copy Markdown
Contributor

fixes #3201

based on #3272 - will rebase if it's merged first

This implements the new Host core API, with added support for reading/writing to multiple local directories. See host.graphqls for the new schema.

This also updates the Project schema/code to use the new *core.Directory instead of the old *filesystem.Filesystem, with the following schema changes:

type Project {
  # ...

  "Code files generated by the SDKs in the project"
  generatedCode: Directory!
}

extend type Directory {
  "load a project's metadata"
  loadProject(configPath: String!): Project!
}

extend type Query {
  "Look up a project by name"
  project(name: String!): Project!
}

@sipsma This second part probably conflicts with your work to do the same (#3259), but I couldn't complete this without it and it seemed like maybe a mutual dependency, so I kept going.

@netlify

netlify Bot commented Oct 11, 2022 •

Copy link
Copy Markdown

👷 Deploy request for cloak-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit c855a1a

@jlongtine

Copy link
Copy Markdown
Contributor

👨🏻‍🍳 💋

Comment thread core/directory.go Outdated

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.

Does llb.Diff + llb.Merge actually fail if you try to provide different platforms? I wouldn't have expected that but also have learned to expect the unexpected when it comes to these nitty gritty details...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It might work, I'm just not sure how to represent it, or test it. 🤔 I've only seen platform get passed to Marshal and wasn't sure what should happen when we have multiple states turn into one.

With Diff I guess it's simpler because it's really a one-directional diff, more like "what has upper changed from lower." But with Merge I have no idea what to keep. Maybe the first? Or last?

Should I just remove this check and have it carry on with otherPlatform? And probably call it upper instead of other for clarity?

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.

Ah okay right, you don't have choice but to choose a value, but I agree it's not clear which one is right. Honestly feel free to just leave this as is for now. It's not causing any harm and I will think about it some more when I rebase my multiplatform PR on the new API.

Comment thread core/integration/host_test.go Outdated

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.

There's some existing tests that create extensions under testdata and use a cloak.yaml. You could re-use that pattern here too but just for loading a workdir rather than creating more extensions too. Just requires not using testutil.Query and instead starting up the engine directly with explicit workdir+configPath values.

Not a blocker but will need to happen sometime as the way config loading works is going to change in the near future.

Comment thread project/goruntime.go Outdated

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.

Is it possible for the runtimes to return Containers instead so that the image config (env vars and such) are maintained? It's not a huge deal but would be nice to have

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh good catch, I forgot Filesystem was closer to Container, will look into that now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I looked into this, it's definitely possible. Essentially these direct LLB calls need to turn into *core.Container calls. The upside is we'll land on a richer core.Container Go API, but the downside is it's a lot of work and it gets a bit verbose with all the extra err != nil checks.

One alternative is to stick with LLB and add some kind of NewContainer that takes a llb.State, but I think we'd need to manually fetch the image config, which doesn't seem great.

Here's the patch so far: https://gist.github.com/vito/65a4c3b513e7f3528cbc4ada8945eec8

Maybe better for a separate PR? Or is this introducing a regression without it?

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.

Maybe better for a separate PR? Or is this introducing a regression without it?

Yeah no need to block this one on it. There has already been some fluctuation in whether extension execution propagates the env or not, so I think most code I've seen handles the case where PATH and such isn't set right. Another brief period where it's not propagated should be okay I think.

vito added 4 commits October 11, 2022 19:22
these pretty much go hand-in-hand, since projects are loaded from local
dirs

Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>

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

LGTM

@vito
vito merged commit 09c6e1f into dagger:cloak Oct 12, 2022
@vito
vito deleted the host branch October 12, 2022 02:40
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.

3 participants