From 01bc4eff0e4d50df645f355ac89f7de3bbd8724f Mon Sep 17 00:00:00 2001 From: "Dr. Stefan Schimanski" Date: Mon, 19 Nov 2018 17:09:44 +0100 Subject: [PATCH] openapi-aggregation: merge without clones --- .../pkg/controllers/openapi/aggregator.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/staging/src/k8s.io/kube-aggregator/pkg/controllers/openapi/aggregator.go b/staging/src/k8s.io/kube-aggregator/pkg/controllers/openapi/aggregator.go index 343cdee3ddd..4dadf71e980 100644 --- a/staging/src/k8s.io/kube-aggregator/pkg/controllers/openapi/aggregator.go +++ b/staging/src/k8s.io/kube-aggregator/pkg/controllers/openapi/aggregator.go @@ -196,13 +196,12 @@ func (s *specAggregator) buildOpenAPISpec() (specToReturn *spec.Swagger, err err } sortByPriority(specs) for _, specInfo := range specs { - // TODO: Make kube-openapi.MergeSpec(s) accept nil or empty spec as destination and just clone the spec in that case. if specToReturn == nil { - specToReturn, err = aggregator.CloneSpec(specInfo.spec) - if err != nil { - return nil, err - } - continue + specToReturn = &spec.Swagger{} + *specToReturn = *specInfo.spec + // Paths and Definitions are set by MergeSpecsIgnorePathConflict + specToReturn.Paths = nil + specToReturn.Definitions = nil } if err := aggregator.MergeSpecsIgnorePathConflict(specToReturn, specInfo.spec); err != nil { return nil, err @@ -267,7 +266,7 @@ func (s *specAggregator) UpdateAPIServiceSpec(apiServiceName string, spec *spec. // For APIServices (non-local) specs, only merge their /apis/ prefixed endpoint as it is the only paths // proxy handler delegates. if specInfo.apiService.Spec.Service != nil { - aggregator.FilterSpecByPaths(spec, []string{"/apis/"}) + spec = aggregator.FilterSpecByPathsWithoutSideEffects(spec, []string{"/apis/"}) } return s.tryUpdatingServiceSpecs(&openAPISpecInfo{