using fmt.Sprintf for string interpolation.

This commit is contained in:
Joachim Hill-Grannec 2016-04-20 13:14:48 -07:00
parent 95b1f347ba
commit 06003bfc87

View file

@ -97,7 +97,7 @@ func (bs *BitbucketServer) Login(res http.ResponseWriter, req *http.Request) (*m
log.Error(err)
}
response, err := client.Get(bs.URL + "/plugins/servlet/applinks/whoami")
response, err := client.Get(fmt.Sprintf("%s/plugins/servlet/applinks/whoami", bs.URL))
if err != nil {
log.Error(err)
}
@ -105,7 +105,7 @@ func (bs *BitbucketServer) Login(res http.ResponseWriter, req *http.Request) (*m
bits, err := ioutil.ReadAll(response.Body)
userName := string(bits)
response1, err := client.Get(bs.URL + "/rest/api/1.0/users/" + userName)
response1, err := client.Get(fmt.Sprintf("%s/rest/api/1.0/users/%s",bs.URL, userName))
contents, err := ioutil.ReadAll(response1.Body)
defer response1.Body.Close()
var mUser User
@ -134,7 +134,7 @@ func (bs *BitbucketServer) Repo(u *model.User, owner, name string) (*model.Repo,
client := NewClientWithToken(&bs.Consumer, u.Token)
url := bs.URL + "/rest/api/1.0/projects/" + owner + "/repos/" + name
url := fmt.Sprintf("%s/rest/api/projects/%s/repos/%s",bs.URL,owner,name)
log.Info("Trying to get " + url)
response, err := client.Get(url)
if err != nil {
@ -165,7 +165,7 @@ func (bs *BitbucketServer) Repo(u *model.User, owner, name string) (*model.Repo,
repo.Name = bsRepo.Slug
repo.Owner = bsRepo.Project.Key
repo.AllowPush = true
repo.FullName = bsRepo.Project.Key + "/" + bsRepo.Slug
repo.FullName = fmt.Sprintf("%s/%s",bsRepo.Project.Key,bsRepo.Slug)
repo.Branch = "master"
repo.Kind = model.RepoGit
@ -178,7 +178,7 @@ func (bs *BitbucketServer) Repos(u *model.User) ([]*model.RepoLite, error) {
client := NewClientWithToken(&bs.Consumer, u.Token)
response, err := client.Get(bs.URL + "/rest/api/1.0/repos?limit=10000")
response, err := client.Get(fmt.Sprintf("%s/rest/api/1.0/repos?limit=10000",bs.URL))
if err != nil {
log.Error(err)
}
@ -296,7 +296,7 @@ func (bs *BitbucketServer) Hook(r *http.Request) (*model.Repo, *model.Build, err
repo.AllowDeploy = false
repo.AllowPull = false
repo.AllowPush = true
repo.FullName = hookPost.Repository.Project.Key + "/" + hookPost.Repository.Slug
repo.FullName = fmt.Sprintf("%s/%s",hookPost.Repository.Project.Key,hookPost.Repository.Slug)
repo.Branch = "master"
repo.Kind = model.RepoGit