Merge pull request #109867 from tnqn/automated-cherry-pick-of-#109836-upstream-release-1.23

Automated cherry pick of #109836: Fix OpenAPI loading error caused by empty APIService
This commit is contained in:
Kubernetes Prow Robot 2022-05-10 01:45:43 -07:00 committed by GitHub
commit 21cde7de1f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -61,11 +61,11 @@ func IsLocalAPIService(apiServiceName string) bool {
return strings.HasPrefix(apiServiceName, localDelegateChainNamePrefix)
}
// GetAPIServicesName returns the names of APIServices recorded in specAggregator.openAPISpecs.
// GetAPIServiceNames returns the names of APIServices recorded in specAggregator.openAPISpecs.
// We use this function to pass the names of local APIServices to the controller in this package,
// so that the controller can periodically sync the OpenAPI spec from delegation API servers.
func (s *specAggregator) GetAPIServiceNames() []string {
names := make([]string, len(s.openAPISpecs))
names := make([]string, 0, len(s.openAPISpecs))
for key := range s.openAPISpecs {
names = append(names, key)
}

View file

@ -53,14 +53,14 @@ func IsLocalAPIService(apiServiceName string) bool {
return strings.HasPrefix(apiServiceName, localDelegateChainNamePrefix)
}
// GetAPIServicesName returns the names of APIServices recorded in openAPIV3Specs.
// GetAPIServiceNames returns the names of APIServices recorded in openAPIV3Specs.
// We use this function to pass the names of local APIServices to the controller in this package,
// so that the controller can periodically sync the OpenAPI spec from delegation API servers.
func (s *specAggregator) GetAPIServiceNames() []string {
s.rwMutex.Lock()
defer s.rwMutex.Unlock()
names := make([]string, len(s.openAPIV3Specs))
names := make([]string, 0, len(s.openAPIV3Specs))
for key := range s.openAPIV3Specs {
names = append(names, key)
}