vmware-archive / operator-builder

A Kubebuilder plugin to accelerate the development of Kubernetes operators
MIT License
41 stars 6 forks source link

feat: validate duplicate kinds within groups #270

Closed scottd018 closed 2 years ago

scottd018 commented 2 years ago

Consider the following workload configs:

mything.yaml:

---
kind: ComponentWorkload
name: my-thing
spec:
  api:
    clusterScoped: false
    domain: my.domain
    group: stuff
    kind: MyThing
    version: v1alpha1
  companionCliSubcmd:
    description: Manage my thing
    name: my-thing
  dependencies: []
  resources:
    - postgres.yaml

mything2.yaml:

---
kind: ComponentWorkload
name: my-thing-2
spec:
  api:
    clusterScoped: false
    domain: my.domain
    group: stuff
    kind: MyThing
    version: v1alpha1
  companionCliSubcmd:
    description: Manage my second thing
    name: my-thing
  dependencies: []
  resources:
    - redis.yaml

Although these were meant to me independent components, operator-builder sees them as the same kind and builds them under the same _types.go file and resources/ directory.

We should validate that there are no duplicate kinds within their individual groups and return and error when we find this problem.