kptdev/kpt

Go kpt fn SDK isGVK function errantly returns true when the groups do not match

bmcmanus-apex opened this issue · 2 comments

Expected behavior

IsGVK does not return true for K8s service with group: "", version: "v1" and kind: "Service" when checking for a knative service with group: "serving.knative.dev", version: "v1" and kind: "Service"

Actual behavior

IsGVK returns true for K8s service with group: "", version: "v1" and kind: "Service" when checking for a knative service with group: "serving.knative.dev", version: "v1" and kind: "Service"

Information

obj.IsGVK("serving.knative.dev", "v1", "Service") returns true errantly when the obj is a K8s service. The function checks that both the object group and parameter group are not empty before performing an equality check. In the case of a service there is no group and consequently the logic short cuts before the comparison that would return the appropriate false. I see from the function comment that the empty string as a parameter should match any group which seems reasonable. The object group should be strictly respected though and not match any group parameter it would seem.

Steps to reproduce the behavior

when obj is a k8s service similar to below:

apiVersion: v1
kind: Service
metadata:
  labels:
    app.kubernetes.io/name: some-service
  name: some-service
spec:
  clusterIP: None
  ports:
    - name: postgresdb
      port: 5432
  selector:
    app.kubernetes.io/name: some-service
  type: ClusterIP

obj.IsGVK("serving.knative.dev", "v1", "Service")

We updated to the latest version of the SDK and the new functions fix the issue reported here.