MCPcopy Index your code
hub / github.com/dagger/dagger / DirectoryReadFile

Function DirectoryReadFile

core/modulesource.go:2035–2049  ·  view source on GitHub ↗

DirectoryReadFile reads file contents from a dagql Directory.

(ctx context.Context, dir dagql.ObjectResult[*Directory], path string)

Source from the content-addressed store, hash-verified

2033
2034// DirectoryReadFile reads file contents from a dagql Directory.
2035func DirectoryReadFile(ctx context.Context, dir dagql.ObjectResult[*Directory], path string) ([]byte, error) {
2036 dag, err := CurrentDagqlServer(ctx)
2037 if err != nil {
2038 return nil, err
2039 }
2040 var contents dagql.String
2041 err = dag.Select(ctx, dir, &contents,
2042 dagql.Selector{Field: "file", Args: []dagql.NamedInput{{Name: "path", Value: dagql.String(path)}}},
2043 dagql.Selector{Field: "contents"},
2044 )
2045 if err != nil {
2046 return nil, err
2047 }
2048 return []byte(contents), nil
2049}
2050
2051func (fs ModuleSourceStatFS) Stat(ctx context.Context, path string) (string, *Stat, error) {
2052 if fs.src == nil {

Callers 1

Calls 3

StringTypeAlias · 0.92
CurrentDagqlServerFunction · 0.70
SelectMethod · 0.65

Tested by

no test coverage detected