Skip to main content

TypeScript SDK Reference

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?, _digest?, _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
_digest?string
_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


_digest

Private Optional Readonly _digest: string = 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(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

NameType
opts?ModuleSourceAsModuleOpts

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[]>


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

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


resolveDirectoryFromCaller

resolveDirectoryFromCaller(path, opts?): Directory

Load a directory from the caller optionally with a given view applied.

Parameters

NameTypeDescription
pathstringThe path on the caller's filesystem to load.
opts?ModuleSourceResolveDirectoryFromCallerOpts-

Returns

Directory


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>


view

view(name): ModuleSourceView

Retrieve a named view defined for this module source.

Parameters

NameTypeDescription
namestringThe name of the view to retrieve.

Returns

ModuleSourceView


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

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


withInit

withInit(opts?): ModuleSource

Sets module init arguments

Parameters

NameType
opts?ModuleSourceWithInitOpts

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


withView

withView(name, patterns): ModuleSource

Update the module source with a new named view.

Parameters

NameTypeDescription
namestringThe name of the view to set.
patternsstring[]The patterns to set as the view filters.

Returns

ModuleSource