Repository navigation
Conversation
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
In the previous commit I added a bunch of new tests and some extra validation, but then forgot to run the rest of the tests, which were failing with validation errors on paths in cases that were actually okay. This fixes the validation to allow relative paths provided they don't escape the root dir, which requires some careful handling to deal with the fact that e.g. filepath.Join(/, "../..") == "/". Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Contributor
Author
|
Closing this PR out since #6386 ended up adding support for custom names of dependencies and thus fixing the problems of:
Which are also covered in integ tests now (which is all this PR consisted of). We do still need to implement support for being able to rename "core", so will leave #6328 and #6071 open to track that. But can be done backwards compatibly now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Opening as draft to start discussion while I work on proposed solution in parallel, only change so far are some new tests that exemplify the problem (and commits from the
dagger.jsonupdates PR, which this will be based on).Related to:
The need for better handling of corner case conflicts between a module's objects and dependencies/core has been on my radar for a while via those issues, but once I started working on what I thought would be relatively straightforward handling, I realized that there's more corner cases and that the solutions are potentially much more annoying for the users than I originally imagined...
These are very much corner cases, but also not obscure enough to ignore. Have a general approach in mind but want to get feedback from others in parallel while I finish implementing it since it's not entirely obvious one way or the other.
Also highly possible I'm caring way too much about obscure corner cases, feel free to let me know if you feel that way.
Example Problems
These are different manifestations of the same set of underlying problems.
An important note is that these problems all exist on the level of the graphql schema and are not specific to implementation details of any single SDK.
Conflicts between a module and a direct dep of the same name
Covered here: #6438
Basically, a module
Foothat depends on another moduleFoocurrently results in an error due to the fact modules are loaded with schemas for their own APIs in addition to their dependencies.Conflicts between two deps with same name prefix
Example:
FooBarFooand defines an object namedBarCallermodule depends on bothFooBarandFooIn this case, the schema for
Caller's deps will contain:FooBar"main module object" fromFooBarFooBarobject fromFoo(gets that name due to namespacing ofBarAnd thus there will be a conflict.
Even worse, say that originally the
Foomodule didn't haveBardefined, but was updated to in a newer version.Callermay have a bunch of code written that now suddenly stops compiling just because they updated to that new version ofBar(as opposed to getting an error before they even started writing their code, which is at least less painful even if annoying).Conflicts between a module's types and core types
Say someone authors a module named
Fooand we add a typeFooto core at some point in the future.This will create a conflict on the graphql schema level (i.e. not just the Go SDK codegen).
This is exacerbated by the fact that
coreis not namespaced, but say we did namespace everything byCore(CoreContainer,CoreDirectory,CoreFile, etc.). There would still be problems if someone had a module namedCoreFooand we added aFootype tocorein the future.Current Proposed Solution
General considerations I have in mind here:
sed -is).. If there are any changes needed, it's worth trying to make it as minimal as possible.This will come in a few parts, outlined below
Also, as the utter baseline, we obviously need clear+helpful error messages if these cases happen. Probably goes without saying.
Support for aliasing dependencies
Originally suggested this as a solution purely to #6438 but I think now it can probably be used more generally.
Basically, similar to how most languages let you alias an import, we can do the same.
As a strawman, you could imagine
dagger mod install --alias someAlias github.com/org/daggerverse/someMod`That would result in the module name of
someModto be overwritten tosomeAliasand thus all the objects would be namedspaced withSomeAlias, allowing any conflicts to be avoided.Support for aliasing individual objects
This is likely getting obscure enough that we could skip for now and save for the future if really needed, but will mention anyways.
The one catch remaining is the case where a conflict like this arises due to a dependency upgrade. It would really suck if a user had to rewrite all their usage of objects from the dep once they had to change it to an alias.
The only solution I can think of here would be to also support aliasing individual objects from a dependency in addition to aliasing the whole module name. So, again as a strawman, maybe
dagger mod install --alias-object foo bar github.com/org/daggerverse/someModwould result in the
Fooobject fromsomeModto be renamed toBarand thus allow the caller to not have to rename everything in their code (just at most a few isolated objects).coreis explicit dep indagger.json+ optionally supports aliasingComplementary to the above, we can support core being an explicit dep in
dagger.jsonand thus have the same aliasing abilities as any other module, which should give a path to also avoiding conflicts with types from it via the exact same mechanism as with user modules.This is generally complementary to a whole bunch of baby steps we been taking to model core more and more as a module, not actually that big of a leap from the current state in terms of implementation.
Longer term - module author docs
We've discussed this previously, but its importance definitely goes up a bit if we go this route.
Basically, it should be easy to view docs while authoring modules for the generated bindings to all your deps. May just need to be a builtin-sdk feature (or possibly a module of its own that operates on other modules, TBD).
This becomes even more important if alias settings result in the actual names available to you being customized. We don't want users needing to read
dagger.jsonmanually to figure stuff like this out.Other Possibilities
There's an enormous number of other variations and completely different approaches here.
But my favorite alternative is to change graphql schemas for each module to be completely independent schemas, never mixed together when being used as a set of dependencies. Could be queryable via different endpoints on the engine.
dagqlThe main reason I'm ruling this out now is partially practicality in terms of time and partially that I can't say for sure that it would actually work in practice; it's too vague and would need more detailing to make a call on.
The proposed solution is much more obvious in the short term and includes things we've wanted to do anyways (such as put core as an explicit dep in dagger.json). So it's relatively low cost. In a hypothetical future where we've changed the graphql servers + SDKs to avoid this problem entirely, then we can just sunset aliasing as a feature.
There's one last alternative solution, which is that I'm severely overthinking obscure corner cases and we can just have clear error messages + docs in these cases for now 😄 I'd honestly be happy to hear others felt that way, but atm to me these cases seem just barely too straightforward to hit that they are hard to ignore, even if relatively obscure.
cc @vito @helderco @jedevc @shykes