Azure / aks-app-routing-operator

Kubernetes operator that implements AKS Application Routing
https://learn.microsoft.com/en-us/azure/aks/app-routing
MIT License
32 stars 23 forks source link

fix self deploy bug #40

Closed OliverMKing closed 1 year ago

OliverMKing commented 1 year ago

Description

If war is unable to find its own deployment then currently it will return a malformed deployment object and nil for that function. We have checks later that check if the deployment object is nil and handle that case accordingly. Those rely on us returning nil if the deployment is not found.

nil, nil is often an anitpattern in go but it's not in this case because nil is the desired value if self isn't found. self being nil is a concept that's supported within all of the war code. The reason why nil, nil is an antipattern in go is because if you receive a nil error from a function that means you should be able to use the other values (and nil is usually not actually a desired state of other values). This is good because otherwise you'd need multiple nil checks versus just one against error. In this case nil is a valid state of self (it's possible for it not to exist) so this is a fine pattern.

Type of change

Please delete options that are not relevant.

How Has This Been Tested?

Tested with unit tests.

Checklist: