refactor: openpitrix module
Signed-off-by: hongming <talonwan@yunify.com>
This commit is contained in:
@@ -250,7 +250,7 @@ func (c *Config) stripEmptyOptions() {
|
||||
c.LdapOptions = nil
|
||||
}
|
||||
|
||||
if c.OpenPitrixOptions != nil && c.OpenPitrixOptions.APIServer == "" {
|
||||
if c.OpenPitrixOptions != nil && len(c.OpenPitrixOptions.Validate()) > 0 {
|
||||
c.OpenPitrixOptions = nil
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"io/ioutil"
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/alerting"
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/devops"
|
||||
esclient "kubesphere.io/kubesphere/pkg/simple/client/elasticsearch"
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/elasticsearch"
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/k8s"
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/kubesphere"
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/ldap"
|
||||
@@ -79,8 +79,12 @@ func newTestConfig() *Config {
|
||||
Bucket: "ssss",
|
||||
},
|
||||
OpenPitrixOptions: &openpitrix.OpenPitrixOptions{
|
||||
APIServer: "http://api-gateway.openpitrix-system.svc",
|
||||
Token: "ABCDEFGHIJKLMN",
|
||||
RuntimeManagerEndpoint: "openpitrix-hyperpitrix.openpitrix-system.svc:9103",
|
||||
ClusterManagerEndpoint: "openpitrix-hyperpitrix.openpitrix-system.svc:9104",
|
||||
RepoManagerEndpoint: "openpitrix-hyperpitrix.openpitrix-system.svc:9101",
|
||||
AppManagerEndpoint: "openpitrix-hyperpitrix.openpitrix-system.svc:9102",
|
||||
CategoryManagerEndpoint: "openpitrix-hyperpitrix.openpitrix-system.svc:9113",
|
||||
AttachmentManagerEndpoint: "openpitrix-hyperpitrix.openpitrix-system.svc:9122",
|
||||
},
|
||||
MonitoringOptions: &prometheus.PrometheusOptions{
|
||||
Endpoint: "http://prometheus.kubesphere-monitoring-system.svc",
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
package errors
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/emicklei/go-restful"
|
||||
"net/http"
|
||||
)
|
||||
@@ -42,20 +40,6 @@ func New(message string) Error {
|
||||
return Error{Message: message}
|
||||
}
|
||||
|
||||
func Parse(data []byte) error {
|
||||
var j map[string]string
|
||||
err := json.Unmarshal(data, &j)
|
||||
if err != nil {
|
||||
return errors.New(string(data))
|
||||
} else if message := j["message"]; message != "" {
|
||||
return errors.New(message)
|
||||
} else if message := j["Error"]; message != "" {
|
||||
return errors.New(message)
|
||||
} else {
|
||||
return errors.New(string(data))
|
||||
}
|
||||
}
|
||||
|
||||
func ParseSvcErr(err error, resp *restful.Response) {
|
||||
if svcErr, ok := err.(restful.ServiceError); ok {
|
||||
resp.WriteServiceError(svcErr.Code, svcErr)
|
||||
|
||||
Reference in New Issue
Block a user