Skip to main content

Dagger NodeJS SDK

api/client.gen.ModuleSource

The source needed to load and run a module, along with any metadata about the source such as versions/urls/etc.

Hierarchy

  • BaseClient

    ModuleSource

Constructors

constructor

new ModuleSource(parent?, _id?, _asString?, _configExists?, _kind?, _moduleName?, _moduleOriginalName?, _resolveContextPathFromCaller?, _sourceRootSubpath?, _sourceSubpath?): ModuleSource

Constructor is used for internal usage only, do not create object from it.

Parameters

NameType
parent?Object
parent.ctxContext
parent.queryTree?QueryTree[]
_id?ModuleSourceID
_asString?string
_configExists?boolean
_kind?ModuleSourceKind
_moduleName?string
_moduleOriginalName?string
_resolveContextPathFromCaller?string
_sourceRootSubpath?string
_sourceSubpath?string

Returns

ModuleSource

Overrides

BaseClient.constructor

Properties

_asString

Private Optional Readonly _asString: string = undefined


_configExists

Private Optional Readonly _configExists: boolean = undefined


_id

Private Optional Readonly _id: ModuleSourceID = undefined


_kind

Private Optional Readonly _kind: ModuleSourceKind = undefined


_moduleName

Private Optional Readonly _moduleName: string = undefined


_moduleOriginalName

Private Optional Readonly _moduleOriginalName: string = undefined


_resolveContextPathFromCaller

Private Optional Readonly _resolveContextPathFromCaller: string = undefined


_sourceRootSubpath

Private Optional Readonly _sourceRootSubpath: string = undefined


_sourceSubpath

Private Optional Readonly _sourceSubpath: string = undefined

Methods

asGitSource

asGitSource(): GitModuleSource

If the source is a of kind git, the git source representation of it.

Returns

GitModuleSource


asLocalSource

asLocalSource(): LocalModuleSource

If the source is of kind local, the local source representation of it.

Returns

LocalModuleSource


asModule

asModule(): Module_

Load the source as a module. If this is a local source, the parent directory must have been provided during module source creation

Returns

Module_


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 load and use the module.

Returns

Directory


dependencies

dependencies(): Promise<ModuleDependency[]>

The dependencies of the module source. Includes dependencies from the configuration and any extras from withDependencies calls.

Returns

Promise<ModuleDependency[]>


directory

directory(path): Directory

The directory containing the module configuration and source code (source code may be in a subdir).

Parameters

NameTypeDescription
pathstringThe path from the source directory to select.

Returns

Directory


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>


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

NameTypeDescription
depModuleSourceThe dependency module source to resolve.

Returns

ModuleSource


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

ModuleSource


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>


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

NameType
arg(param: ModuleSource) => ModuleSource

Returns

ModuleSource


withContextDirectory

withContextDirectory(dir): ModuleSource

Update the module source with a new context directory. Only valid for local sources.

Parameters

NameTypeDescription
dirDirectoryThe directory to set as the context directory.

Returns

ModuleSource


withDependencies

withDependencies(dependencies): ModuleSource

Append the provided dependencies to the module source's dependency list.

Parameters

NameTypeDescription
dependenciesModuleDependency[]The dependencies to append.

Returns

ModuleSource


withName

withName(name): ModuleSource

Update the module source with a new name.

Parameters

NameTypeDescription
namestringThe name to set.

Returns

ModuleSource


withSDK

withSDK(sdk): ModuleSource

Update the module source with a new SDK.

Parameters

NameTypeDescription
sdkstringThe SDK to set.

Returns

ModuleSource


withSourceSubpath

withSourceSubpath(path): ModuleSource

Update the module source with a new source subpath.

Parameters

NameTypeDescription
pathstringThe path to set as the source subpath.

Returns

ModuleSource