kuberig-io / kuberig-dsl

KubeRig DSL generation code
https://kuberig.io
Apache License 2.0
8 stars 0 forks source link

Kubernetes v1.16.0 dsl generation fails #12

Closed teyckmans closed 4 years ago

teyckmans commented 4 years ago

JSONSchemaProps attribute x-kubernetes-list-map-keys causes the kuberig-dsl to generate invalid kotlin code.

teyckmans commented 4 years ago

On line 17879 of the swagger file https://raw.githubusercontent.com/kubernetes/kubernetes/v1.16.0/api/openapi-spec/swagger.json

The following attribute is defined:

        "x-kubernetes-list-map-keys": {
          "description": "x-kubernetes-list-map-keys annotates an array with the x-kubernetes-list-type `map` by specifying the keys used as the index of the map.\n\nThis tag MUST only be used on lists that have the \"x-kubernetes-list-type\" extension set to \"map\". Also, the values specified for this attribute must be a scalar typed field of the child structure (no nesting is supported).",
          "items": {
            "type": "string"
          },
          "type": "array"
        },

This causes the Dsl type generation to behave incorrectly. A wrong Dsl type directory and ListDsl type is generated.

Also the factory method contains invalid code.

teyckmans commented 4 years ago

Reason why this is failing is because this is the first time the api specification has an 'x-kubernetes-xyz' attribute that is not a simple type but a list that where we generate separate types for.

And the type generation did not handle the 'x-kubernetes-xyz' part correctly in type name generation. Which in turn cause a wrong directory and type to be generated.

As a fix we now remove '-' characters from type names. This also fixes the factory method code issue as the type name is used here as well when generating the constructor call.

teyckmans commented 4 years ago

This fix breaks openshift compatibility. Need to check what is happening.

teyckmans commented 4 years ago

The failure was due to build issues. Solved in 0.0.14.