diff --git a/cmd/ks-apiserver/app/options/options.go b/cmd/ks-apiserver/app/options/options.go index 7b008e676a982fb5ba8817caf558e6d19b453d8d..431a265320dcca05f8b9d422ec2138074d4ac00e 100644 --- a/cmd/ks-apiserver/app/options/options.go +++ b/cmd/ks-apiserver/app/options/options.go @@ -177,6 +177,14 @@ func (s *ServerRunOptions) NewAPIServer(stopCh <-chan struct{}) (*apiserver.APIS } } + if s.OpenPitrixOptions != nil { + opClient, err := openpitrix.NewClient(s.OpenPitrixOptions) + if err != nil { + return nil, err + } + apiServer.OpenpitrixClient = opClient + } + server := &http.Server{ Addr: fmt.Sprintf(":%d", s.GenericServerRunOptions.InsecurePort), } diff --git a/pkg/kapis/openpitrix/v1/register.go b/pkg/kapis/openpitrix/v1/register.go index 7a7e290fd1c0e84f982d1a4a99a2d8225c210f32..c75b71e67fab246649a73f266312e56801201064 100644 --- a/pkg/kapis/openpitrix/v1/register.go +++ b/pkg/kapis/openpitrix/v1/register.go @@ -40,7 +40,9 @@ const ( var GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"} func AddToContainer(c *restful.Container, factory informers.InformerFactory, op op.Client) error { - + if op == nil { + return nil + } mimePatch := []string{restful.MIME_JSON, runtime.MimeMergePatchJson, runtime.MimeJsonPatchJson} webservice := runtime.NewWebService(GroupVersion) handler := newOpenpitrixHandler(factory, op)