weaveworks / gitopssets-controller

Manages the GitOpsSet CRDs.
Apache License 2.0
9 stars 5 forks source link

Ignore empty generators in the Matrix generator. #114

Closed bigkevmcd closed 1 year ago

bigkevmcd commented 1 year ago

If generator doesn't yield any resources, then this will avoid generating from them.

Fixes #112

foot commented 1 year ago

Make sense, do we do this at the top level too? 👀

bigkevmcd commented 1 year ago

Make sense, do we do this at the top level too? 👀

We kind of do, we wouldn't generate anything there.

This is an issue at the Matrix level, because it complicates the logic when trying to figure out if either of the two combined elements are empty when merging elements to reduce duplicates.

foot commented 1 year ago

Ah yeah, didn't read through the panic. Good one

│ manager github.com/weaveworks/gitopssets-controller/controllers/templates/generators/matrix.cartesian({0xc0002ccdc0?, 0x2, 0x0?}) │

foot commented 1 year ago

We kind of do, we wouldn't generate anything there.

Would iterate over empty list:

https://github.com/weaveworks/gitopssets-controller/blob/b487430a6cca06b900bd139ced0e03230a7da0dc/controllers/templates/renderer.go#L47

bigkevmcd commented 1 year ago

We kind of do, we wouldn't generate anything there.

Would iterate over empty list:

https://github.com/weaveworks/gitopssets-controller/blob/b487430a6cca06b900bd139ced0e03230a7da0dc/controllers/templates/renderer.go#L47

Yeah, so nothing generated.

The issue is down to this https://github.com/weaveworks/gitopssets-controller/blob/main/controllers/templates/generators/matrix/matrix.go#L207-L209

It's a bit icky to determine whether or not either j or k are greater than their respective slice sizes, because even at 0 that's really size 1.