Class: ModuleSource
The source needed to load and run a module, along with any metadata about the source such as versions/urls/etc.
Extends
BaseClient
Constructors
new ModuleSource()
new ModuleSource(
ctx
?,_id
?,_asString
?,_configExists
?,_digest
?,_kind
?,_moduleName
?,_moduleOriginalName
?,_pin
?,_resolveContextPathFromCaller
?,_sourceRootSubpath
?,_sourceSubpath
?):ModuleSource
Constructor is used for internal usage only, do not create object from it.
Parameters
ctx?
Context
_id?
_asString?
string
_configExists?
boolean
_digest?
string
_kind?
_moduleName?
string
_moduleOriginalName?
string
_pin?
string
_resolveContextPathFromCaller?
string
_sourceRootSubpath?
string
_sourceSubpath?
string
Returns
Overrides
BaseClient.constructor
Methods
asGitSource()
asGitSource():
GitModuleSource
If the source is a of kind git, the git source representation of it.
Returns
asLocalSource()
asLocalSource():
LocalModuleSource
If the source is of kind local, the local source representation of it.
Returns
asModule()
asModule(
opts
?):Module_
Load the source as a module. If this is a local source, the parent directory must have been provided during module source creation
Parameters
opts?
Returns
asString()
asString():
Promise
<string
>
A human readable ref string representation of this module source.
Returns
Promise
<string
>
configExists()
configExists():
Promise
<boolean
>
Returns whether the module source has a configuration file.
Returns
Promise
<boolean
>
contextDirectory()
contextDirectory():
Directory
The directory containing everything needed to load and use the module.
Returns
dependencies()
dependencies():
Promise
<ModuleDependency
[]>
The effective module source dependencies from the configuration, and calls to withDependencies and withoutDependencies.
Returns
Promise
<ModuleDependency
[]>
digest()
digest():
Promise
<string
>
Return the module source's content 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.
Returns
Promise
<string
>
directory()
directory(
path
):Directory
The directory containing the module configuration and source code (source code may be in a subdir).
Parameters
path
string
The path from the source directory to select.
Returns
id()
id():
Promise
<ModuleSourceID
>
A unique identifier for this ModuleSource.
Returns
Promise
<ModuleSourceID
>
kind()
kind():
Promise
<ModuleSourceKind
>
The kind of source (e.g. local, git, etc.)
Returns
Promise
<ModuleSourceKind
>
moduleName()
moduleName():
Promise
<string
>
If set, the name of the module this source references, including any overrides at runtime by callers.
Returns
Promise
<string
>
moduleOriginalName()
moduleOriginalName():
Promise
<string
>
The original name of the module this source references, as defined in the module configuration.
Returns
Promise
<string
>
pin()
pin():
Promise
<string
>
The pinned version of this module source.
Returns
Promise
<string
>
resolveContextPathFromCaller()
resolveContextPathFromCaller():
Promise
<string
>
The path to the module source's context directory on the caller's filesystem. Only valid for local sources.
Returns
Promise
<string
>
resolveDependency()
resolveDependency(
dep
):ModuleSource
Resolve the provided module source arg as a dependency relative to this module source.
Parameters
dep
The dependency module source to resolve.
Returns
resolveDirectoryFromCaller()
resolveDirectoryFromCaller(
path
,opts
?):Directory
Load a directory from the caller optionally with a given view applied.
Parameters
path
string
The path on the caller's filesystem to load.
opts?
ModuleSourceResolveDirectoryFromCallerOpts
Returns
resolveFromCaller()
resolveFromCaller():
ModuleSource
Load the source from its path on the caller's filesystem, including only needed+configured files and directories. Only valid for local sources.
Returns
sourceRootSubpath()
sourceRootSubpath():
Promise
<string
>
The path relative to context of the root of the module source, which contains dagger.json. It also contains the module implementation source code, but that may or may not being a subdir of this root.
Returns
Promise
<string
>
sourceSubpath()
sourceSubpath():
Promise
<string
>
The path relative to context of the module implementation source code.
Returns
Promise
<string
>
view()
view(
name
):ModuleSourceView
Retrieve a named view defined for this module source.
Parameters
name
string
The name of the view to retrieve.
Returns
views()
views():
Promise
<ModuleSourceView
[]>
The named views defined for this module source, which are sets of directory filters that can be applied to directory arguments provided to functions.
Returns
Promise
<ModuleSourceView
[]>
with()
with(
arg
):ModuleSource
Call the provided function with current ModuleSource.
This is useful for reusability and readability by not breaking the calling chain.
Parameters
arg
(param
) => ModuleSource
Returns
withContextDirectory()
withContextDirectory(
dir
):ModuleSource
Update the module source with a new context directory. Only valid for local sources.
Parameters
dir
The directory to set as the context directory.
Returns
withDependencies()
withDependencies(
dependencies
):ModuleSource
Append the provided dependencies to the module source's dependency list.
Parameters
dependencies
The dependencies to append.
Returns
withInit()
withInit(
opts
?):ModuleSource
Sets module init arguments
Parameters
opts?
Returns
withName()
withName(
name
):ModuleSource
Update the module source with a new name.
Parameters
name
string
The name to set.
Returns
withoutDependencies()
withoutDependencies(
dependencies
):ModuleSource
Remove the provided dependencies from the module source's dependency list.
Parameters
dependencies
string
[]
The dependencies to remove.
Returns
withSDK()
withSDK(
sdk
):ModuleSource
Update the module source with a new SDK.
Parameters
sdk
string
The SDK to set.
Returns
withSourceSubpath()
withSourceSubpath(
path
):ModuleSource
Update the module source with a new source subpath.
Parameters
path
string
The path to set as the source subpath.
Returns
withView()
withView(
name
,patterns
):ModuleSource
Update the module source with a new named view.
Parameters
name
string
The name of the view to set.
patterns
string
[]
The patterns to set as the view filters.