MCPcopy Index your code
hub / github.com/dagger/dagger / moduleSourceAsModule

Method moduleSourceAsModule

core/schema/modulesource.go:2993–3190  ·  view source on GitHub ↗
(
	ctx context.Context,
	src dagql.ObjectResult[*core.ModuleSource],
	args struct {
		// This internal-only flag allows us to force SDK modules to enable default function
		// caching even when they are on older modules, which ensures they don't see a regression
		// right after function caching is enabled. It can be removed after SDKs have been updated
		// to latest engine versions.
		ForceDefaultFunctionCaching bool `internal:"true" default:"false"`

		// LegacyDefaultPath, when true, causes +defaultPath to resolve relative
		// to the workspace root instead of the module's own source directory.
		// Used for legacy toolchains loaded from dagger.json.
		LegacyDefaultPath bool `internal:"true" default:"false"`

		// LegacyArgCustomizationsJSON is a JSON-encoded []*modules.ModuleConfigArgument
		// carrying arg customizations from the workspace dagger.json.
		// Applied after type defs are populated so constructor arg metadata
		// (Ignore, DefaultPath, etc.) can be overridden before Install.
		LegacyArgCustomizationsJSON string `internal:"true" default:""`

		// LegacyNameOverride, when non-empty, overrides the module name.
		LegacyNameOverride string `internal:"true" default:""`

		// LegacyWorkspaceConfigJSON is a JSON-encoded map[string]any
		// carrying workspace config defaults from the workspace dagger.json.
		LegacyWorkspaceConfigJSON string `internal:"true" default:""`

		// LegacyDefaultsFromDotEnv, when true and workspace config is set,
		// also load .env defaults for args not found in WorkspaceConfig.
		LegacyDefaultsFromDotEnv bool `internal:"true" default:"false"`

		// DefaultPathContextSourceRef, when set, loads implementation code from
		// the receiver but resolves +defaultPath inputs from this source ref.
		DefaultPathContextSourceRef string `internal:"true" default:""`

		// DefaultPathContextSourcePin pins DefaultPathContextSourceRef when set.
		DefaultPathContextSourcePin string `internal:"true" default:""`
	},
)

Source from the content-addressed store, hash-verified

2991 return inst.WithContentDigest(ctx, scopedDigest)
2992}
2993func (s *moduleSourceSchema) moduleSourceAsModule(
2994 ctx context.Context,
2995 src dagql.ObjectResult[*core.ModuleSource],
2996 args struct {
2997 // This internal-only flag allows us to force SDK modules to enable default function
2998 // caching even when they are on older modules, which ensures they don't see a regression
2999 // right after function caching is enabled. It can be removed after SDKs have been updated
3000 // to latest engine versions.
3001 ForceDefaultFunctionCaching bool `internal:"true" default:"false"`
3002
3003 // LegacyDefaultPath, when true, causes +defaultPath to resolve relative
3004 // to the workspace root instead of the module's own source directory.
3005 // Used for legacy toolchains loaded from dagger.json.
3006 LegacyDefaultPath bool `internal:"true" default:"false"`
3007
3008 // LegacyArgCustomizationsJSON is a JSON-encoded []*modules.ModuleConfigArgument
3009 // carrying arg customizations from the workspace dagger.json.
3010 // Applied after type defs are populated so constructor arg metadata
3011 // (Ignore, DefaultPath, etc.) can be overridden before Install.
3012 LegacyArgCustomizationsJSON string `internal:"true" default:""`
3013
3014 // LegacyNameOverride, when non-empty, overrides the module name.
3015 LegacyNameOverride string `internal:"true" default:""`
3016
3017 // LegacyWorkspaceConfigJSON is a JSON-encoded map[string]any
3018 // carrying workspace config defaults from the workspace dagger.json.
3019 LegacyWorkspaceConfigJSON string `internal:"true" default:""`
3020
3021 // LegacyDefaultsFromDotEnv, when true and workspace config is set,
3022 // also load .env defaults for args not found in WorkspaceConfig.
3023 LegacyDefaultsFromDotEnv bool `internal:"true" default:"false"`
3024
3025 // DefaultPathContextSourceRef, when set, loads implementation code from
3026 // the receiver but resolves +defaultPath inputs from this source ref.
3027 DefaultPathContextSourceRef string `internal:"true" default:""`
3028
3029 // DefaultPathContextSourcePin pins DefaultPathContextSourceRef when set.
3030 DefaultPathContextSourcePin string `internal:"true" default:""`
3031 },
3032) (inst dagql.ObjectResult[*core.Module], err error) {
3033 dag, err := core.CurrentDagqlServer(ctx)
3034 if err != nil {
3035 return inst, fmt.Errorf("failed to get dag server: %w", err)
3036 }
3037
3038 if src.Self().ModuleName == "" {
3039 return inst, fmt.Errorf("module name must be set")
3040 }
3041
3042 // Check engine version compatibility
3043 engineVersion := src.Self().EngineVersion
3044 if !engine.CheckVersionCompatibility(engineVersion, engine.MinimumModuleVersion) {
3045 return inst, fmt.Errorf("module requires dagger %s, but support for that version has been removed", engineVersion)
3046 }
3047 if !engine.CheckMaxVersionCompatibility(engineVersion, engine.BaseVersion(engine.Version)) {
3048 return inst, fmt.Errorf("module requires dagger %s, but you have %s", engineVersion, engine.Version)
3049 }
3050

Callers

nothing calls this directly

Calls 15

loadDependencyModulesMethod · 0.95
runModuleDefInSDKMethod · 0.95
CurrentDagqlServerFunction · 0.92
BaseVersionFunction · 0.92
StringTypeAlias · 0.92
NonNullFunction · 0.92
HashStringsFunction · 0.92

Tested by

no test coverage detected