Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: CRD's openapi schema extension cannot be properly serialized #1804

Merged

Conversation

yue9944882
Copy link
Member

Fixes: #1796

this pull allows the yaml serializer to have similar behavior as gson's @SerializedName annotation by registering additional type descriptions.

and i will pick it to past releases after merged, as it's breaking all CRDs w/ the openapi extension.

cc @brendandburns

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 27, 2021
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 27, 2021
Copy link
Contributor

@NeverRaR NeverRaR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yaml.dump() is still not working properly,it will serialize field "x-kubernetes-int-or-string" to
"xKubernetesIntOrString" and "x-kubernetes-int-or-string" like this:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: crontabs.stable.example.com
spec:
  group: stable.example.com
  names:
    kind: CronTab
    plural: crontabs
    shortNames:
    - ct
    singular: crontab
  scope: Namespaced
  versions:
  - name: v1
    schema:
      openAPIV3Schema:
        type: object
        properties:
          foo:
            anyOf:
            - type: integer
            - type: string
            pattern: ^.*
            x-kubernetes-int-or-string: true
+           xKubernetesIntOrString: true
          spec:
            type: object
            properties:
              cronSpec:
                type: string
              image:
                type: string
              replicas:
                type: integer
    served: true
    storage: true

@yue9944882
Copy link
Member Author

@NeverRaR nice catch, i fixed CRD dumping in the latest commit

representer.addTypeDescription(desc);
}

private static TypeDescription substitudePropertiesWithGsonAnnotation(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe substitute?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep nailed typo

@brendandburns
Copy link
Contributor

This looks good to me, but waiting for @NeverRaR to lgtm also.

@NeverRaR
Copy link
Contributor

/lgtm

@k8s-ci-robot
Copy link
Contributor

@NeverRaR: changing LGTM is restricted to collaborators

In response to this:

/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@NeverRaR
Copy link
Contributor

lgtm

@brendandburns
Copy link
Contributor

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 29, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: brendandburns, yue9944882

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [brendandburns,yue9944882]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Yaml fails to load/dump CRD contains x-kubernetes-int-or-string in V1JSONSchemaProps
4 participants