vmware-archive / operator-builder

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

fix: overlapping resource names cause duplicate function names #284

Closed scottd018 closed 2 years ago

scottd018 commented 2 years ago

When generating a resource, of the same type, with the same name (presumably using resource markers with different conditions), the function names are generated the same. Take the below for example:

---
# +operator-builder:resource:collectionField=services.secrets,value="none",include
apiVersion: v1
kind: ServiceAccount
metadata:
  name: csi-secrets-store-provider-aws
  namespace: platform #+operator-builder:collection:field:name=namespaces.platform,default="platform",type=string
---
# +operator-builder:resource:collectionField=services.secrets,value="secretsManager",include
apiVersion: v1
kind: ServiceAccount
metadata:
  name: csi-secrets-store-provider-aws
  namespace: platform #+operator-builder:collection:field:name=namespaces.platform,default="platform",type=string
  annotations:
    # +operator-builder:collection:field:name=services.secrets,type=string,default="none",description=`
    # +kubebuilder:validation:Enum:secretsManager;none
    # The provider which supplies secret management capabilities.  The following
    # providers are supported: ["none", "secretsManager"].`
    platform.providers/shared-storage: "secretsManager"

The code is laid down for both of these for both cases (none versus secretsManager). However, the function name to lay down these resources is the same.

We need a way to de-duplicate the CreateFuncNames and InitFuncNames so that we do not have the overlaps when this condition occurs.