File
The File type represents a single file.
API reference
A file.
Implements Exportable, Node, Syncer
contents- Retrieves the contents of the file.
digest- Return the file's digest. The format of the digest is not guaranteed to be stable between releases of Dagger. It is guaranteed to be stable between invocations of the same Dagger engine.
export- Writes the file to a file path on the host.
id- A unique identifier for this File.
name- Retrieves the name of the file.
size- Retrieves the size of the file, in bytes.
asEnvFile- Parse as an env file
asJSON- Parse the file contents as JSON.
chown- Change the owner of the file recursively.
search- Searches for content matching the given regular expression or literal string.
stat- Return file status
sync- Force evaluation in the engine.
withName- Retrieves this file with its name set to the given name.
withReplaced- Retrieves the file with content replaced with the given text.
withTimestamps- Retrieves this file with its created/modified timestamps set to the given time.
contents(offsetLines: Int, limitLines: Int): String!
Retrieves the contents of the file.
offsetLines: IntStart reading after this line
limitLines: IntMaximum number of lines to read
digest(excludeMetadata: Boolean = false): String!
Return the file's digest. The format of the digest is not guaranteed to be stable between releases of Dagger. It is guaranteed to be stable between invocations of the same Dagger engine.
excludeMetadata: Boolean = falseIf true, exclude metadata from the digest.
export(path: String!, allowParentDirPath: Boolean = false): String!
Writes the file to a file path on the host.
path: String!Location of the written directory (e.g., "output.txt").
allowParentDirPath: Boolean = falseIf allowParentDirPath is true, the path argument can be a directory path, in which case the file will be created in that directory.
id: ID!
A unique identifier for this File.
name: String!
Retrieves the name of the file.
size: Int!
Retrieves the size of the file, in bytes.
asEnvFile(expand: Boolean): EnvFile!
Parse as an env file
expand: BooleanReplace "${VAR}" or "$VAR" with the value of other vars
chown(owner: String!): File!
Change the owner of the file recursively.
owner: String!A user:group to set for the file.
The user and group can either be an ID (1000:1000) or a name (foo:bar).
If the group is omitted, it defaults to the same as the user.
search(pattern: String!,literal: Boolean = false,multiline: Boolean = false,dotall: Boolean = false,insensitive: Boolean = false,skipIgnored: Boolean = false,skipHidden: Boolean = false,filesOnly: Boolean = false,limit: Int,paths: [String!] = [],globs: [String!] = []): [SearchResult!]!
Searches for content matching the given regular expression or literal string.
Uses Rust regex syntax; escape literal ., [, ], {, }, | with backslashes.
pattern: String!The text to match.
literal: Boolean = falseInterpret the pattern as a literal string instead of a regular expression.
multiline: Boolean = falseEnable searching across multiple lines.
dotall: Boolean = falseAllow the . pattern to match newlines in multiline mode.
insensitive: Boolean = falseEnable case-insensitive matching.
skipIgnored: Boolean = falseHonor .gitignore, .ignore, and .rgignore files.
skipHidden: Boolean = falseSkip hidden files (files starting with .).
filesOnly: Boolean = falseOnly return matching files, not lines and content
limit: IntLimit the number of results to return
paths: [String!] = []globs: [String!] = []
withName(name: String!): File!
Retrieves this file with its name set to the given name.
name: String!Name to set file to.
withReplaced(search: String!,replacement: String!,all: Boolean = false,firstFrom: Int): File!
Retrieves the file with content replaced with the given text.
If 'all' is true, all occurrences of the pattern will be replaced.
If 'firstAfter' is specified, only the first match starting at the specified line will be replaced.
If neither are specified, and there are multiple matches for the pattern, this will error.
If there are no matches for the pattern, this will error.
search: String!The text to match.
replacement: String!The text to match.
all: Boolean = falseReplace all occurrences of the pattern.
firstFrom: IntReplace the first match starting from the specified line.
withTimestamps(timestamp: Int!): File!
Retrieves this file with its created/modified timestamps set to the given time.
timestamp: Int!Timestamp to set dir/files in.
Formatted in seconds following Unix epoch (e.g., 1672531199).
References
Returned by
Address.fileBinding.asFileChangeset.asPatchCheckGroup.reportContainer.asTarballContainer.fileCurrentModule.workdirFileDirectory.fileEnvFile.asFileHost.fileModule.introspectionSchemaJSONModuleSource.introspectionSchemaJSONQuery.fileQuery.httpWorkspace.file