crd2pulumi icon indicating copy to clipboard operation
crd2pulumi copied to clipboard

[Golang] AWS LB Controller TargetGroupBinding generates empty struct for TargetGroupBindingSpecServiceRefArgs

Open crielly opened this issue 4 years ago • 7 comments
trafficstars

Essentially, it seems that when generating types from the AWS LB controller's TargetGroupBinding CRD, at least one struct is missing fields (TargetGroupBindingSpecServiceRefArgs).

Expected behavior

I'd expect it to have a Port field:

              serviceRef:
                description: serviceRef is a reference to a Kubernetes Service and
                  ServicePort.
                properties:
                  name:
                    description: Name is the name of the Service.
                    type: string
                  port:
                    anyOf:
                    - type: integer
                    - type: string
                    description: Port is the port of the ServicePort.
                    x-kubernetes-int-or-string: true
                required:
                - name
                - port
                type: object

Current behavior

no fields at all:

type TargetGroupBindingSpecServiceRefPortArgs struct {
}

Steps to reproduce

  1. have AWS LB Controller installed in your Kube cluster
  2. kubectl get crd targetgroupbindings.elbv2.k8s.aws -o yaml > tgb-crd.yml
  3. crd2pulumi --goPath tgb-crd.yml

Context (Environment)

Go 1.16 WSL2 Ubuntu 20.04

Affected feature

?

crielly avatar May 26 '21 16:05 crielly

Does this only impact the Go code generation, or does it also impact other languages?

lukehoban avatar May 27 '21 21:05 lukehoban

I am not in a position to say as I'm not using any other languages with Pulumi.

crielly avatar May 28 '21 17:05 crielly

Have also struck this with traefik CRDs that follow a similar pattern:

              retry:
                description: Retry holds the retry configuration.
                properties:
                  attempts:
                    type: integer
                  initialInterval:
                    anyOf:
                    - type: integer
                    - type: string
                    x-kubernetes-int-or-string: true
                type: object

results in a struct with no parameters.

davefinster avatar Jun 11 '21 01:06 davefinster

The same thing happens for Traefik IngressRoute, services port struct has no fields. CRD: https://github.com/traefik/traefik-helm-chart/blob/5ee335a0f96179ad2457e2d3289776e1c20184d4/traefik/crds/ingressroute.yaml#L87

ncsibra avatar Sep 07 '21 10:09 ncsibra

The same thing happens for prometheuses.monitoring.coreos.com (prometheus-operator). The fields PrometheusSpecResourcesLimitsArgs and PrometheusSpecResourcesRequestsArgs are empty structs. They follow the same pattern as the above, i.e:

  anyOf:
  - type: integer
  - type: string
  x-kubernetes-int-or-string: true

Dadavan avatar Nov 15 '21 13:11 Dadavan

@lukehoban any progress? I'd love to help if you can point me in the right direction

hagaibarel avatar Nov 15 '21 14:11 hagaibarel

I had a similar issue generating code for dotnet from a crd containing the following pattern:

  anyOf:
  - type: integer
  - type: string
  x-kubernetes-int-or-string: true

It would seem that crd2pulumi ignores the x-kubernetes-int-or-string property if the oneOf, anyOf or allOf properties exists. From what i can gather (specifically here and here) x-kubernetes-int-or-string should take precedence over oneOf, anyOf and allOf.

I fixed it by moving the code for checking for the existence of x-kubernetes-int-or-string above the other three, which made it work for me. A commit containing what i changed to make it work for me can be found here.

madsbacha avatar Nov 17 '21 15:11 madsbacha

Fixed in https://github.com/pulumi/crd2pulumi/pull/60

blampe avatar Jul 01 '24 18:07 blampe