Visitar URL original
Collections: custom functions share a namespace with engine operations · Issue #15137 · dagger/dagger · GitHub
Skip to content

Collections: custom functions share a namespace with engine operations #15137

Open

Description

@shykes

Context

A collection is a module type that holds items with unique keys. The engine adds four engine operations to every collection: keys, list, get, and subset. The module author can also add custom functions. For example, VitestTestFiles.test runs the selected test files in one Vitest process.

#14802 made two changes:

  1. It removed batch planning from the engine. Before this change, when you selected several items, dagger check called the custom function of the same name once, instead of the item check once per item. Now dagger check runs each item check. Modules before v1.0.0-beta.22 keep the old behavior.
  2. It removed the batch namespace. Custom functions moved next to the engine operations:
Before                        After
VitestTestFiles               VitestTestFiles
├── keys, list, get, subset   ├── keys, list, get, subset
└── batch                     └── test
    └── test

The first change makes batching a module implementation detail. The second change was not necessary for the first. It only changed the call path from .batch.test(ws) to .test(ws).

Problem

Custom functions and engine operations now share one namespace. This causes three problems:

  • Every collection reserves the names keys, list, get, and subset. A custom function with one of these names stops the module from loading: collection "Foo" function "list" conflicts with a collection operation.
  • Each new engine operation is a breaking change. It stops every module that already has a custom function with that name from loading.
  • Callers of .batch break. For example, the e2e module of dagger/vitest fails with field "batch" not found (feat: replace baseImageAddress with baseImage (Container) vitest#28).

Possible solutions

A. Hide custom functions. Remove custom functions from the API, so that collections expose only engine operations. A module that wants a bulk operation puts it on a regular object, for example a new function VitestProject.runFiles(ws, files).

B. Restore one namespace. Put custom functions back under one field. The field can be batch, or a name that does not refer to batching.

A. Hide B. Namespace
Name conflict Removed Removed
Custom functions in the API Removed Kept, under one field
One-call path subset(...).test(ws) and delta Removed Kept
Breaking change for Modules that expose custom functions Callers of .test(ws)
Legacy batch planning (before v1.0.0-beta.22) Needs internal access to custom functions No change

Acceptance criteria

  • A collection can have a custom function with any name.
  • A new engine operation does not break existing modules.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions