devlopment branch (#1736)
This commit is contained in:
8
pkg/simple/client/sonarqube/interface.go
Normal file
8
pkg/simple/client/sonarqube/interface.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package sonarqube
|
||||
|
||||
type Interface interface {
|
||||
//
|
||||
GetIssues()
|
||||
|
||||
//
|
||||
}
|
||||
@@ -4,39 +4,35 @@ import (
|
||||
"github.com/spf13/pflag"
|
||||
)
|
||||
|
||||
type SonarQubeOptions struct {
|
||||
type Options struct {
|
||||
Host string `json:",omitempty" yaml:"host" description:"SonarQube service host address"`
|
||||
Token string `json:",omitempty" yaml:"token" description:"SonarQube service token"`
|
||||
}
|
||||
|
||||
func NewSonarQubeOptions() *SonarQubeOptions {
|
||||
return &SonarQubeOptions{
|
||||
func NewSonarQubeOptions() *Options {
|
||||
return &Options{
|
||||
Host: "",
|
||||
Token: "",
|
||||
}
|
||||
}
|
||||
|
||||
func NewDefaultSonarQubeOptions() *SonarQubeOptions {
|
||||
return NewSonarQubeOptions()
|
||||
}
|
||||
|
||||
func (s *SonarQubeOptions) Validate() []error {
|
||||
errors := []error{}
|
||||
func (s *Options) Validate() []error {
|
||||
var errors []error
|
||||
|
||||
return errors
|
||||
}
|
||||
|
||||
func (s *SonarQubeOptions) ApplyTo(options *SonarQubeOptions) {
|
||||
func (s *Options) ApplyTo(options *Options) {
|
||||
if s.Host != "" {
|
||||
options.Host = s.Host
|
||||
options.Token = s.Token
|
||||
}
|
||||
}
|
||||
|
||||
func (s *SonarQubeOptions) AddFlags(fs *pflag.FlagSet) {
|
||||
fs.StringVar(&s.Host, "sonarqube-host", s.Host, ""+
|
||||
func (s *Options) AddFlags(fs *pflag.FlagSet, c *Options) {
|
||||
fs.StringVar(&s.Host, "sonarqube-host", c.Host, ""+
|
||||
"Sonarqube service address, if left empty, following sonarqube options will be ignored.")
|
||||
|
||||
fs.StringVar(&s.Token, "sonarqube-token", s.Token, ""+
|
||||
fs.StringVar(&s.Token, "sonarqube-token", c.Token, ""+
|
||||
"Sonarqube service access token.")
|
||||
}
|
||||
|
||||
@@ -7,11 +7,11 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
type SonarQubeClient struct {
|
||||
type Client struct {
|
||||
client *sonargo.Client
|
||||
}
|
||||
|
||||
func NewSonarQubeClient(options *SonarQubeOptions) (*SonarQubeClient, error) {
|
||||
func NewSonarQubeClient(options *Options) (*Client, error) {
|
||||
var endpoint string
|
||||
|
||||
if strings.HasSuffix(options.Host, "/") {
|
||||
@@ -26,10 +26,10 @@ func NewSonarQubeClient(options *SonarQubeOptions) (*SonarQubeClient, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &SonarQubeClient{client: sonar}, err
|
||||
return &Client{client: sonar}, err
|
||||
}
|
||||
|
||||
func NewSonarQubeClientOrDie(options *SonarQubeOptions) *SonarQubeClient {
|
||||
func NewSonarQubeClientOrDie(options *Options) *Client {
|
||||
var endpoint string
|
||||
|
||||
if strings.HasSuffix(options.Host, "/") {
|
||||
@@ -44,11 +44,11 @@ func NewSonarQubeClientOrDie(options *SonarQubeOptions) *SonarQubeClient {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return &SonarQubeClient{client: sonar}
|
||||
return &Client{client: sonar}
|
||||
}
|
||||
|
||||
// return sonarqube client
|
||||
// Also we can wrap some methods to avoid direct use sonar client
|
||||
func (s *SonarQubeClient) SonarQube() *sonargo.Client {
|
||||
func (s *Client) SonarQube() *sonargo.Client {
|
||||
return s.client
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user