MCPcopy Create free account
hub / github.com/dagger/dagger / loadContainerFromAddress

Function loadContainerFromAddress

core/modfunc.go:989–1016  ·  view source on GitHub ↗

loadContainerFromAddress loads a Container from a given address using the Address API.

(ctx context.Context, dag *dagql.Server, address string)

Source from the content-addressed store, hash-verified

987
988// loadContainerFromAddress loads a Container from a given address using the Address API.
989func loadContainerFromAddress(ctx context.Context, dag *dagql.Server, address string) (dagql.IDType, error) {
990 var addr dagql.ObjectResult[*Address]
991 err := dag.Select(ctx, dag.Root(), &addr,
992 dagql.Selector{
993 Field: "address",
994 Args: []dagql.NamedInput{
995 {Name: "value", Value: dagql.String(address)},
996 },
997 },
998 )
999 if err != nil {
1000 return nil, fmt.Errorf("load address %q for container default: %w", address, err)
1001 }
1002
1003 var ctr dagql.ObjectResult[*Container]
1004 err = dag.Select(ctx, addr, &ctr,
1005 dagql.Selector{Field: "container"},
1006 )
1007 if err != nil {
1008 return nil, fmt.Errorf("load container from address %q: %w", address, err)
1009 }
1010
1011 ctrID, err := ctr.ID()
1012 if err != nil {
1013 return nil, fmt.Errorf("get contextual container ID: %w", err)
1014 }
1015 return dagql.NewID[*Container](ctrID), nil
1016}
1017
1018// loadContextualArg loads a contextual argument from the module context directory or address.
1019//

Callers 1

loadContextualArgMethod · 0.85

Calls 4

StringTypeAlias · 0.92
SelectMethod · 0.65
IDMethod · 0.65
RootMethod · 0.45

Tested by

no test coverage detected