Skip to main content

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?, _cloneRef?, _commit?, _configExists?, _digest?, _engineVersion?, _htmlRepoURL?, _htmlURL?, _kind?, _localContextDirectoryPath?, _moduleName?, _moduleOriginalName?, _pin?, _repoRootPath?, _sourceRootSubpath?, _sourceSubpath?, _sync?, _version?): ModuleSource

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

Parameters

ctx?

Context

_id?

ModuleSourceID

_asString?

string

_cloneRef?

string

_commit?

string

_configExists?

boolean

_digest?

string

_engineVersion?

string

_htmlRepoURL?

string

_htmlURL?

string

_kind?

ModuleSourceKind

_localContextDirectoryPath?

string

_moduleName?

string

_moduleOriginalName?

string

_pin?

string

_repoRootPath?

string

_sourceRootSubpath?

string

_sourceSubpath?

string

_sync?

ModuleSourceID

_version?

string

Returns

ModuleSource

Overrides

BaseClient.constructor

Methods

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>


cloneRef()

cloneRef(): Promise<string>

The ref to clone the root of the git repo from. Only valid for git sources.

Returns

Promise<string>


commit()

commit(): Promise<string>

The resolved commit of the git repo this source points to. Only valid for git sources.

Returns

Promise<string>


configExists()

configExists(): Promise<boolean>

Whether an existing dagger.json for the module was found.

Returns

Promise<boolean>


contextDirectory()

contextDirectory(): Directory

The full directory loaded for the module source, including the source code as a subdirectory.

Returns

Directory


dependencies()

dependencies(): Promise<ModuleSource[]>

The dependencies of the module source.

Returns

Promise<ModuleSource[]>


digest()

digest(): Promise<string>

A content-hash of the module source. Module sources with the same digest will output the same generated context and convert into the same module instance.

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

A subpath from the source directory to select.

Returns

Directory


engineVersion()

engineVersion(): Promise<string>

The engine version of the module.

Returns

Promise<string>


generatedContextDirectory()

generatedContextDirectory(): Directory

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

Returns

Directory


htmlRepoURL()

htmlRepoURL(): Promise<string>

The URL to access the web view of the repository (e.g., GitHub, GitLab, Bitbucket). Only valid for git sources.

Returns

Promise<string>


htmlURL()

htmlURL(): Promise<string>

The URL to the source's git repo in a web browser. Only valid for git sources.

Returns

Promise<string>


id()

id(): Promise<ModuleSourceID>

A unique identifier for this ModuleSource.

Returns

Promise<ModuleSourceID>


kind()

kind(): Promise<ModuleSourceKind>

The kind of module source (currently local, git or dir).

Returns

Promise<ModuleSourceKind>


localContextDirectoryPath()

localContextDirectoryPath(): Promise<string>

The full absolute path to the context directory on the caller's host filesystem that this module source is loaded from. Only valid for local module sources.

Returns

Promise<string>


moduleName()

moduleName(): Promise<string>

The name of the module, including any setting via the withName API.

Returns

Promise<string>


moduleOriginalName()

moduleOriginalName(): Promise<string>

The original name of the module as read from the module's dagger.json (or set for the first time with the withName API).

Returns

Promise<string>


pin()

pin(): Promise<string>

The pinned version of this module source.

Returns

Promise<string>


repoRootPath()

repoRootPath(): Promise<string>

The import path corresponding to the root of the git repo this source points to. Only valid for git sources.

Returns

Promise<string>


sdk()

sdk(): SDKConfig

The SDK configuration of the module.

Returns

SDKConfig


sourceRootSubpath()

sourceRootSubpath(): Promise<string>

The path, relative to the context directory, that contains the module's dagger.json.

Returns

Promise<string>


sourceSubpath()

sourceSubpath(): Promise<string>

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

Returns

Promise<string>


sync()

sync(): Promise<ModuleSource>

Forces evaluation of the module source, including any loading into the engine and associated validation.

Returns

Promise<ModuleSource>


version()

version(): Promise<string>

The specified version of the git repo this source points to. Only valid for git sources.

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

arg

(param) => ModuleSource

Returns

ModuleSource


withDependencies()

withDependencies(dependencies): ModuleSource

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

Parameters

dependencies

ModuleSource[]

The dependencies to append.

Returns

ModuleSource


withEngineVersion()

withEngineVersion(version): ModuleSource

Upgrade the engine version of the module to the given value.

Parameters

version

string

The engine version to upgrade to.

Returns

ModuleSource


withIncludes()

withIncludes(patterns): ModuleSource

Update the module source with additional include patterns for files+directories from its context that are required for building it

Parameters

patterns

string[]

The new additional include patterns.

Returns

ModuleSource


withName()

withName(name): ModuleSource

Update the module source with a new name.

Parameters

name

string

The name to set.

Returns

ModuleSource


withoutDependencies()

withoutDependencies(dependencies): ModuleSource

Remove the provided dependencies from the module source's dependency list.

Parameters

dependencies

string[]

The dependencies to remove.

Returns

ModuleSource


withSDK()

withSDK(source): ModuleSource

Update the module source with a new SDK.

Parameters

source

string

The SDK source to set.

Returns

ModuleSource


withSourceSubpath()

withSourceSubpath(path): ModuleSource

Update the module source with a new source subpath.

Parameters

path

string

The path to set as the source subpath. Must be relative to the module source's source root directory.

Returns

ModuleSource


withUpdateDependencies()

withUpdateDependencies(dependencies): ModuleSource

Update one or more module dependencies.

Parameters

dependencies

string[]

The dependencies to update.

Returns

ModuleSource