Skip to content

Commit

Permalink
feat: openapi generator generates metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
manusa committed Jul 10, 2024
1 parent 92469de commit 67c383d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions kubernetes-model-generator/openapi/generator/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
k8s.io/apiextensions-apiserver v0.30.2
k8s.io/apimachinery v0.30.2
k8s.io/client-go v0.30.2
k8s.io/metrics v0.30.2
sigs.k8s.io/gateway-api v1.1.0
sigs.k8s.io/kustomize/api v0.17.2
)
Expand Down
2 changes: 2 additions & 0 deletions kubernetes-model-generator/openapi/generator/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw=
k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
k8s.io/kube-openapi v0.0.0-20240423202451-8948a665c108 h1:Q8Z7VlGhcJgBHJHYugJ/K/7iB8a2eSxCyxdVjJp+lLY=
k8s.io/kube-openapi v0.0.0-20240423202451-8948a665c108/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98=
k8s.io/metrics v0.30.2 h1:zj4kIPTCfEbY0RHEogpA7QtlItU7xaO11+Gz1zVDxlc=
k8s.io/metrics v0.30.2/go.mod h1:GpoO5XTy/g8CclVLtgA5WTrr2Cy5vCsqr5Xa/0ETWIk=
k8s.io/utils v0.0.0-20240423183400-0849a56e8f22 h1:ao5hUqGhsqdm+bYbjH/pRkCs0unBGe9UyDahzs9zQzQ=
k8s.io/utils v0.0.0-20240423183400-0849a56e8f22/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
sigs.k8s.io/gateway-api v1.1.0 h1:DsLDXCi6jR+Xz8/xd0Z1PYl2Pn0TyaFMOPPZIj4inDM=
Expand Down
13 changes: 10 additions & 3 deletions kubernetes-model-generator/openapi/generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
apiextensionsV1Beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
configapiV1 "k8s.io/client-go/tools/clientcmd/api/v1"
metricsV1Beta1 "k8s.io/metrics/pkg/apis/metrics/v1beta1"
"os"
"path/filepath"
"reflect"
Expand Down Expand Up @@ -97,9 +98,6 @@ func main() {
reflect.TypeOf(apiextensionsV1Beta1.SelectableField{}),
reflect.TypeOf(apiextensionsV1Beta1.ValidationRule{}),
}, "apiextensions"),
NewTypeSchema([]reflect.Type{
reflect.TypeOf(kustomize.Kustomization{}),
}, "kustomize"),
NewPathSchema(map[reflect.Type]string{
reflect.TypeOf(gatewayApiV1.GatewayList{}): "/apis/" + gatewayApiV1.GroupName + "/v1/namespaces/{namespace}/gateways",
reflect.TypeOf(gatewayApiV1.Gateway{}): "/apis/" + gatewayApiV1.GroupName + "/v1/namespaces/{namespace}/gateways/{name}",
Expand All @@ -116,6 +114,15 @@ func main() {
reflect.TypeOf(gatewayApiV1Beta1.ReferenceGrantList{}): "/apis/" + gatewayApiV1.GroupName + "/v1beta1/namespaces/{namespace}/referencegrants",
reflect.TypeOf(gatewayApiV1Beta1.ReferenceGrant{}): "/apis/" + gatewayApiV1.GroupName + "/v1beta1/namespaces/{namespace}/referencegrants/{name}",
}, "gateway-api"),
NewTypeSchema([]reflect.Type{
reflect.TypeOf(kustomize.Kustomization{}),
}, "kustomize"),
NewPathSchema(map[reflect.Type]string{
reflect.TypeOf(metricsV1Beta1.NodeMetricsList{}): "/apis/" + metricsV1Beta1.SchemeGroupVersion.String() + "/nodes",
reflect.TypeOf(metricsV1Beta1.NodeMetrics{}): "/apis/" + metricsV1Beta1.SchemeGroupVersion.String() + "/nodes/{name}",
reflect.TypeOf(metricsV1Beta1.PodMetricsList{}): "/apis/" + metricsV1Beta1.SchemeGroupVersion.String() + "/namespaces/{namespace}/pods",
reflect.TypeOf(metricsV1Beta1.PodMetrics{}): "/apis/" + metricsV1Beta1.SchemeGroupVersion.String() + "/namespaces/{namespace}/pods/{name}",
}, "metrics"),
}
generate(schemas, targetDirectory)
}
Expand Down

0 comments on commit 67c383d

Please sign in to comment.