Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce genericapiserver api surface #33266

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/apiserver/apiserver.go
Expand Up @@ -97,7 +97,7 @@ func Run(serverOptions *genericoptions.ServerRunOptions) error {
Scheme: api.Scheme,
NegotiatedSerializer: api.Codecs,
}
if err := s.InstallAPIGroups([]genericapiserver.APIGroupInfo{apiGroupInfo}); err != nil {
if err := s.InstallAPIGroup(&apiGroupInfo); err != nil {
return fmt.Errorf("Error in installing API: %v", err)
}
s.Run(serverOptions)
Expand Down
12 changes: 1 addition & 11 deletions pkg/genericapiserver/genericapiserver.go
Expand Up @@ -225,16 +225,6 @@ func NewHandlerContainer(mux *http.ServeMux, s runtime.NegotiatedSerializer) *re
return container
}

// Exposes the given group versions in API. Helper method to install multiple group versions at once.
func (s *GenericAPIServer) InstallAPIGroups(groupsInfo []APIGroupInfo) error {
for _, apiGroupInfo := range groupsInfo {
if err := s.InstallAPIGroup(&apiGroupInfo); err != nil {
return err
}
}
return nil
}

// Installs handler at /apis to list all group versions for discovery
func (s *GenericAPIServer) installGroupsDiscoveryHandler() {
apiserver.AddApisWebService(s.Serializer, s.HandlerContainer, s.apiPrefix, func(req *restful.Request) []unversioned.APIGroup {
Expand Down Expand Up @@ -390,7 +380,7 @@ func (s *GenericAPIServer) Run(options *options.ServerRunOptions) {
select {}
}

// Exposes the given group version in API.
// Exposes the given api group in the API.
func (s *GenericAPIServer) InstallAPIGroup(apiGroupInfo *APIGroupInfo) error {
apiPrefix := s.apiPrefix
if apiGroupInfo.IsLegacyGroup {
Expand Down
4 changes: 3 additions & 1 deletion pkg/genericapiserver/genericapiserver_test.go
Expand Up @@ -138,7 +138,9 @@ func TestInstallAPIGroups(t *testing.T) {
NegotiatedSerializer: api.Codecs,
},
}
s.InstallAPIGroups(apiGroupsInfo)
for i := range apiGroupsInfo {
s.InstallAPIGroup(&apiGroupsInfo[i])
}

server := httptest.NewServer(s.HandlerContainer.ServeMux)
defer server.Close()
Expand Down
6 changes: 4 additions & 2 deletions pkg/master/master.go
Expand Up @@ -331,8 +331,10 @@ func (m *Master) InstallAPIs(c *Config) {
apiGroupsInfo = append(apiGroupsInfo, apiGroupInfo)
}

if err := m.InstallAPIGroups(apiGroupsInfo); err != nil {
glog.Fatalf("Error in registering group versions: %v", err)
for i := range apiGroupsInfo {
if err := m.InstallAPIGroup(&apiGroupsInfo[i]); err != nil {
glog.Fatalf("Error in registering group versions: %v", err)
}
}
}

Expand Down