Refactor: make sources more pluggable#4035
Conversation
85f35d5 to
e6ddffc
Compare
|
This is ready for a look; I've just been able to use it to implement custom sources out-of-band (assuming direct access to the |
jedevc
left a comment
There was a problem hiding this comment.
LGTM, PTAL @tonistiigi when you have the chance 🎉
|
Could you explain more how you plan to use this? I'm afraid that this can be used to create new custom source schemas that are incompatible with buildkitd, client and frontends. I'd like to avoid that there is a versioned LLB or some LLB with extensions that only works on some systems. |
|
@tonistiigi As an alternative to #3960 we have overridden the HTTP and Git sources with implementations that support our container-to-container DNS scheme. Right now we have to smuggle values through the existing So tl;dr is we plan to use this as an escape hatch. There seems to be some interest in figuring how c2c/c2h/h2c networking could work in Buildkit, which makes sense to carefully design, I just don't want to be blocked until we figure it out. This way we can treat Dagger like a testing ground for ideas that can graduate into Buildkit, possibly after a total redesign or two. |
|
I'm trying to avoid the case where there are source schemas that the LLB format does not actually support. Could we reorganize this so there is still only a fixed list of source types that |
|
Maybe something like |
|
@vito does @tonistiigi's suggestion sound good to you? I'm happy to pick up the last bits of refactoring to take this over the finish line if you're a bit busy atm. I've been doing some work around git sources in #4142, and have been wishing for the improved structure from this PR 🎉 |
|
It kind of defeats the purpose of this PR, because we can already replace sources, we'd just like to not have to hack values into the existing In any case, we're not blocked on this anymore, so feel free to close it. I figured a regular old refactor wouldn't be controversial but maybe there are other downsides I'm not seeing. 🤷♂️ |
|
@vito I think I agree with you here, given that this PR doesn't really enable anything that wasn't possible before, I think it's fine as is. To me, having the ability to extend the I also agree with @tonistiigi though, I think it's important that we try and steer away from splitting LLB by ending up with entirely custom sources, e.g. I'm happy to merge this, I think having a discussion around adding completely custom schemes and sources to match them falls outside of the scope of this PR, so we should continue that separately if we need to. |
Sources are a pretty neat extension point, except there are a few code paths that hard-code against each type. This moves code around and adjusts interfaces so that Source implementations are self-contained and merely need to be registered with the source.Manager. Signed-off-by: Alex Suraci <suraci.alex@gmail.com>
9696f2e to
6b27487
Compare
|
Rebased and squashed (and fixed up above nits), to prep for merging. |
jedevc
left a comment
There was a problem hiding this comment.
Let's get this in - this refactor will make my life a lot more pleasant ❤️
Happy to write a follow-up PR if we're still concerned about custom schemes, but given this is all internal, people messing with these APIs should know what they're doing 👀
|
@jedevc Thanks for tidying up those nits! 🙏 |
Sources are a pretty neat extension point, except there are a few code paths that hard-code against each type. This moves code around and adjusts interfaces so that Source implementations are self-contained and merely need to be registered with the
*source.Manager.Code change cliff's notes:
source.Sourcenow exposesSchemes() []stringinstead ofID() stringhttp://andhttps://.docker-image://andoci-layout://, but I left them as-is for now (one implementation with twoSources registered with different configs).*source.Managernow stores a mapping from schemes to Sources*source.FooIdentifiertypes now live in each respectivesource/foo/packagesource.Sourcenow createssource.Identifiersource.Identifiernow implementsCapture(cap *provenance.Capture, pin string)source.Identifiernow implementsScheme()instead ofID()(feels a bit clearer)If this is merged I won't need #3960 anymore because I can just implement my own custom sources.Nevermind, these are orthogonal; I can't use a custom source to inject network config intoExecOp, and I can already override sources without this change. Merging #3960 would still be the cleanest solution for me, but I think this refactor is worthwhile anyway.