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

Method loadModuleSourceConfig

core/schema/modulesource.go:2208–2361  ·  view source on GitHub ↗
(
	src *core.ModuleSource,
)

Source from the content-addressed store, hash-verified

2206}
2207
2208func (s *moduleSourceSchema) loadModuleSourceConfig(
2209 src *core.ModuleSource,
2210) (*modules.ModuleConfigWithUserFields, error) {
2211 // construct the module config based on any config read during load and any settings changed via with* APIs
2212 modCfg := &modules.ModuleConfigWithUserFields{
2213 ModuleConfigUserFields: src.ModuleConfigUserFields,
2214 ModuleConfig: modules.ModuleConfig{
2215 Name: src.ModuleOriginalName,
2216 EngineVersion: src.EngineVersion,
2217 Include: src.IncludePaths,
2218 Codegen: src.CodegenConfig,
2219 Clients: src.ConfigClients,
2220 },
2221 }
2222
2223 if src.DisableDefaultFunctionCaching {
2224 modCfg.DisableDefaultFunctionCaching = ptr(true)
2225 }
2226
2227 if src.SDK != nil {
2228 modCfg.SDK = &modules.SDK{
2229 Source: src.SDK.Source,
2230 Debug: src.SDK.Debug,
2231 Config: src.SDK.Config,
2232 Experimental: src.SDK.Experimental,
2233 }
2234 }
2235
2236 if src.ConfigBlueprint != nil {
2237 modCfg.Blueprint = src.ConfigBlueprint
2238 }
2239 modCfg.Toolchains = src.ConfigToolchains
2240
2241 // Check version compatibility.
2242 if !engine.CheckVersionCompatibility(modCfg.EngineVersion, engine.MinimumModuleVersion) {
2243 return nil, fmt.Errorf("module requires dagger %s, but support for that version has been removed", modCfg.EngineVersion)
2244 }
2245 if !engine.CheckMaxVersionCompatibility(modCfg.EngineVersion, engine.BaseVersion(engine.Version)) {
2246 return nil, fmt.Errorf("module requires dagger %s, but you have %s", modCfg.EngineVersion, engine.Version)
2247 }
2248
2249 // Load the module config source based on sourcePath.
2250 switch src.SourceSubpath {
2251 case "":
2252 // leave unset
2253 default:
2254 var err error
2255 modCfg.Source, err = pathutil.LexicalRelativePath(
2256 filepath.Join("/", src.SourceRootSubpath),
2257 filepath.Join("/", src.SourceSubpath),
2258 )
2259 if err != nil {
2260 return nil, fmt.Errorf("failed to get relative path from source root to source: %w", err)
2261 }
2262 // if source is ".", leave it unset in dagger.json as that's the default
2263 if modCfg.Source == "." {
2264 modCfg.Source = ""
2265 }

Callers 3

runGeneratedContextMethod · 0.95

Calls 8

BaseVersionFunction · 0.92
LexicalRelativePathFunction · 0.92
SelfMethod · 0.80
HumanStringMethod · 0.80
ptrFunction · 0.70
AsStringMethod · 0.45

Tested by

no test coverage detected