-
Notifications
You must be signed in to change notification settings - Fork 689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: remove go aliases #7831
feat: remove go aliases #7831
Conversation
a246f93
to
02075cc
Compare
I support this! It makes it more consistent with the other SDKs, generates less code, and makes the IDE happier because of no hidden docstrings in aliases. |
AH! An issue I wasn't expecting to encounter - there are deps in our dependency tree (see shykes/daggerverse#10), which have random hashes as their This is fiddly, and not great. For now, we can probably make do by ensuring that our dependencies have good hashes anyways. But long term, we really need to do #7760 - I'm going to add that to our milestone as well. |
27cdab5
to
30d8c81
Compare
3791b42
to
967a3ce
Compare
Tests are failing due to dagger/dagger-test-modules#3. |
Hm, one more test is failing, |
f21cec7
to
3748836
Compare
Signed-off-by: Justin Chadwell <me@jedevc.com>
Signed-off-by: Justin Chadwell <me@jedevc.com>
Signed-off-by: Justin Chadwell <me@jedevc.com>
Signed-off-by: Justin Chadwell <me@jedevc.com>
3748836
to
5fefd47
Compare
I pointed https://github.com/vito/daggerverse` to my fork at https://github.com/jedevc/daggerverse-vito, so I could test with #7831. |
5fefd47
to
3b93a17
Compare
But keep compat with older engine versions. Signed-off-by: Justin Chadwell <me@jedevc.com>
Signed-off-by: Justin Chadwell <me@jedevc.com>
Without this, a `Container` type in a module called `Container` has 2 instances: `dagger.Container` and `Container`. These are unique, and need to be treated as such. This was resulting in a really bizarre error in TestModule/GoExtendCore with the removal of aliases. Not *quite* sure why this only just recently appeared. Signed-off-by: Justin Chadwell <me@jedevc.com>
Signed-off-by: Justin Chadwell <me@jedevc.com>
Signed-off-by: Helder Correia <174525+helderco@users.noreply.github.com>
Signed-off-by: Helder Correia <174525+helderco@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be nice to skip the extra hop for go-to-definition, although I guess for that what I'd really want is some sort of magical go-to-backing-implementation feature (instead of the codegen'd client).
Also, I guess you could .
-import if you preferred the syntax sugar from before?
Anyway, approving, didn't find anything wonky
if basic.Kind() == types.Invalid { | ||
s.Id("any") | ||
break | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This bit seems interesting - is it to prevent codegen from blowing up on an unknown type? Maybe because it gets figured out on another pass?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, that's the behavior in c50cb10
(#7831). It produces invalid code, but the code wouldn't have compiled in the first place - this means dagger develop
can at least succeed, so you can actually fix the issues, instead of having to just "guess".
@@ -385,23 +389,28 @@ package main | |||
|
|||
import ( | |||
"context" | |||
"%[2]s/internal/dagger" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose now if I never run dagger develop
and the generated module code isn't committed, instead of my editor giving me a bunch of errors for undefined types, there will just be this one unknown import, which is better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That too I guess! The main reason for this in here is that if you don't do it, go cleverly attempts to "find it" - and often seems to select dagger.io/dagger
which is reasonably unhelpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that issue still exists but for dag
right? I remember that auto-importing from somewhere. 🤔 Or is that fixed by now too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that issue exists for users if they don't run dagger develop
first - since it's in dagger.gen.go
. Sadly, I don't know about how to fix that one 🤔
* ci: avoid use of dagger package aliases Signed-off-by: Justin Chadwell <me@jedevc.com> * tests: update tests to avoid use of go aliases Signed-off-by: Justin Chadwell <me@jedevc.com> * chore: avoid codegen internal use of aliased types in go codegen Signed-off-by: Justin Chadwell <me@jedevc.com> * fix: go codegen should succeed even with invalid types Signed-off-by: Justin Chadwell <me@jedevc.com> * feat: remove go aliases But keep compat with older engine versions. Signed-off-by: Justin Chadwell <me@jedevc.com> * chore: add changelog Signed-off-by: Justin Chadwell <me@jedevc.com> * fix: go should track fully qualified obj names Without this, a `Container` type in a module called `Container` has 2 instances: `dagger.Container` and `Container`. These are unique, and need to be treated as such. This was resulting in a really bizarre error in TestModule/GoExtendCore with the removal of aliases. Not *quite* sure why this only just recently appeared. Signed-off-by: Justin Chadwell <me@jedevc.com> * chore: bump vito/daggerverse with correct engineVersions Signed-off-by: Justin Chadwell <me@jedevc.com> * Fix typos Signed-off-by: Helder Correia <174525+helderco@users.noreply.github.com> * Update wolfi Signed-off-by: Helder Correia <174525+helderco@users.noreply.github.com> * Update legacy test from latest merged PR Signed-off-by: Helder Correia <174525+helderco@users.noreply.github.com> --------- Signed-off-by: Justin Chadwell <me@jedevc.com> Signed-off-by: Helder Correia <174525+helderco@users.noreply.github.com> Co-authored-by: Helder Correia <174525+helderco@users.noreply.github.com>
Completes the work from #6680 by removing the aliases, which were really tricky to work with from a code completion perspective.
By using #7759, we can avoid breaking the daggerverse, and just apply this for v0.12 and after.
With this change, all dagger types will need to be referenced directly from the
internal/dagger
package. Before:After (see the change from
Container
todagger.Container
):