Cleanup debug logging in Bitbucket Server remote

This commit is contained in:
Ivan Babrou 2016-09-01 17:10:35 +01:00
parent 31a0fd0eed
commit 113c63bf8e
No known key found for this signature in database
GPG key ID: DBF6C142408CB4F0
2 changed files with 11 additions and 22 deletions

View file

@ -4,15 +4,14 @@ import (
"crypto/md5"
"encoding/hex"
"fmt"
log "github.com/Sirupsen/logrus"
"github.com/drone/drone/model"
"github.com/drone/drone/remote/bitbucketserver/internal"
"github.com/mrjones/oauth"
"net/url"
"strings"
"time"
)
"github.com/drone/drone/model"
"github.com/drone/drone/remote/bitbucketserver/internal"
"github.com/mrjones/oauth"
)
const (
statusPending = "INPROGRESS"
@ -83,7 +82,6 @@ func convertRepo(from *internal.Repo) *model.Repo {
repo.Link = item.Href
}
}
log.Debug(fmt.Printf("Repo: %+v\n", repo))
return &repo
}
@ -152,6 +150,5 @@ func avatarLink(email string) string {
hasher.Write([]byte(strings.ToLower(email)))
emailHash := fmt.Sprintf("%v", hex.EncodeToString(hasher.Sum(nil)))
avatarURL := fmt.Sprintf("https://www.gravatar.com/avatar/%s.jpg", emailHash)
log.Debug(avatarURL)
return avatarURL
}

View file

@ -4,13 +4,14 @@ import (
"bytes"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"strconv"
log "github.com/Sirupsen/logrus"
"github.com/drone/drone/model"
"github.com/mrjones/oauth"
"io/ioutil"
"net/http"
"io"
)
const (
@ -35,7 +36,6 @@ func NewClientWithToken(url string, consumer *oauth.Consumer, AccessToken string
var token oauth.AccessToken
token.Token = AccessToken
client, err := consumer.MakeHttpClient(&token)
log.Debug(fmt.Printf("Create client: %+v %s\n", token, url))
if err != nil {
log.Error(err)
}
@ -109,7 +109,6 @@ func (c *Client) FindRepoPerms(owner string, repo string) (*model.Perm, error) {
perms.Admin = true
}
perms.Pull = true
log.Debug(fmt.Printf("Perms: %+v\n", perms))
return perms, nil
}
@ -160,7 +159,6 @@ func (c *Client) doPut(url string, body []byte) error {
return nil
}
//Helper function to help create the hook
func (c *Client) doPost(url string, status *BuildStatus) error {
// write it to the body of the request.
@ -182,10 +180,6 @@ func (c *Client) doPost(url string, status *BuildStatus) error {
return nil
}
//Helper function to do delete on the hook
func (c *Client) doDelete(url string) error {
request, err := http.NewRequest("DELETE", url, nil)
@ -201,7 +195,6 @@ func (c *Client) doDelete(url string) error {
func (c *Client) paginatedRepos(start int) ([]*Repo, error) {
limit := 1000
requestUrl := fmt.Sprintf(pathRepos, c.base, strconv.Itoa(start), strconv.Itoa(limit))
log.Debugf("request :%s", requestUrl)
response, err := c.client.Get(requestUrl)
if err != nil {
return nil, err
@ -212,13 +205,12 @@ func (c *Client) paginatedRepos(start int) ([]*Repo, error) {
if err != nil {
return nil, err
}
log.Debugf("repoResponse: %+v", repoResponse)
if(!repoResponse.IsLastPage){
reposList, err := c.paginatedRepos(start + limit);
if !repoResponse.IsLastPage {
reposList, err := c.paginatedRepos(start + limit)
if err != nil {
return nil, err
}
repoResponse.Values = append(repoResponse.Values, reposList...)
}
return repoResponse.Values, nil
}
}