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

Method ResultCallModule

core/module.go:2151–2197  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

2149}
2150
2151func (mod *userMod) ResultCallModule(ctx context.Context) (*dagql.ResultCallModule, error) {
2152 self := mod.self()
2153 if self == nil {
2154 return nil, fmt.Errorf("module provenance: missing module result wrapper")
2155 }
2156 if !self.Source.Valid {
2157 return nil, fmt.Errorf("module provenance: module %q has no source", self.Name())
2158 }
2159
2160 scoped, err := ImplementationScopedModule(ctx, mod.res)
2161 if err != nil {
2162 return nil, fmt.Errorf("module provenance: implementation-scoped module %q: %w", self.Name(), err)
2163 }
2164 scopedID, err := scoped.ID()
2165 if err != nil {
2166 return nil, fmt.Errorf("module provenance: module %q handle ID: %w", self.Name(), err)
2167 }
2168 if scopedID == nil || scopedID.EngineResultID() == 0 {
2169 return nil, fmt.Errorf("module provenance: implementation-scoped module %q is not attached", self.Name())
2170 }
2171
2172 src := self.Source.Value.Self()
2173 var ref, pin string
2174 switch src.Kind {
2175 case ModuleSourceKindLocal:
2176 ref = filepath.Join(src.Local.ContextDirectoryPath, src.SourceRootSubpath)
2177 case ModuleSourceKindGit:
2178 ref = src.Git.CloneRef
2179 if src.SourceRootSubpath != "" {
2180 ref += "/" + strings.TrimPrefix(src.SourceRootSubpath, "/")
2181 }
2182 if src.Git.Version != "" {
2183 ref += "@" + src.Git.Version
2184 }
2185 pin = src.Git.Commit
2186 case ModuleSourceKindDir:
2187 default:
2188 return nil, fmt.Errorf("module provenance: unexpected module source kind %q", src.Kind)
2189 }
2190
2191 return &dagql.ResultCallModule{
2192 ResultRef: &dagql.ResultCallRef{ResultID: scopedID.EngineResultID()},
2193 Name: self.Name(),
2194 Ref: ref,
2195 Pin: pin,
2196 }, nil
2197}
2198
2199func (mod *userMod) ModuleResult() dagql.ObjectResult[*Module] {
2200 if mod == nil {

Callers

nothing calls this directly

Calls 6

selfMethod · 0.95
NameMethod · 0.95
EngineResultIDMethod · 0.80
SelfMethod · 0.80
IDMethod · 0.65

Tested by

no test coverage detected