Repository navigation
core: #Mount supports inline file - #2290
Conversation
|
|
I like the convenience of this, but agree that this seems like something we should be able to do in Cue without having to make a separate task for it. We already have a way of turning a string into If there's no way to do that right now then LGTM, I'd rather users have the convenience of this than block it because it feels like there should be a different way. |
sipsma
left a comment
There was a problem hiding this comment.
Some comments on the code if we end up going this route
|
Since the mounts are set in type: "file"
contents: stringBut in Go, it needs to be type: "fs"
contents: dagger.#FSEven doing it in |
I tried a lot of combinaison but it was not possible, as Helder said :
|
Since it uses EDIT: Here's a test verify: core.#ReadFile & {
input: write.output
path: "/test.txt" // Use original file instead of `result.txt`
} & {
contents: "hello world"
}
}
}Result dagger do -p ./mount_file.cue test --log-format plain
1:54PM INF actions.image | computing
1:54PM INF actions.image | completed duration=0s
1:54PM INF actions.test.write | computing
1:54PM INF actions.test.write | completed duration=0s
1:54PM INF actions.test.verify | computing
1:54PM ERR actions.test.verify | failed: ReadFile /test.txt: open /tmp/buildkit-mount2779228987/test.txt: no such file or directory
duration=0s
1:54PM FTL system | failed to execute plan: task failed: actions.test.verify: ReadFile /test.txt: open /tmp/buildkit-mount2779228987/test.txt: no such file or directory |
6a9c376 to
37460d8
Compare
I don't think we need to do it in |
Okay but then how would you do that? Adding a field Tbh, if it requires a new field in I just fear that it become complex for nothing, I'll open a PR tomorrow to mounts file from |
I don't think you'll be able to extend the mount from there. For one, how do you add to the disjunction? Secondly, you still have the same conflict with The only thing I can think of right now would be another field that then passes the correct mount to |
|
This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
37460d8 to
e212686
Compare
e212686 to
9e74e2a
Compare
It was really painful to mount a simple file using `type: fs` because it creates some verbose intermediate step. With this update, it is not possible to directly mount a file as string. Signed-off-by: Vasek - Tom C <[email protected]>
9e74e2a to
209f6d5
Compare
|
I have updated the PR to latest change, what we decide with this one? There is no clean way to add it to |
|
This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
|
I defer to @helderco |
|
I agree that it would be better to abstract this in //
// CORE
//
#Mount: {
dest: string
type: string
#CacheMount | #TmpMount
}
#CacheMount: {
type: "cache"
contents: #CacheDir
}
#TmpMount: {
type: "tmp"
contents: #TempDir
}
#CacheDir: {
id: string
concurrency: *"shared" | "private" | "locked"
}
#TempDir: {
size: int64 | *0
}
#Exec: {
mounts: [string]: #Mount
}
//
// DOCKER
//
#RunMount: {
dest: string
type: string
#CacheMount | #TmpMount | #FileMount
}
#FileMount: {
type: "file"
contents: string
}
#Run: {
mounts: [string]: #RunMount
_fileMounts: {
for mount, cfg in mounts {
if cfg.type == "file" {
(mount): {
dest: cfg.dest
contents: #CacheDir & {
id: "imagine-fs-here--\(cfg.contents)"
}
}
}
}
}
exec: #Exec & {
"mounts": {
for mount, cfg in mounts {
if cfg.type != "file" {
(mount): cfg
}
}
_fileMounts
}
}
}
run: #Run & {
mounts: wat: {
dest: "/file"
contents: "wat"
}
}// OUTPUT
run: {
mounts: {
wat: {
dest: "/file"
contents: "wat"
type: "file"
}
}
exec: {
mounts: {
wat: {
dest: "/file"
contents: {
id: "imagine-fs-here--wat"
concurrency: "shared"
}
type: "cache"
}
}
}
}Granted it's much uglier to resort to these loops and conditions, but has a better separation of concerns. A positive aspect is that the API is the same from But is it worth it? |
I think the best way to make a decision is a benchmark, I'll test both solution and see which is the most effective :D |
helderco
left a comment
There was a problem hiding this comment.
Even though this can be done entirely in CUE in docker.#Run I wonder if the added complexity is worth it for the separation of concerns. API can be the same (implementation detail), except for core.#Exec supporting it as well.
|
@helderco Thanks for your follow up!
Totally agree, IMO it's not worth and can lead to performance issue / misunderstanding from user because API will be much complex. I let you merge this one if you think we should. I will indeed do a follow up PR to implement this new mount where it can be useful. |
This broke github workflows, from dagger#2290. Signed-off-by: Helder Correia <[email protected]>
It was really painful to mount a simple file using
type: fsbecause it creates some verbose intermediate step.With this update, it is not possible to directly mount a file as string.
Signed-off-by: Vasek - Tom C [email protected]