cluster clusters

This commit is contained in:
LiHui
2022-05-20 11:53:51 +08:00
parent 49cc977cf0
commit 32b85cd625
18 changed files with 81 additions and 65 deletions

View File

@@ -17,6 +17,7 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
"kubesphere.io/kubesphere/pkg/utils/clusterclient"
"math"
"net/url"
"strconv"
@@ -50,7 +51,7 @@ type openpitrixHandler struct {
openpitrix openpitrix.Interface
}
func newOpenpitrixHandler(ksInformers informers.InformerFactory, ksClient versioned.Interface, option *openpitrixoptions.Options, stopCh <-chan struct{}) *openpitrixHandler {
func newOpenpitrixHandler(ksInformers informers.InformerFactory, ksClient versioned.Interface, option *openpitrixoptions.Options, cc clusterclient.ClusterClients, stopCh <-chan struct{}) *openpitrixHandler {
var s3Client s3.Interface
if option != nil && option.S3Options != nil && len(option.S3Options.Endpoint) != 0 {
var err error
@@ -61,7 +62,7 @@ func newOpenpitrixHandler(ksInformers informers.InformerFactory, ksClient versio
}
return &openpitrixHandler{
openpitrix.NewOpenpitrixOperator(ksInformers, ksClient, s3Client, stopCh),
openpitrix.NewOpenpitrixOperator(ksInformers, ksClient, s3Client, cc, stopCh),
}
}

View File

@@ -14,6 +14,7 @@ limitations under the License.
package v1
import (
"kubesphere.io/kubesphere/pkg/utils/clusterclient"
"net/http"
restful "github.com/emicklei/go-restful"
@@ -38,11 +39,11 @@ const (
var GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"}
func AddToContainer(c *restful.Container, ksInfomrers informers.InformerFactory, ksClient versioned.Interface, options *openpitrixoptions.Options, stopCh <-chan struct{}) error {
func AddToContainer(c *restful.Container, ksInfomrers informers.InformerFactory, ksClient versioned.Interface, options *openpitrixoptions.Options, cc clusterclient.ClusterClients, stopCh <-chan struct{}) error {
mimePatch := []string{restful.MIME_JSON, runtime.MimeJsonPatchJson, runtime.MimeMergePatchJson}
webservice := runtime.NewWebService(GroupVersion)
handler := newOpenpitrixHandler(ksInfomrers, ksClient, options, stopCh)
handler := newOpenpitrixHandler(ksInfomrers, ksClient, options, cc, stopCh)
webservice.Route(webservice.POST("/repos").
To(handler.CreateRepo).