Skip to content
This repository has been archived by the owner on Jun 19, 2022. It is now read-only.

Generate CRD Schemas #920

Closed
Harwayne opened this issue Apr 22, 2020 · 2 comments
Closed

Generate CRD Schemas #920

Harwayne opened this issue Apr 22, 2020 · 2 comments
Labels
area/api APIs kind/feature-request New feature or request lifecycle/stale priority/2 Nice to have feature but doesn't block current release defined by release/*
Milestone

Comments

@Harwayne
Copy link
Contributor

Problem
Most of our CRDs reuse the same underlying structs for common functionality. For example, most sources contain spec.pubSubSpec. However, each CRD's YAML must contain its own OpenAPIV3Schema.

We should have a tool that makes it easy to use a common schema 'snippet' for these shared types.

Persona:
Developer

Exit Criteria

  • A developer can add a field or extra OpenAPI schema validation to an existing field that is used by multiple types without having to manually alter the YAML for every CRD that uses that type.
    • E.g. I add extra schema validation to spec.pubSubSpec.foo. That field is used by a dozen sources. I do not have to update a dozen YAML files. Instead I only need to update one.

Additional context (optional)
This need became apparent while working on #614 and #615. While working on those, I noticed that almost every Source had a slightly different schema for the commonly shared types. Even more fun was that they sometimes were at different levels of nesting, so copy-pasting was difficult and error prone.

@Harwayne Harwayne added the kind/feature-request New feature or request label Apr 22, 2020
@Harwayne
Copy link
Contributor Author

Possible solutions:

  1. kustomize
    • This seems to be the way that K8s is pushing to modify YAMLs before applying them.
    • This directory shows how it can be done for CloudAuditLogsSource.
      • I think it is fairly ugly and probably require code duplication to inject the same schema at distinct levels.
  2. ytt
    • I've seen interest in this from others in Knative, particularly around test and release.
    • I think we can get this to work, but it would require a distinct file for the entire node (e.g. properties.yaml) and annotate all the entries in 'pubsub_spec' with #@overlay/match missing_ok=True.
  3. yq
    • I think I could get yq to work via its create and merge operators.
  4. Custom tool.

@grantr grantr added area/api APIs priority/2 Nice to have feature but doesn't block current release defined by release/* release/2 and removed release/2 labels Apr 28, 2020
@grantr grantr added this to the Backlog milestone Apr 28, 2020
@github-actions
Copy link

This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Reopen the issue with /reopen. Mark the issue as
fresh by adding the comment /remove-lifecycle stale.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/api APIs kind/feature-request New feature or request lifecycle/stale priority/2 Nice to have feature but doesn't block current release defined by release/*
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants