Kuadrant / policy-machinery

Machinery for implementing Gateway API policies
Apache License 2.0
9 stars 2 forks source link

Rethink "URL" of the Object interface #10

Closed guicassolato closed 2 months ago

guicassolato commented 3 months ago

The "URL" concept of the Object interface (GetURL()) took inspiration from Kube's SelfLink which was deprecated.

In the context of a Policy Machinery topology, URL serves the purpose of uniquely identifying an object that is added to the topology, with the additional requirement that it must be possible to infer its value from a policy targetRef field.

Moreover, one should not have to read a resource from the cluster to know its unique ID. Other than calculating from targetRefs, this rather general requirement allows adding to a topology (1) objects that act like cluster objects but that are not in fact so, such as Listener and HTTPRouteRule topology objects, and (2) objects that only exist in memory and have not obtained an actual UID assigned by the cluster. For this reason, Kubernetes's UIDs cannot be used.

In summary, there's nothing wrong with Policy Machinery's URL, except perhaps its name or its current conventional value.

"URL" may lead users to expect a value formatted as a classical web URL, i.e. scheme ":" ["//" authority] path ["?" query] ["#" fragment]. However, in the Policy Machinery, the proposed convention so far has been: kind:qualified-name, where qualified-name typically has of one of the following formats: namespace/name, namespace/name#section, name, name#section.

This issue is to either rename the GetURL() function of the Object interface or establish a convention for its value that fits the requirements without being confusing to users.

We should also avoid name overloading. Therefore, calling URL as "UID" or "SelfLink" is not OK.