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

Method moduleSourceUpdateItems

core/schema/modulesource.go:1630–1779  ·  view source on GitHub ↗

moduleSourceUpdateItems processes update requests for items (dependencies or toolchains).

(
	ctx context.Context,
	parentSrc dagql.ObjectResult[*core.ModuleSource],
	updateArgs []string,
	accessor moduleRelationTypeAccessor,
)

Source from the content-addressed store, hash-verified

1628// moduleSourceUpdateItems processes update requests for items (dependencies or
1629// toolchains).
1630func (s *moduleSourceSchema) moduleSourceUpdateItems(
1631 ctx context.Context,
1632 parentSrc dagql.ObjectResult[*core.ModuleSource],
1633 updateArgs []string,
1634 accessor moduleRelationTypeAccessor,
1635) ([]core.ModuleSourceID, error) {
1636 dag, err := core.CurrentDagqlServer(ctx)
1637 if err != nil {
1638 return nil, fmt.Errorf("failed to get dag server: %w", err)
1639 }
1640
1641 type updateReq struct {
1642 symbolic string
1643 version string
1644 }
1645 updateReqs := make(map[updateReq]struct{}, len(updateArgs))
1646 for _, updateArg := range updateArgs {
1647 req := updateReq{}
1648 req.symbolic, req.version, _ = strings.Cut(updateArg, "@")
1649 updateReqs[req] = struct{}{}
1650 }
1651
1652 var newUpdatedArgs []core.ModuleSourceID
1653 for _, existingItem := range accessor.getItems(parentSrc.Self()) {
1654 if len(updateReqs) == 0 {
1655 if existingItem.Self().Kind == core.ModuleSourceKindLocal {
1656 continue
1657 }
1658
1659 var updatedItem dagql.ObjectResult[*core.ModuleSource]
1660 err := dag.Select(ctx, dag.Root(), &updatedItem,
1661 dagql.Selector{
1662 Field: "moduleSource",
1663 Args: []dagql.NamedInput{
1664 {Name: "refString", Value: dagql.String(existingItem.Self().AsString())},
1665 },
1666 },
1667 )
1668 if err != nil {
1669 return nil, fmt.Errorf("failed to load existing %s: %w", accessor.typ, err)
1670 }
1671
1672 updatedItemID, err := updatedItem.ID()
1673 if err != nil {
1674 return nil, fmt.Errorf("failed to get updated %s ID: %w", accessor.typ, err)
1675 }
1676 newUpdatedArgs = append(newUpdatedArgs, dagql.NewID[*core.ModuleSource](updatedItemID))
1677 continue
1678 }
1679
1680 if existingItem.Self().Kind == core.ModuleSourceKindLocal {
1681 for updateReq := range updateReqs {
1682 if updateReq.symbolic == existingItem.Self().ModuleName {
1683 return nil, fmt.Errorf("updating local %s is not supported", accessor.typ.Plural())
1684 }
1685
1686 var contextRoot string
1687 switch parentSrc.Self().Kind {

Calls 10

CurrentDagqlServerFunction · 0.92
StringTypeAlias · 0.92
LexicalRelativePathFunction · 0.92
getItemsMethod · 0.80
SelfMethod · 0.80
PluralMethod · 0.80
SelectMethod · 0.65
IDMethod · 0.65
RootMethod · 0.45
AsStringMethod · 0.45

Tested by

no test coverage detected