Arnavion / k8s-openapi

Rust definitions of the resource types in the Kubernetes client API
Apache License 2.0
379 stars 41 forks source link

Allow skipping client generation #102

Open MikailBag opened 3 years ago

MikailBag commented 3 years ago

This is a draft because currently, it still fails on metrics.k8s.io.

MikailBag commented 3 years ago

So, with k3d & k3s v1.20.2, the error is definition io.k8s.apimachinery.pkg.apis.meta.v1.APIGroup_v2 is a Resource but its URL path segment and scope could not be inferred.

/openapi/v2 contains the following (inside paths):

{
// ...
    "/apis/metrics.k8s.io/": {
        "get": {
            "description": "get information of a group",
            "consumes": [
                "application/json",
                "application/yaml",
                "application/vnd.kubernetes.protobuf"
            ],
            "produces": [
                "application/json",
                "application/yaml",
                "application/vnd.kubernetes.protobuf"
            ],
            "schemes": [
                "https"
            ],
            "tags": [
                "metrics"
            ],
            "operationId": "getMetricsAPIGroup",
            "responses": {
                "200": {
                    "description": "OK",
                    "schema": {
                        "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.APIGroup_v2"
                    }
                }
            }
        }
    }
}
// ...

So I conclude k8s-openapi failure here is legitimate: for some reason schema contains two metav1.APIGroups copied.

I will check if the same happens in other distributions.

Arnavion commented 3 years ago

It'll need to be treated like the regular APIGroup - https://github.com/Arnavion/k8s-openapi/blob/445e89ec444ebb1c68e61361e64eec4c4a3f4785/k8s-openapi-codegen-common/src/lib.rs#L452-L456