Repository navigation
Host resources - #10753
Host resources#10753shykes wants to merge 1 commit into
Conversation
c57ae21 to
f1b1bc7
Compare
…ddress Signed-off-by: Solomon Hykes <[email protected]>
|
Open question: are these host resources, or just... resources? |
'Host resources' makes sense to me since they're always resolved relative to the host - e.g. when you pass It also makes sense to gatekeep them a bit, e.g. modules currently can't access the |
Since it's a remote git repo. I'd personally vote for just dropping the leading But not highly opinionated there. Also seems like we'll might want to add an enum alongside each of the resource := dag.Resource("env://FOO")
kind, err := resource.Kind(ctx) // returns an enum indicating which kind of resource it is
if err != nil { // ... }
switch kind {
case dagger.SecretResourceKind:
secret := resource.AsSecret()
// do stuff with it ...
case dagger.Container:
ctr := resource.AsContainer()
// do stuff with it ...
}That's what we've done for other similar parts of the API (like ModuleSource). Otherwise you are forced to try each However, that does bring up the related question of whether it's always going to be a one-to-one mapping of a given URI to its valid "kind" (container, secret, etc.) or if it would every make sense for multiple to be possible. e.g. I suppose since we support turning a local dir into a
In which case the enum idea might need some adjustment 🤔 Just food for thought at this point |
|
@sipsma yeah in this case it's specifically not going to be a one-to-one mapping IMO. This design is an attempt at making the API more readable and concise - but conceptually it could also be done like this: And so on. |
|
@sipsma re: dropping the "host": yeah I was wondering the same thing.
|
|
Just to throw another design point into the mix - if we put it behind |
| return inst, err | ||
| } | ||
|
|
||
| func (s *hostSchema) resourceAsService( |
There was a problem hiding this comment.
Thoughts on a future resourceAsContainer? That would be used for parsing the CLI args for a remote image. Would also be used to use it as default values for a Container arg, etc, see #8483.
Reason I'm raising, is because in the context of #10737, there's two potential places to load from: the host, or a remote registry. Just wondering what the API would look like here 🤔
There was a problem hiding this comment.
This PR already defines resourceAsContainer, is that what you mean? https://github.com/dagger/dagger/pull/10753/files/2cc8e15e087cb659a3f919892587a15206927976#diff-09f798f10567cb9017b829bfa481df0a90e444368d36bd8f7025a69d1d2521c9R486
There was a problem hiding this comment.
Ah, it's at the top 🤦♀️ Yeah that!
Just kinda wondering how this would work if a host container store was connected, it should probably be able to look there as well?
Good point. No strong opinion about hiding it from modules. I think, given that runtime access is correctly sandboxed, there's no strong requirement to hide this API from modules. It boils down to making sure devs are not confused by the API. |
|
Forgot to comment this: very nice, I like it 🎉 |
|
Closing in favor of #10770 |
Overview
This introduces a unified naming system for host resources, and an API for loading them.
Host resources are useful anytime you need a text representation for various resources in the Dagger API, and a simple way to convert that text representation to a typed object.
Purpose
This removes logic that already exists in the CLI, and moves it to the engine. That will allow implementing #10697 which is part of #10370 .