未验证 提交 c80a17f4 编写于 作者: R runzexia

sonar handler init

上级 9ec99d1a
......@@ -134,6 +134,14 @@ func (s *ServerRunOptions) NewAPIServer(stopCh <-chan struct{}) (*apiserver.APIS
apiServer.DevopsClient = devopsClient
}
if s.SonarQubeOptions.Host != "" {
sonarClient, err := sonarqube.NewSonarQubeClient(s.SonarQubeOptions)
if err != nil {
return nil, err
}
apiServer.SonarClient = sonarqube.NewSonar(sonarClient.SonarQube())
}
if s.LdapOptions.Host != "" {
if s.LdapOptions.Host == fakeInterface && s.DebugMode {
apiServer.LdapClient = ldap.NewSimpleLdap()
......
......@@ -31,10 +31,9 @@ func NewProjectPipelineHandler(devopsClient devopsClient.Interface, dbClient *my
}
}
func NewPipelineSonarHandler(devopsClient devopsClient.Interface, dbClient *mysql.Database, sonarClient sonarqube.SonarInterface) PipelineSonarHandler {
func NewPipelineSonarHandler(devopsClient devopsClient.Interface, sonarClient sonarqube.SonarInterface) PipelineSonarHandler {
return PipelineSonarHandler{
pipelineSonarGetter: devops.NewPipelineSonarGetter(devopsClient, sonarClient),
projectOperator: devops.NewProjectOperator(dbClient),
}
}
......
......@@ -690,9 +690,9 @@ func AddPipelineToWebService(webservice *restful.WebService, devopsClient devops
}
func AddSonarToWebService(webservice *restful.WebService, devopsClient devops.Interface, dbClient *mysql.Database, sonarClient sonarqube.SonarInterface) error {
sonarEnable := devopsClient != nil && dbClient != nil && sonarClient != nil
sonarEnable := devopsClient != nil && sonarClient != nil
if sonarEnable {
sonarHandler := NewPipelineSonarHandler(devopsClient, dbClient, sonarClient)
sonarHandler := NewPipelineSonarHandler(devopsClient, sonarClient)
webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipeline}/sonarstatus").
To(sonarHandler.GetPipelineSonarStatusHandler).
Doc("Get the sonar quality information for the specified pipeline of the DevOps project. More info: https://docs.sonarqube.org/7.4/user-guide/metric-definitions/").
......
......@@ -14,18 +14,12 @@ limitations under the License.
package jenkins
import (
"k8s.io/klog"
"kubesphere.io/kubesphere/pkg/simple/client/devops"
)
func NewDevopsClient(options *Options) (devops.Interface, error) {
jenkins := CreateJenkins(nil, options.Host, options.MaxConnections, options.Username, options.Password)
jenkins, err := jenkins.Init()
if err != nil {
klog.Errorf("failed to connecto to jenkins role, %+v", err)
return nil, err
}
return jenkins, nil
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册