#Host files in shell

1 messages · Page 1 of 1 (latest)

glass bronze
#

That seems to work (when I don't make silly mistakes 😅 )

#

@devout elm Save me from looking, how do I pass a file as a secret in shell?

#

(For this: expected "Secret" ID, got File! ID)

devout elm
#

I haven't used it, but I guess host | set-secret-file maybe?

glass bronze
#

file:// won't work here right

#

Ok so set-secret-file works, there's just a bit deprecation warning in the docs

bold vine
#

I believe another option is to use a default argument for the path. I'm new to dagger, and so I was also surprised it wasn't possible to do something more like what you tried to do.

e.g I have this function, which reads a file "bboxes.csv" from disk.

// Extracts bounding box for a given area from bboxes.csv
func (m *Headway) BBox(ctx context.Context,
    // Area name to look up (must exist in bboxes.csv)
    area string,
        //  !!!!!! NOTE: defaultPath !!!!!
    // +defaultPath="./services/gtfs/bboxes.csv"
    bboxesFile *dagger.File) (Bbox, error) {

    container := dag.Container().
        From("debian:bookworm-slim").
        WithMountedFile("/bboxes.csv", bboxesFile).
        WithExec([]string{"sh", "-c", fmt.Sprintf("test $(grep '%s:' /bboxes.csv | wc -l) -eq 1", area)}).
        WithExec([]string{"sh", "-c", fmt.Sprintf("grep '%s:' /bboxes.csv | cut -d':' -f2", area)})

    bboxStr, err := container.Stdout(ctx)
    if err != nil {
        return Bbox{}, fmt.Errorf("failed to get bbox for area %s: %w", area, err)
    }
    return Bbox{Value: bboxStr}, nil
}
glass bronze
#

I wonder if defaultPath expands ~ properly