#chmod on dagger.File downloaded via client.HTTP

1 messages · Page 1 of 1 (latest)

strange adder
#

Hi,

I test out Dagger Go SDK (v0.6.0) to build my pipelines. I am using client.HTTP to download some dependencies, which gives me dagger.File object that I can directly inject inside container (which is great!)

However I also need to add executable bit to the downloaded file. I am looking for os.Chmod on dagger.File struct to change the permissions, but it doesn't look like it's implemented.

Is the correct workaround to download it via client.HTTP, exporting it to Host (via .Export), doing the OS operation and then inject it into container from Host instead of directly referencing File struct?

Thanks for suggestions!

round wyvern
#

👋 you can do it like this:

package main

import (
    "context"
    "os"

    "dagger.io/dagger"
)

func main() {
    ctx := context.Background()

    // create Dagger client
    client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr))
    if err != nil {
        panic(err)
    }
    defer client.Close()

    client.Container().From("ubuntu").
        WithFile("/hello-world.sh", client.HTTP("https://raw.githubusercontent.com/ruanyf/simple-bash-scripts/master/scripts/hello-world.sh"), dagger.ContainerWithFileOpts{
            Permissions: 0o755,
        }).WithExec([]string{"/hello-world.sh"}).ExitCode(ctx)
}
#

^ check out the "Permissions" opts