Git Product home page Git Product logo

sonargo's Introduction

sonargo

GitHub version GoDoc

Client of sonarqube api in golang

Compatibility

As sonarqube api is updated frequently, this client now only support v7.4. Forward compatibility is not guaranteed in this version (To be done).

Usage

import github.com/magicsong/sonargo/sonar

Construct a new Sonarqube client, then use the various services on the client to access different parts of the Sonarqube API. For example, to list all projects:

sonarURL := os.Getenv("SONAR_URL")
if sonarURL == "" {
    fmt.Println("Sonar URL has not been set")
    os.Exit(1)
}
client, err := sonargo.NewClient(sonarURL+"/api", "user", "password")
if err != nil {
    fmt.Println(err.Error())
    os.Exit(1)
}
//set options
opt := &ProjectsSearchOption{
    AnalyzedBefore:    "",
    OnProvisionedOnly: "",
    P:                 "",
    ProjectIds:        "",
    Projects:          "",
    Ps:                "",
    Q:                 "",
    Qualifiers:        "",
}
v, _, err := client.Projects.Search(opt)
if err != nil {
    fmt.Println(err.Error())
    os.Exit(1)
}
fmt.Print(v.Components[0])

Other services is also like Projects, using following steps:

  1. Get a client by use NewClient()
  2. Get the service by simply using dot. The service name is CamelCase of the name in sonarqube api
  3. Use functions of each service to do what you want to do

Notes

  • Most code in first release version is generated by code. So some naming is not suitable. See generate-go-for-sonarqube
  • Sonarqube community does not build a v7.4 docker image for public, so a v7.4 dockerfile is provided in build folder.

ToDo

  • Add godoc for each api
  • Add more tests
  • test forward compatibility

Author

宋雪涛 (Xuetao Song, [email protected])

Licence

Copyright 2018 MagicSong

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

sonargo's People

Contributors

fsmaia avatar magicsong avatar justusbunsi avatar saitho avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.