vmware-archive / operator-builder

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

refactor: ProcessAPIConfig called twice #262

Closed scottd018 closed 2 years ago

scottd018 commented 2 years ago

The ProcessAPIConfig does a lot of method including parsing and pulling of markers. During a debug sessions, I found that this method is called twice which results in potentially duplication of an intense loop.

  1. https://github.com/vmware-tanzu-labs/operator-builder/blob/main/internal/plugins/config/v1/api.go#L49 : this gets called first
  2. https://github.com/vmware-tanzu-labs/operator-builder/blob/main/internal/plugins/workload/v1/api.go#L60 : this gets called second

I believe we should export the createAPISubcommand type (CreateAPISubcommand) and use it in both of these packages and do everything up front (item 1 above) and remove the extra calls. This would allow us to validate and set the workload only a single time and remove the second loop.