Skip to main content
Version: 1.0-beta

CurrentModule

The CurrentModule type provides capabilities to introspect the Dagger Function's module and interface between the current execution environment and the Dagger API.

API reference​

Reflective module API provided to functions at runtime.

Implements Node

id
A unique identifier for this CurrentModule.
name
The name of the module being executed in
sourceSubpath
The path to the directory containing the module's source code, relative to the context directory.
contextDirectory
The module's context directory loaded into the engine (plus any generated code that may have been created).
dependencies
The dependencies of the module.
generatedContextDirectory
The generated files and directories made on top of the module source's context directory.
gitRef
The Git ref of the module's source: the resolved commit of a Git source, or the HEAD of the repository that contains a local source. Null for a Directory source, or a local source outside a Git repository.
naming
The names the engine gives this module's own declarations: the same as its source's ModuleSource.naming, for module runtimes, which have no ModuleSource.
source
The directory containing the module's source code loaded into the engine (plus any generated code that may have been created).
workdir
Load a directory from the module's scratch working directory, including any changes that may have been made to it during module function execution.
workdirFile
Load a file from the module's scratch working directory, including any changes that may have been made to it during module function execution.Load a file from the module's scratch working directory, including any changes that may have been made to it during module function execution.

id: ID!

A unique identifier for this CurrentModule.

name: String!

The name of the module being executed in

sourceSubpath: String!

The path to the directory containing the module's source code, relative to the context directory.

contextDirectory: Directory!

The module's context directory loaded into the engine (plus any generated code that may have been created).

It holds the module's source code and every other file the engine loaded for the module, at their paths relative to the context root. Use sourceSubpath to locate the source code in it.

dependencies: [Module!]!

The dependencies of the module.

generatedContextDirectory: Directory!

The generated files and directories made on top of the module source's context directory.

gitRef: GitRef

The Git ref of the module's source: the resolved commit of a Git source, or the HEAD of the repository that contains a local source. Null for a Directory source, or a local source outside a Git repository.

Its asRepository pins HEAD to that commit. For a local source, the repository holds the whole checkout, including files the module does not load, so asRepository.uncommitted lists the uncommitted changes of the whole checkout.

For a Git source loaded from a private remote, asRepository and tree are read without the credentials of the client that loaded the module and may fail to authenticate; commitSha needs none.

A local repository is read when this field is first selected for a module load, not when the module loads: a file changed in between can differ from the module's contextDirectory.

A function result cached across sessions is not recomputed when the repository changes: use the PER_SESSION or NEVER cache policy for a function that returns what it reads from this field.

naming: ModuleNaming!Experimental

The names the engine gives this module's own declarations: the same as its source's ModuleSource.naming, for module runtimes, which have no ModuleSource.

It answers for the module under its own name (ModuleSource.moduleName), by the naming rules of the version the module is named by. A workspace or toolchain that loads the module under another name namespaces its types under that name instead, which this doesn't reflect.

Experimental: Identifier casing APIs are likely to change.

source: Directory!

The directory containing the module's source code loaded into the engine (plus any generated code that may have been created).

workdir(path: String!,exclude: [String!] = [],include: [String!] = [],gitignore: Boolean = false): Directory!

Load a directory from the module's scratch working directory, including any changes that may have been made to it during module function execution.

path: String!

Location of the directory to access (e.g., ".").

exclude: [String!] = []

Exclude artifacts that match the given pattern (e.g., ["node_modules/", ".git*"]).

include: [String!] = []

Include only artifacts that match the given pattern (e.g., ["app/", "package.*"]).

gitignore: Boolean = false

Apply .gitignore filter rules inside the directory

workdirFile(path: String!): File!

Load a file from the module's scratch working directory, including any changes that may have been made to it during module function execution.Load a file from the module's scratch working directory, including any changes that may have been made to it during module function execution.

path: String!

Location of the file to retrieve (e.g., "README.md").

References

Returned by