travisghansen / kubernetes-client-php

No nonsense PHP Client for the Kubernetes API
Apache License 2.0
33 stars 10 forks source link

New feature: method Config::AutoConfig() #7

Closed data219 closed 3 years ago

data219 commented 3 years ago

Convenience method to ease bootstrapping the config. Just a simple method trying if in cluster config or config file config is to be found at the default locations and giving in cluster config precedence over config file variant.

Requires PR #5 to work correctly.

While using in cluster config in production/staging, I guess many people might want to use config files in local development. This method eases such setups and helps with the distinction between hosting environments. (Which requires knowledge of k8s that should not concern bootstrapping code.)

travisghansen commented 3 years ago

With this one I say we roughly follow the conventions here (both in naming and preference/order): https://github.com/kubernetes-client/javascript/blob/master/src/config.ts#L285

data219 commented 3 years ago

configs precedence and method named adjusted according to JS implementation.

travisghansen commented 3 years ago

The docblock logic is backward on this now. And should it be updated to catch error instead of exception now?

data219 commented 3 years ago

Absolutely! I swapped the logic in the comment and made it catch Error.

travisghansen commented 3 years ago

I’ll snap a release in a few hours with the fixes. Thanks for the contributions!

travisghansen commented 3 years ago

OK just snapped v0.3.3. Thanks again!