Skip to content

[bug]: Transpiler does not covert ResourceQuantity correctly #958

@ian-buse

Description

@ian-buse

Describe the bug

When converting the ResourceQuantity class, the transpiler produces this CRD output (in this case, for resource limits):

limits:
  additionalProperties:
    properties:
      format:
        enum:
        - DecimalExponent
        - BinarySI
        - DecimalSI
        nullable: false
        type: string
      value:
        nullable: false
        type: string
    type: object
  nullable: false
  type: object

Meaning it would expect the custom resource YAML to look something like:

resources:
  limits:
    cpu:
      enum: BinarySI
      value: abcdefg

However, this doesn't agree with the way Kubernetes expects resource quantities, like 512Mi. The way CRD YAML should look is:

limits:
  type: object
  additionalProperties:
    type: string

The K8s SDK handles converting the value.

I've already have a fix + test for this. Wasn't sure if an issue should be created first or not. 😄

To reproduce

  1. Create a custom resource spec that uses the ResourceQuantity class (like V1ResourceRequirements)
  2. Generate the CRD and look at the invalid output

Expected behavior

It generates a valid CRD.

Screenshots

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions