loadContainerFromAddress loads a Container from a given address using the Address API.
(ctx context.Context, dag *dagql.Server, address string)
| 987 | |
| 988 | // loadContainerFromAddress loads a Container from a given address using the Address API. |
| 989 | func 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 | // |
no test coverage detected