#Check if an entry in the directory is a file or a directory?

1 messages · Page 1 of 1 (latest)

trail gate
#

I have a "root" dagger.Directory and I want to grab all its subdirectories. What are some good/idiomatic ways of approaching that, given that entries will only give me strings ?

shell quarry
# trail gate I have a "root" `dagger.Directory` and I want to grab all its subdirectories. Wh...

The most straightforward way is to run a WithExec with whichever tool you need to filter what you want.

It is possible to extend Entries to add further options to filter and get more information from te output (https://github.com/moby/buildkit/blob/83b43c683efc36847e19cdb3c058c9d24d22e65f/frontend/gateway/pb/gateway.proto#L24) but that will need its own issue and some discussion before that's implemented

GitHub

concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit - moby/buildkit

trail gate
#

Feels a bit wrong to run another container and exec just to determine that. Haven't fully tested this, but is there any downside to assuming an entry is a directory and grabbing it with .Directory() and if that's nil that mus mean we're dealing with a file. Any edge cases there ?