#Support explicit dependency · Issue 940...

1 messages · Page 1 of 1 (latest)

autumn yoke
#

I would like the command2 to run after command1 only if command1 exit status is 0

package main

import (
    "dagger.io/dagger"
)

dagger.#Plan & {
    client: commands: {
        command1: {
            name: "sh"
            flags: "-c": "docker exec nginx false"
        }
        command2: {
            name: "sh"
            flags: "-c": "docker exec nginx true"
        }
    }
    actions: make: {
        command1: client.commands.command1
        command2: client.commands.command2
    }
}

Current output

dagger do make --log-format plain --log-level debug
11:21PM DEBUG system | acquiring buildkitd lock    lockFilePath=/home/ubuntu/.config/dagger/.buildkitd.lock
11:21PM DEBUG system | acquired buildkitd lock
11:21PM DEBUG system | detected buildkit config    haveHostNetwork=true isActive=true version=v0.10.4
11:21PM DEBUG system | platform detected automatically    platform={amd64 linux  [] }
11:21PM DEBUG system | spawning buildkit job    attrs=null localdirs={}
11:21PM INFO  client.commands.command2 | computing
11:21PM DEBUG client.commands.command2 | running client command    args=-c docker exec nginx true name=sh
11:21PM INFO  client.commands.command1 | computing
11:21PM DEBUG client.commands.command1 | running client command    args=-c docker exec nginx false name=sh
11:21PM ERROR client.commands.command1 | 
11:21PM ERROR client.commands.command1 | failed: exit status 1
    duration=200ms
11:21PM FATAL system | failed to execute plan: task failed: client.commands.command1: exit status 1
#

I'm sorry, I should post that in # help. So many channels that I ignored them.

unborn vine
#

👋 if you make the command's depend on each other, that'll make them execute serially. i.e:

package hello

import (
    "dagger.io/dagger"
)

dagger.#Plan & {
    client: commands: {
        sleep1: {
            name: "sleep"
            args: ["5s"]
        }
        sleep2: {
            name: "sleep"
            args: ["5s"]
            env: {
                "FOO": client.commands.sleep1.stderr
            }

        }
    }
    actions: {
        // Hello world
        hello: {
            client.commands.sleep1
            client.commands.sleep2
        }
    }
}```

LMK if that works!
autumn yoke
#

I think it works, thanks!

package main

import (
    "dagger.io/dagger"
)

dagger.#Plan & {
    client: commands: {
        command1: {
            name: "sh"
            flags: "-c": "docker exec nginx false"
        }
        command2: {
            name: "sh"
            flags: "-c": "docker exec nginx true"
            env: {
                "command2": client.commands.command1.stderr
            }
        }
    }
    actions: make: {
        command1: client.commands.command1
        command2: client.commands.command2
    }
}
bin/dagger do make
[✗] client.commands.command1
5:41PM FATAL failed to execute plan: task failed: client.commands.command1: exit status 1
unborn vine
#

🚀 daggerfire

autumn yoke
#

I think I was too quick to confirm. I see something surprising: command2 is executed even if I only request the command1 subaction.

package hello

import (
    "dagger.io/dagger"
)

dagger.#Plan & {
    client: commands: {
        sleep1: {
            name: "sleep"
            args: ["1s"]
        }
        sleep2: {
            name: "sleep"
            args: ["1s"]
            env: {
                "EXIT": client.commands.sleep1.stderr
            }
        }
    }
    actions: {
        hello: {
            sleep1: client.commands.sleep1
            sleep2: client.commands.sleep2
        }
    }
}
dagger do hello sleep1
[✔] client.commands.sleep1                                       
[✔] actions.hello.sleep1                                         
[✔] client.commands.sleep2                                       
Field   Value
stdout  ""
stderr  ""

The problem goes away if I remove the env block, i.e. I get the following output

dagger do hello sleep1
[✔] client.commands.sleep1                                       
[✔] actions.hello.sleep1                                         
Field   Value
stdout  ""
stderr  ""
unborn vine
clear cliff
#

@autumn yoke Can you create an issue for me?