vmware-archive / operator-builder

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

feat: replace text with missing replace results in hard-coded values #298

Open scottd018 opened 2 years ago

scottd018 commented 2 years ago

When using the replace function of a marker, with the missing replace string, the values become hard-coded.

Given the following markers:

    # +operator-builder:field:name=google.region,type=string,replace=GOOGLE_LOCATION,default=us-east1
    # +operator-builder:field:name=clusterName,type=string,replace=GOOGLE_KMS_KEY_RING,default=cluster-key-ring
    # +operator-builder:field:name=clusterName,type=string,replace=GOOGLE_KMS_KEY,default=cluster-key
    # +operator-builder:collection:field:name=google.project,type=string,replace=GOOGLE_PROJECT,default=my-project
    keyName: projects/my-project/locations/us-east1/keyRings/cluster-key-ring/cryptoKeys/cluster-key
    state: ENCRYPTED

Would result in:

    keyName: "projects/my-project/locations/us-east1/keyRings/cluster-key-ring/cryptoKeys/cluster-key",
    state: "ENCRYPTED"

We should error out and let the user know that they have made a mistake with their markers.