Open wingyplus opened 4 weeks ago
This is a regression. As you can see, there's a "List of containers" example in:
It may have broken in the following PR, since there's an implicit sync
that only happens in Container
objects:
You can see there's test coverage for []*dagger.File
, but not for []*dagger.Container
, that's why it wasn't caught:
I'll investigate, thanks for reporting!
The problem is that on a single Container
, the CLI produces these queries:
query {
test {
sync
}
}
query {
loadContainerFromID(id: "xxx") {
defaultArgs
mounts
user
workdir
entrypoint
platform
}
}
The same happens only for Terminal
, btw. The end result is that you get an evaluated Container
before printing those values to the screen. The sync is there because by removing stdout
and stderr
, it would just show the metadata without evaluating the pipeline. The Directory
and File
objects don't have the same problem.
If it's a list of Container
objects, the following will instead return multiple values:
query {
test {
sync
}
}
Since the request with sync
expects a single string
here:
It's now getting a []string
when parsing the response from multiple Container
objects (even though there's no difference in the request, only in the response), which explains this error message:
json: cannot unmarshal array into Go value of type string
There's three possible solutions here:
sync
when it's a list of objects, i.e., just print the metadata, without evaluating.
sync
.
query {
cont1: loadContainerFromID(id: "xxx") {
defaultArgs
mounts
user
workdir
entrypoint
platform
}
cont2: loadContainerFromID(id: "yyy") {
defaultArgs
mounts
user
workdir
entrypoint
platform
}
cont3: loadContainerFromID(id: "zzz") {
defaultArgs
mounts
user
workdir
entrypoint
platform
}
}
Container
, and append the results afterwards.The 2nd option is more performant but I'm leaning on the 3rd option because I think it's easier to adapt to while the performance penalty should be negligible.
Of course we could also just return an error but I don't think that's necessary.
Do we need to keep the list ordered? I'm not sure if the option 3 can cause the list shuffle because concurrent processing.
It's not a problem because we can ensure the index in the list is preserved, based on the indices from the list of IDs after { containers { sync } }
.
What is the issue?
From this snippet:
When calling
dagger call containers
, the cli raise an error:Expected that it will return a list of container information or more descriptive error if it's not supported.
Dagger version
dagger v0.12.5 (registry.dagger.io/engine:v0.12.5) darwin/arm64
Steps to reproduce
No response
Log output
No response