jenkinsci / kubernetes-cd-plugin

A Jenkins plugin to deploy to Kubernetes cluster
MIT License
140 stars 72 forks source link

Add support for generateName #74

Open voneiden opened 5 years ago

voneiden commented 5 years ago

Currently https://github.com/jenkinsci/kubernetes-cd-plugin/blob/master/src/main/java/com/microsoft/jenkins/kubernetes/KubernetesClientWrapper.java#L315 will throw an exception if a resource does not have a name.

Kubernetes supports (since when?) a metadata key generateName which indicates that the server will generate a unique name based on the template given:

"Names generated by the system may be requested using metadata.generateName. GenerateName indicates that the name should be made unique by the server prior to persisting it. A non-empty value for the field indicates the name will be made unique (and the name returned to the client will be different than the name passed). The value of this field will be combined with a unique suffix on the server if the Name field has not been provided."

I suppose the plugin should detect the presence of this key and always create instead of apply the resource.