Generating OpenAPI spec for Google Config Connector

158 views Asked by At

I'm trying to use the Kube OpenAPI tool openapi-gen to generate OpenAPI specs for Google's Config Connector.

I'm relatively new to Go, so I'm not sure whether this is a configuration error on my part or if I'm simply using it wrong.

I've cloned the Kube OpenAPI repo, and inside of that directory I've cloned the Config Connector repo, for simplicity.

This is what's happening when I try to generate an OpenAPI spec file.

$ go run cmd/openapi-gen/openapi-gen.go -i ./k8s-config-connector/pkg/apis/serviceusage/v1beta1 -p foo.com/foo -h ./boilerplate/boilerplate.go.txt
E0811 16:45:57.516697   22683 openapi.go:309] Error when generating: TypeMeta, TypeMeta invalid type
2021/08/11 16:45:57 OpenAPI code generation error: Failed executing generator: some packages had errors:
failed to generate default in ./k8s-config-connector/pkg/apis/serviceusage/v1beta1.Service: TypeMeta: not sure how to enforce default for Unsupported
exit status 1

What's going on here?

1

There are 1 answers

0
Fariya Rahmat On

Here are some troubleshooting steps:

1 - GOROOT variable should be set and point to root of go installation

2- Operator-sdk depended on it being exported as an environment variable. Run the below command

export GOROOT=$(go env GOROOT)

when using the operator-sdk, it is necessary to either (a) set GOROOT in your environment, or (b) use the same GOROOT that was used to build the operator-sdk binary.

Refer to the link for additional information.