k3d
k3d copied to clipboard
[FEATURE] Allow changing the cluster name using environment variables
What
Adds new functionality to check for env variable for cluster name. The variable is named K3D_CLUSTER_NAME
Why
Closes https://github.com/k3d-io/k3d/issues/1281
Implications
The PR changes the default behavior of cluster commands including create, delete, start, stop. After this change, k3d will first look for env variable named K3D_CLUSTER_NAME and create cluster with the value provided by the variable. It should be noted that env variable has less preference than config file, so it only acts when neither of the config file or the command line provides cluster name
@iwilltry42 need your insight on following it can be seen that we are setting ppViper in clusterCreate.go and to follow current pattern, ive created separate Viper config variable in every cluterCreate, clusterDelete, clusterStart and clusterStop command files. I think we can merge all ppViper variable into single variable
Hey @tesla59, thanks for putting up this PR!
I feel like that may be a little over-engineered though :thinking:
Why not just use k3d cluster create $CLUSTER_NAME
right away or use $CLUSTER_NAME
inside the config file?
Hi @iwilltry42 . I have kept this way keeping in mind that we might add more options in the future. Can i get your suggestion on the alternative u mentioned?
Hey @iwilltry42 . I would like to revisit this PR on the points u mentioned. Can u kindly elaborate please?
@tesla59 sorry I never got back to this! I wonder what's the big benefit of creating those extra options in Viper as compared to what I mentioned here: https://github.com/k3d-io/k3d/pull/1294#issuecomment-1664409683 ?
Closing due to inactivity. Feel free to reopen if still applicable.