Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cue/load: support specifying that a package value conforms to a schema #2006

Open
myitcv opened this issue Oct 14, 2022 · 1 comment
Open
Labels
cue/load Issues related to cue/load mechanics FeatureRequest New feature or request

Comments

@myitcv
Copy link
Member

myitcv commented Oct 14, 2022

Is your feature request related to a problem? Please describe.

A number of tools that use CUE ask/require their users to provide CUE input. This almost always requires the user to write a concrete configuration that satisfies a schema that is defined by the tool.

For example, a Dagger plan looks like this:

package todoapp

import (
  "dagger.io/dagger"
  "universe.dagger.io/netlify"
)

dagger.#Plan & {
  // ...
  actions: {
    // ...
    deploy: netlify.#Deploy & {
      // ...
    }
  // ...
  }
}

It's also often the case that the user is providing a configuration file/package in a well defined place, after running $tool init or similar. For example, in the root of a CUE module.

When writing the concrete configuration, it's frustrating for every Dagger user to have to import dagger.io/dagger and effectively wrap their configuration with:

dagger.#Plan & {
    // ...
}

For one, this indents the entire configuration, even though the resulting value is embedded to the package value.

Noting that with must() or a similar approach, we would be able to embed a constraint that forces the package value to satisfy the dagger.#Plan definition without opening the definition. But this would still suffer from the same requirement that the user import and embed such a constraint, an unnecessary hurdle which immediately raises the question "why do I have to do this every time?"

Describe the solution you'd like

The ability to specify somewhere within cue.mod that a package within the module satisfies a given schema. For example, in the case above, if we assume the CUE config file was sitting at the root of a CUE module, the configuration would need to map the module root package to be constrained by dagger.io/dagger.#Plan.

It should be possible for tools to declare such configuration, as well as humans.

This should be a native method supported by cue/load, so that all CUE-related tooling understands the constraint.

Describe alternatives you've considered

  • As discussed above. Requiring the user to import and add a constraint in each configuration.
  • Adding custom load logic in each tool. We definitely want to avoid this approach, because it will prevent other CUE tooling from understanding the intent of the configuration author.

Additional context

n/a

@myitcv myitcv added FeatureRequest New feature or request cue/load Issues related to cue/load mechanics labels Oct 14, 2022
@myitcv
Copy link
Member Author

myitcv commented Oct 14, 2022

cc @hugosantos

@myitcv myitcv added zGarden and removed zGarden labels Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cue/load Issues related to cue/load mechanics FeatureRequest New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant