Skip to content

Commit

Permalink
fix(openapi): don't duplicate ObjectMeta for kustomize
Browse files Browse the repository at this point in the history
From sigs.k8s.io/kustomize/[email protected]/types/objectmeta.go

// ObjectMeta partially copies apimachinery/pkg/apis/meta/v1.ObjectMeta
// No need for a direct dependence; the fields are stable.

Signed-off-by: Marc Nuri <[email protected]>
  • Loading branch information
manusa authored Aug 14, 2024
1 parent 4807fa8 commit 342fb8a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions kubernetes-model-generator/openapi/generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ type Schema struct {
Paths map[reflect.Type]ApiVersion
}

var mappingOverrides = map[reflect.Type]string{
reflect.TypeOf(kustomize.ObjectMeta{}): "#/components/schemas/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta",
}

func NewTypeSchema(types []reflect.Type, name string) Schema {
return Schema{types, name, make(map[reflect.Type]ApiVersion)}
}
Expand Down Expand Up @@ -230,6 +234,11 @@ func extractFields(fields []reflect.StructField, t reflect.Type) []reflect.Struc
}

func openApiKind(t reflect.Type) *openapi3.SchemaRef {
if mappingOverrides[t] != "" {
return &openapi3.SchemaRef{
Ref: mappingOverrides[t],
}
}
stringSchema := &openapi3.SchemaRef{
Value: openapi3.NewStringSchema(),
}
Expand Down
2 changes: 1 addition & 1 deletion kubernetes-model-generator/openapi/schemas/kustomize.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"components":{"schemas":{"io.k8s.sigs.kustomize.api.types.ConfigMapArgs":{"properties":{"behavior":{"type":"string"},"env":{"type":"string"},"envs":{"items":{"type":"string"},"type":"array"},"files":{"items":{"type":"string"},"type":"array"},"literals":{"items":{"type":"string"},"type":"array"},"name":{"type":"string"},"namespace":{"type":"string"},"options":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.GeneratorOptions"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.FieldOptions":{"properties":{"create":{"type":"boolean"},"delimiter":{"type":"string"},"encoding":{"type":"string"},"index":{"format":"int32","type":"integer"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.FieldSelector":{"properties":{"fieldPath":{"type":"string"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.FieldSpec":{"properties":{"create":{"type":"boolean"},"group":{"type":"string"},"kind":{"type":"string"},"path":{"type":"string"},"version":{"type":"string"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.GeneratorOptions":{"properties":{"annotations":{"additionalProperties":{"type":"string"},"type":"object"},"disableNameSuffixHash":{"type":"boolean"},"immutable":{"type":"boolean"},"labels":{"additionalProperties":{"type":"string"},"type":"object"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.HelmChart":{"properties":{"additionalValuesFiles":{"items":{"type":"string"},"type":"array"},"apiVersions":{"items":{"type":"string"},"type":"array"},"includeCRDs":{"type":"boolean"},"kubeVersion":{"type":"string"},"name":{"type":"string"},"nameTemplate":{"type":"string"},"namespace":{"type":"string"},"releaseName":{"type":"string"},"repo":{"type":"string"},"skipHooks":{"type":"boolean"},"skipTests":{"type":"boolean"},"valuesFile":{"type":"string"},"valuesInline":{"additionalProperties":{"type":"object"},"type":"object"},"valuesMerge":{"type":"string"},"version":{"type":"string"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.HelmChartArgs":{"properties":{"chartHome":{"type":"string"},"chartName":{"type":"string"},"chartRepoName":{"type":"string"},"chartRepoUrl":{"type":"string"},"chartVersion":{"type":"string"},"extraArgs":{"items":{"type":"string"},"type":"array"},"helmBin":{"type":"string"},"helmHome":{"type":"string"},"releaseName":{"type":"string"},"releaseNamespace":{"type":"string"},"values":{"type":"string"},"valuesLocal":{"additionalProperties":{"type":"object"},"type":"object"},"valuesMerge":{"type":"string"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.HelmGlobals":{"properties":{"chartHome":{"type":"string"},"configHome":{"type":"string"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.Image":{"properties":{"digest":{"type":"string"},"name":{"type":"string"},"newName":{"type":"string"},"newTag":{"type":"string"},"tagSuffix":{"type":"string"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.Kustomization":{"properties":{"apiVersion":{"type":"string"},"bases":{"items":{"type":"string"},"type":"array"},"buildMetadata":{"items":{"type":"string"},"type":"array"},"commonAnnotations":{"additionalProperties":{"type":"string"},"type":"object"},"commonLabels":{"additionalProperties":{"type":"string"},"type":"object"},"components":{"items":{"type":"string"},"type":"array"},"configMapGenerator":{"items":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.ConfigMapArgs"},"type":"array"},"configurations":{"items":{"type":"string"},"type":"array"},"crds":{"items":{"type":"string"},"type":"array"},"generatorOptions":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.GeneratorOptions"},"generators":{"items":{"type":"string"},"type":"array"},"helmChartInflationGenerator":{"items":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.HelmChartArgs"},"type":"array"},"helmCharts":{"items":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.HelmChart"},"type":"array"},"helmGlobals":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.HelmGlobals"},"imageTags":{"items":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.Image"},"type":"array"},"images":{"items":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.Image"},"type":"array"},"kind":{"type":"string"},"labels":{"items":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.Label"},"type":"array"},"metadata":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.ObjectMeta"},"namePrefix":{"type":"string"},"nameSuffix":{"type":"string"},"namespace":{"type":"string"},"openapi":{"additionalProperties":{"type":"string"},"type":"object"},"patches":{"items":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.Patch"},"type":"array"},"patchesJson6902":{"items":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.Patch"},"type":"array"},"patchesStrategicMerge":{"items":{"type":"string"},"type":"array"},"replacements":{"items":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.ReplacementField"},"type":"array"},"replicas":{"items":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.Replica"},"type":"array"},"resources":{"items":{"type":"string"},"type":"array"},"secretGenerator":{"items":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.SecretArgs"},"type":"array"},"sortOptions":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.SortOptions"},"transformers":{"items":{"type":"string"},"type":"array"},"validators":{"items":{"type":"string"},"type":"array"},"vars":{"items":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.Var"},"type":"array"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.Label":{"properties":{"fields":{"items":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.FieldSpec"},"type":"array"},"includeSelectors":{"type":"boolean"},"includeTemplates":{"type":"boolean"},"pairs":{"additionalProperties":{"type":"string"},"type":"object"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.LegacySortOptions":{"properties":{"orderFirst":{"items":{"type":"string"},"type":"array"},"orderLast":{"items":{"type":"string"},"type":"array"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.ObjectMeta":{"properties":{"annotations":{"additionalProperties":{"type":"string"},"type":"object"},"labels":{"additionalProperties":{"type":"string"},"type":"object"},"name":{"type":"string"},"namespace":{"type":"string"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.Patch":{"properties":{"options":{"additionalProperties":{"type":"boolean"},"type":"object"},"patch":{"type":"string"},"path":{"type":"string"},"target":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.Selector"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.ReplacementField":{"properties":{"path":{"type":"string"},"source":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.SourceSelector"},"targets":{"items":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.TargetSelector"},"type":"array"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.Replica":{"properties":{"count":{"format":"int64","type":"integer"},"name":{"type":"string"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.SecretArgs":{"properties":{"behavior":{"type":"string"},"env":{"type":"string"},"envs":{"items":{"type":"string"},"type":"array"},"files":{"items":{"type":"string"},"type":"array"},"literals":{"items":{"type":"string"},"type":"array"},"name":{"type":"string"},"namespace":{"type":"string"},"options":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.GeneratorOptions"},"type":{"type":"string"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.Selector":{"properties":{"annotationSelector":{"type":"string"},"group":{"type":"string"},"kind":{"type":"string"},"labelSelector":{"type":"string"},"name":{"type":"string"},"namespace":{"type":"string"},"version":{"type":"string"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.SortOptions":{"properties":{"legacySortOptions":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.LegacySortOptions"},"order":{"type":"string"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.SourceSelector":{"properties":{"fieldPath":{"type":"string"},"group":{"type":"string"},"kind":{"type":"string"},"name":{"type":"string"},"namespace":{"type":"string"},"options":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.FieldOptions"},"version":{"type":"string"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.Target":{"properties":{"apiVersion":{"type":"string"},"group":{"type":"string"},"kind":{"type":"string"},"name":{"type":"string"},"namespace":{"type":"string"},"version":{"type":"string"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.TargetSelector":{"properties":{"fieldPaths":{"items":{"type":"string"},"type":"array"},"options":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.FieldOptions"},"reject":{"items":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.Selector"},"type":"array"},"select":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.Selector"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.Var":{"properties":{"fieldref":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.FieldSelector"},"name":{"type":"string"},"objref":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.Target"}},"type":"object"}}},"info":{"title":"kustomize","version":"0.0.0"},"openapi":"3.0.0","paths":{}}
{"components":{"schemas":{"io.k8s.sigs.kustomize.api.types.ConfigMapArgs":{"properties":{"behavior":{"type":"string"},"env":{"type":"string"},"envs":{"items":{"type":"string"},"type":"array"},"files":{"items":{"type":"string"},"type":"array"},"literals":{"items":{"type":"string"},"type":"array"},"name":{"type":"string"},"namespace":{"type":"string"},"options":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.GeneratorOptions"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.FieldOptions":{"properties":{"create":{"type":"boolean"},"delimiter":{"type":"string"},"encoding":{"type":"string"},"index":{"format":"int32","type":"integer"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.FieldSelector":{"properties":{"fieldPath":{"type":"string"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.FieldSpec":{"properties":{"create":{"type":"boolean"},"group":{"type":"string"},"kind":{"type":"string"},"path":{"type":"string"},"version":{"type":"string"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.GeneratorOptions":{"properties":{"annotations":{"additionalProperties":{"type":"string"},"type":"object"},"disableNameSuffixHash":{"type":"boolean"},"immutable":{"type":"boolean"},"labels":{"additionalProperties":{"type":"string"},"type":"object"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.HelmChart":{"properties":{"additionalValuesFiles":{"items":{"type":"string"},"type":"array"},"apiVersions":{"items":{"type":"string"},"type":"array"},"includeCRDs":{"type":"boolean"},"kubeVersion":{"type":"string"},"name":{"type":"string"},"nameTemplate":{"type":"string"},"namespace":{"type":"string"},"releaseName":{"type":"string"},"repo":{"type":"string"},"skipHooks":{"type":"boolean"},"skipTests":{"type":"boolean"},"valuesFile":{"type":"string"},"valuesInline":{"additionalProperties":{"type":"object"},"type":"object"},"valuesMerge":{"type":"string"},"version":{"type":"string"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.HelmChartArgs":{"properties":{"chartHome":{"type":"string"},"chartName":{"type":"string"},"chartRepoName":{"type":"string"},"chartRepoUrl":{"type":"string"},"chartVersion":{"type":"string"},"extraArgs":{"items":{"type":"string"},"type":"array"},"helmBin":{"type":"string"},"helmHome":{"type":"string"},"releaseName":{"type":"string"},"releaseNamespace":{"type":"string"},"values":{"type":"string"},"valuesLocal":{"additionalProperties":{"type":"object"},"type":"object"},"valuesMerge":{"type":"string"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.HelmGlobals":{"properties":{"chartHome":{"type":"string"},"configHome":{"type":"string"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.Image":{"properties":{"digest":{"type":"string"},"name":{"type":"string"},"newName":{"type":"string"},"newTag":{"type":"string"},"tagSuffix":{"type":"string"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.Kustomization":{"properties":{"apiVersion":{"type":"string"},"bases":{"items":{"type":"string"},"type":"array"},"buildMetadata":{"items":{"type":"string"},"type":"array"},"commonAnnotations":{"additionalProperties":{"type":"string"},"type":"object"},"commonLabels":{"additionalProperties":{"type":"string"},"type":"object"},"components":{"items":{"type":"string"},"type":"array"},"configMapGenerator":{"items":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.ConfigMapArgs"},"type":"array"},"configurations":{"items":{"type":"string"},"type":"array"},"crds":{"items":{"type":"string"},"type":"array"},"generatorOptions":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.GeneratorOptions"},"generators":{"items":{"type":"string"},"type":"array"},"helmChartInflationGenerator":{"items":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.HelmChartArgs"},"type":"array"},"helmCharts":{"items":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.HelmChart"},"type":"array"},"helmGlobals":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.HelmGlobals"},"imageTags":{"items":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.Image"},"type":"array"},"images":{"items":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.Image"},"type":"array"},"kind":{"type":"string"},"labels":{"items":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.Label"},"type":"array"},"metadata":{"$ref":"#/components/schemas/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta"},"namePrefix":{"type":"string"},"nameSuffix":{"type":"string"},"namespace":{"type":"string"},"openapi":{"additionalProperties":{"type":"string"},"type":"object"},"patches":{"items":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.Patch"},"type":"array"},"patchesJson6902":{"items":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.Patch"},"type":"array"},"patchesStrategicMerge":{"items":{"type":"string"},"type":"array"},"replacements":{"items":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.ReplacementField"},"type":"array"},"replicas":{"items":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.Replica"},"type":"array"},"resources":{"items":{"type":"string"},"type":"array"},"secretGenerator":{"items":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.SecretArgs"},"type":"array"},"sortOptions":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.SortOptions"},"transformers":{"items":{"type":"string"},"type":"array"},"validators":{"items":{"type":"string"},"type":"array"},"vars":{"items":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.Var"},"type":"array"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.Label":{"properties":{"fields":{"items":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.FieldSpec"},"type":"array"},"includeSelectors":{"type":"boolean"},"includeTemplates":{"type":"boolean"},"pairs":{"additionalProperties":{"type":"string"},"type":"object"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.LegacySortOptions":{"properties":{"orderFirst":{"items":{"type":"string"},"type":"array"},"orderLast":{"items":{"type":"string"},"type":"array"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.ObjectMeta":{"properties":{"annotations":{"additionalProperties":{"type":"string"},"type":"object"},"labels":{"additionalProperties":{"type":"string"},"type":"object"},"name":{"type":"string"},"namespace":{"type":"string"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.Patch":{"properties":{"options":{"additionalProperties":{"type":"boolean"},"type":"object"},"patch":{"type":"string"},"path":{"type":"string"},"target":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.Selector"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.ReplacementField":{"properties":{"path":{"type":"string"},"source":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.SourceSelector"},"targets":{"items":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.TargetSelector"},"type":"array"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.Replica":{"properties":{"count":{"format":"int64","type":"integer"},"name":{"type":"string"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.SecretArgs":{"properties":{"behavior":{"type":"string"},"env":{"type":"string"},"envs":{"items":{"type":"string"},"type":"array"},"files":{"items":{"type":"string"},"type":"array"},"literals":{"items":{"type":"string"},"type":"array"},"name":{"type":"string"},"namespace":{"type":"string"},"options":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.GeneratorOptions"},"type":{"type":"string"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.Selector":{"properties":{"annotationSelector":{"type":"string"},"group":{"type":"string"},"kind":{"type":"string"},"labelSelector":{"type":"string"},"name":{"type":"string"},"namespace":{"type":"string"},"version":{"type":"string"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.SortOptions":{"properties":{"legacySortOptions":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.LegacySortOptions"},"order":{"type":"string"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.SourceSelector":{"properties":{"fieldPath":{"type":"string"},"group":{"type":"string"},"kind":{"type":"string"},"name":{"type":"string"},"namespace":{"type":"string"},"options":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.FieldOptions"},"version":{"type":"string"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.Target":{"properties":{"apiVersion":{"type":"string"},"group":{"type":"string"},"kind":{"type":"string"},"name":{"type":"string"},"namespace":{"type":"string"},"version":{"type":"string"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.TargetSelector":{"properties":{"fieldPaths":{"items":{"type":"string"},"type":"array"},"options":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.FieldOptions"},"reject":{"items":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.Selector"},"type":"array"},"select":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.Selector"}},"type":"object"},"io.k8s.sigs.kustomize.api.types.Var":{"properties":{"fieldref":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.FieldSelector"},"name":{"type":"string"},"objref":{"$ref":"#/components/schemas/io.k8s.sigs.kustomize.api.types.Target"}},"type":"object"}}},"info":{"title":"kustomize","version":"0.0.0"},"openapi":"3.0.0","paths":{}}

0 comments on commit 342fb8a

Please sign in to comment.