koki / short

Manageable Kubernetes manifests through a composable, reusable syntax
https://docs.koki.io/short
Apache License 2.0
122 stars 14 forks source link

service shorthand #29

Closed ublubu closed 6 years ago

ublubu commented 6 years ago

@wlan0

Setting Kind in the koki->kube transform because it doesn't happen automatically.

Service shorthand with some tests and example yamls.

Notes: I'm using strings wrapped as IPAddr instead of net.IP because the json/yaml ser/de doesn't work well with net.IP. It might be worth figuring out the framework for performing validation (perhaps separately from the file format/conversion implementation).

wlan0 commented 6 years ago

This mostly LGTM. What's the deal with the revert...Into pattern?

It's not easy to tell where the values are being assigned when reading that pattern...

ublubu commented 6 years ago

My thinking is this: I'm using revert...Into as a convenient way to make changes across multiple fields. It's a tradeoff between having to trust that the revert method doesn't do anything bad and cluttering the top-level conversion method with marshaling multiple values into multiple fields. I generally prefer to avoid code that relies on side-effects like this, but IMO the syntax favors the approach I've taken.

With that said, I'll have a look through again to make sure there's enough going on in the into methods that it's worth taking the shortcut. (And add comments about what each into method is doing behind the scenes.)

ublubu commented 6 years ago

updated, @wlan0

ublubu commented 6 years ago

@wlan0, yeah it is nicer without the revertXInto functions.