Skip to content

New Linter: discriminatedunions #20

@JoelSpeed

Description

@JoelSpeed

Identify structs marked with +union

  • Should have 1 required field with +uniondiscriminator
  • Other fields should be optional and marked with +unionMember or +unionMember,optional
  • For CRDs, should have a CEL validation rule has(self.<discriminator> && self.<discriminator> == "<member>" ? has(self.member) : !has(self.member) or equivalent if the member is optional
  • Should not have non-member fields present (strong opinion, so, configurable)

Metadata

Metadata

Assignees

Labels

kind/featureCategorizes issue or PR as related to a new feature.lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions