kubernetes / kubernetes/kube-openapi

Having the same type embedded more than once breaks generation

Open
#129 5 comments 0 reactions 0 assignees View on GitHub
good first issue lifecycle/frozen
Dominant language
Go
Stars
356
Forks
249
Avg merge
1d 15h
Merged PRs (30d)
3

Description

`ServiceServingCertSignerConfig` embeds `metav1.TypeMeta` and `configv1.GenericControllerConfig`: https://github.com/openshift/api/blob/master/servicecertsigner/v1alpha1/types.go#L15-L21

At the time, `configv1.GenericControllerConfig` also embedded `metav1.TypeMeta`, which led to:

```
func schema_openshift_api_servicecertsigner_v1alpha1_ServiceServingCertSignerConfig(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "ServiceServingCertSignerConfig provides information to configure a serving serving cert signing controller",
Properties: map[string]spec.Schema{
"kind": {
SchemaProps: spec.SchemaProps{
Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds",
Type: []string{"string"},
Format: "",
},
},
"apiVersion": {
SchemaProps: spec.SchemaProps{
Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources",
Type: []string{"string"},
Format: "",
},
},
"kind": {
SchemaProps: spec.SchemaProps{
Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds",
Type: []string{"string"},
Format: "",
},
},
"apiVersion": {
SchemaProps: spec.SchemaProps{
Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources",
Type: []string{"string"},
Format: "",
},
},
```

```
pkg/openapi/zz_generated.openapi.go:24107:6: duplicate key "kind" in map literal
pkg/openapi/zz_generated.openapi.go:24114:6: duplicate key "apiVersion" in map literal
```

Contributor guide

Open the contributing guide

Research direction

Start with servicecertsigner/v1alpha1/types.go and the generated output in pkg/openapi/zz_generated.openapi.go, then reproduce generation for ServiceServingCertSignerConfig. Trace how embedded TypeMeta fields are collected and confirm that the generated Go map contains no duplicate kind or apiVersion keys and compiles successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.