You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Move core actions to dagger/core sub-package #1825
All core actions are currently available under dagger.io/dagger. For example dagger.#Exec, dagger.#Pull etc.
From observing new developers, I am noticing that they tend to go to these core actions first. This makes sense because dagger.io/dagger is the primary entrypoint for the Dagger API. However, often these core actions are not what developers should be using: they are relatively low-level, and a higher-level package might be a better fit in most cases.
Example:
Solution
Move core actions to a sub-package which makes their low-level nature more clear. I suggest dagger.io/dagger/core as originally proposed by @gerhard .
Since some developers already rely on the current paths, we can leave some hidden compatibility aliases, but direct all new developers to use the new API.
With dagger.#Dockerfile vs docker.#Dockerfile it makes it harder to know which one to use. By moving to core.#Dockerfile it's a bit more clear that's a bit more lower level.
Since the point is to discourage the use of dagger/core directly, there's a few details worth discussing.
Plan
Currently, actions are matched against a single namespace. The biggest issue are the client actions (to keep dagger.#Plan). There's two options:
Look for actions both in core and dagger packages (/cc @aluzzardi);
Move everything to core and alias in dagger what we want to be "public" use;
We don't have higher level abstractions on top of our secret actions, so this conflicts with the idea to discourage direct usage of core actions.
We could make an exception here for a dagger.io/dagger/secrets package with secrets.#Decode, secrets.#Trim, etc. Or alias in dagger.
Mounts
I don't think it's necessary to scope exec.#Mount (same issue as secrets above) because you don't necessarily need to use it explicitly when setting values for docker.#Run, since it already sets it:
With dagger.#Dockerfile vs docker.#Dockerfile it makes it harder to know which one to use. By moving to core.#Dockerfile it's a bit more clear that's a bit more lower level.
Since the point is to discourage the use of dagger/core directly, there's a few details worth discussing.
Plan
Currently, actions are matched against a single namespace. The biggest issue are the client actions (to keep dagger.#Plan). There's two options:
Look for actions both in core and dagger packages (/cc @aluzzardi);
Move everything to core and alias in dagger what we want to be "public" use;
I like option 1 better.
From a CUE point of view, it's cleaner: core (short for "core actions") is a higher-level package which depends on dagger, but not the other way around. (That's a slight downside of the word "core": it implies that there is nothing below, but in fact "dagger" holds core types that are more "core" than core actions :)
From a Go point of view, I already have implemented support for actions in two packages. The PR containing it was never merged, but the code itself worked just fine. I hope I can retrieve it, it would save you a little bit of time (nothing super hard, just code plumbing).
Aliasing creates new problems that are best avoided.
Secrets
We don't have higher level abstractions on top of our secret actions, so this conflicts with the idea to discourage direct usage of core actions.
We could make an exception here for a dagger.io/dagger/secrets package with secrets.#Decode, secrets.#Trim, etc. Or alias in dagger.
I think it's fine that it stays in core. They are in fact core actions, and I would love for higher-level packages to wrap them, for example a sops package, a yaml package, etc.
Note: separately, I do like the feel of secrets.#Foo instead of core.#FooSecret, that's an argument in favor of dagger.io/dagger/core/secrets (note the /core).
Mounts
Maybe alias them in dagger?
I really think we should avoid aliasing as much as possible, it forces us to be more rigorous - one-off exceptions are a slippery slope.
I know we discussed it already and decided against it, but note that having dagger.io/dagger/core/exec would slightly improve the DX here, because mounts would be scoped to exec and not pollute top-level core.
Activity
shykes commentedon Mar 21, 2022
@helderco does this feel right to you?
helderco commentedon Mar 26, 2022
With
dagger.#Dockerfilevsdocker.#Dockerfileit makes it harder to know which one to use. By moving tocore.#Dockerfileit's a bit more clear that's a bit more lower level.Since the point is to discourage the use of
dagger/coredirectly, there's a few details worth discussing.Plan
Currently, actions are matched against a single namespace. The biggest issue are the client actions (to keep
dagger.#Plan). There's two options:coreanddaggerpackages (/cc @aluzzardi);coreand alias indaggerwhat we want to be "public" use;Option 2 (implemented in #1866)
Secrets
We don't have higher level abstractions on top of our secret actions, so this conflicts with the idea to discourage direct usage of
coreactions.We could make an exception here for a
dagger.io/dagger/secretspackage withsecrets.#Decode,secrets.#Trim, etc. Or alias indagger.Mounts
I don't think it's necessary to scope
exec.#Mount(same issue as secrets above) because you don't necessarily need to use it explicitly when setting values fordocker.#Run, since it already sets it:So:
dagger.#Plan & { - _nodeModulesMount: "/src/node_modules": core.#Mount & { + _nodeModulesMount: "/src/node_modules": { dest: "/src/node_modules" - type: "cache" - contents: core.#CacheDir & { - contents: { id: "todoapp-modules-cache" } }See https://cuelang.org/play/?id=Ju4lItnwo4M#cue@export@cue 👈
Although, putting
#CacheDirand#TempDirincontentsmakes it a bit clearer, especially if we add another type with conflicting fields later on.Maybe alias them in
dagger?shykes commentedon Mar 27, 2022
I like option 1 better.
From a CUE point of view, it's cleaner:
core(short for "core actions") is a higher-level package which depends ondagger, but not the other way around. (That's a slight downside of the word "core": it implies that there is nothing below, but in fact "dagger" holds core types that are more "core" than core actions :)From a Go point of view, I already have implemented support for actions in two packages. The PR containing it was never merged, but the code itself worked just fine. I hope I can retrieve it, it would save you a little bit of time (nothing super hard, just code plumbing).
Aliasing creates new problems that are best avoided.
I think it's fine that it stays in
core. They are in fact core actions, and I would love for higher-level packages to wrap them, for example asopspackage, ayamlpackage, etc.Note: separately, I do like the feel of
secrets.#Fooinstead ofcore.#FooSecret, that's an argument in favor ofdagger.io/dagger/core/secrets(note the/core).I really think we should avoid aliasing as much as possible, it forces us to be more rigorous - one-off exceptions are a slippery slope.
I know we discussed it already and decided against it, but note that having
dagger.io/dagger/core/execwould slightly improve the DX here, because mounts would be scoped toexecand not pollute top-level core.helderco commentedon Mar 28, 2022
Agreed. 🙂
I've implemented option 2, please review #1866.