kube-aggregator: update existing openapi spec info if pre-existing

This commit is contained in:
Dr. Stefan Schimanski 2019-04-10 15:34:48 +02:00
parent 1cca3f9d45
commit 1f1a524f48

View File

@ -202,15 +202,16 @@ func (s *specAggregator) tryUpdatingServiceSpecs(specInfo *openAPISpecInfo) erro
if specInfo == nil {
return fmt.Errorf("invalid input: specInfo must be non-nil")
}
orgSpecInfo, exists := s.openAPISpecs[specInfo.apiService.Name]
origSpecInfo, existedBefore := s.openAPISpecs[specInfo.apiService.Name]
s.openAPISpecs[specInfo.apiService.Name] = specInfo
// Skip aggregation if OpenAPI spec didn't change
if exists && orgSpecInfo != nil && orgSpecInfo.etag == specInfo.etag {
if existedBefore && origSpecInfo != nil && origSpecInfo.etag == specInfo.etag {
return nil
}
s.openAPISpecs[specInfo.apiService.Name] = specInfo
if err := s.updateOpenAPISpec(); err != nil {
if exists {
s.openAPISpecs[specInfo.apiService.Name] = orgSpecInfo
if existedBefore {
s.openAPISpecs[specInfo.apiService.Name] = origSpecInfo
} else {
delete(s.openAPISpecs, specInfo.apiService.Name)
}