@@ -19,15 +19,15 @@ import (
1919 "github.com/runatlantis/atlantis/server/logging"
2020)
2121
22- // AzureDevopsClient represents an Azure DevOps VCS client
23- type AzureDevopsClient struct {
22+ // Client represents an Azure DevOps VCS client
23+ type Client struct {
2424 Client * azuredevops.Client
2525 ctx context.Context
2626 UserName string
2727}
2828
29- // NewAzureDevopsClient returns a valid Azure DevOps client.
30- func NewAzureDevopsClient (hostname string , userName string , token string ) (* AzureDevopsClient , error ) {
29+ // NewClient returns a valid Azure DevOps client.
30+ func New (hostname string , userName string , token string ) (* Client , error ) {
3131 tp := azuredevops.BasicAuthTransport {
3232 Username : "" ,
3333 Password : strings .TrimSpace (token ),
@@ -48,7 +48,7 @@ func NewAzureDevopsClient(hostname string, userName string, token string) (*Azur
4848 adClient .BaseURL = * base
4949 }
5050
51- client := & AzureDevopsClient {
51+ client := & Client {
5252 Client : adClient ,
5353 UserName : userName ,
5454 ctx : context .Background (),
@@ -59,7 +59,7 @@ func NewAzureDevopsClient(hostname string, userName string, token string) (*Azur
5959
6060// GetModifiedFiles returns the names of files that were modified in the merge request
6161// relative to the repo root, e.g. parent/child/file.txt.
62- func (g * AzureDevopsClient ) GetModifiedFiles (logger logging.SimpleLogging , repo models.Repo , pull models.PullRequest ) ([]string , error ) {
62+ func (g * Client ) GetModifiedFiles (logger logging.SimpleLogging , repo models.Repo , pull models.PullRequest ) ([]string , error ) {
6363 var files []string
6464
6565 owner , project , repoName := SplitAzureDevopsRepoFullName (repo .FullName )
@@ -114,7 +114,7 @@ func (g *AzureDevopsClient) GetModifiedFiles(logger logging.SimpleLogging, repo
114114//
115115// If comment length is greater than the max comment length we split into
116116// multiple comments.
117- func (g * AzureDevopsClient ) CreateComment (logger logging.SimpleLogging , repo models.Repo , pullNum int , comment string , command string ) error { //nolint: revive
117+ func (g * Client ) CreateComment (logger logging.SimpleLogging , repo models.Repo , pullNum int , comment string , command string ) error { //nolint: revive
118118 sepEnd := "\n ```\n </details>" +
119119 "\n <br>\n \n **Warning**: Output length greater than max comment size. Continued in next comment."
120120 sepStart := "Continued from previous comment.\n <details><summary>Show Output</summary>\n \n " +
@@ -149,17 +149,17 @@ func (g *AzureDevopsClient) CreateComment(logger logging.SimpleLogging, repo mod
149149 return nil
150150}
151151
152- func (g * AzureDevopsClient ) ReactToComment (logger logging.SimpleLogging , repo models.Repo , pullNum int , commentID int64 , reaction string ) error { //nolint: revive
152+ func (g * Client ) ReactToComment (logger logging.SimpleLogging , repo models.Repo , pullNum int , commentID int64 , reaction string ) error { //nolint: revive
153153 return nil
154154}
155155
156- func (g * AzureDevopsClient ) HidePrevCommandComments (logger logging.SimpleLogging , repo models.Repo , pullNum int , command string , dir string ) error { //nolint: revive
156+ func (g * Client ) HidePrevCommandComments (logger logging.SimpleLogging , repo models.Repo , pullNum int , command string , dir string ) error { //nolint: revive
157157 return nil
158158}
159159
160160// PullIsApproved returns true if the merge request was approved by another reviewer.
161161// https://docs.microsoft.com/en-us/azure/devops/repos/git/branch-policies?view=azure-devops#require-a-minimum-number-of-reviewers
162- func (g * AzureDevopsClient ) PullIsApproved (logger logging.SimpleLogging , repo models.Repo , pull models.PullRequest ) (approvalStatus models.ApprovalStatus , err error ) {
162+ func (g * Client ) PullIsApproved (logger logging.SimpleLogging , repo models.Repo , pull models.PullRequest ) (approvalStatus models.ApprovalStatus , err error ) {
163163 owner , project , repoName := SplitAzureDevopsRepoFullName (repo .FullName )
164164
165165 opts := azuredevops.PullRequestGetOptions {
@@ -189,13 +189,13 @@ func (g *AzureDevopsClient) PullIsApproved(logger logging.SimpleLogging, repo mo
189189 return approvalStatus , nil
190190}
191191
192- func (g * AzureDevopsClient ) DiscardReviews (logger logging.SimpleLogging , repo models.Repo , pull models.PullRequest ) error { //nolint: revive
192+ func (g * Client ) DiscardReviews (logger logging.SimpleLogging , repo models.Repo , pull models.PullRequest ) error { //nolint: revive
193193 // TODO implement
194194 return nil
195195}
196196
197197// PullIsMergeable returns true if the merge request can be merged.
198- func (g * AzureDevopsClient ) PullIsMergeable (logger logging.SimpleLogging , repo models.Repo , pull models.PullRequest , _ string , _ []string ) (models.MergeableStatus , error ) { //nolint: revive
198+ func (g * Client ) PullIsMergeable (logger logging.SimpleLogging , repo models.Repo , pull models.PullRequest , _ string , _ []string ) (models.MergeableStatus , error ) { //nolint: revive
199199 owner , project , repoName := SplitAzureDevopsRepoFullName (repo .FullName )
200200
201201 opts := azuredevops.PullRequestGetOptions {IncludeWorkItemRefs : true }
@@ -256,7 +256,7 @@ func (g *AzureDevopsClient) PullIsMergeable(logger logging.SimpleLogging, repo m
256256}
257257
258258// GetPullRequest returns the pull request.
259- func (g * AzureDevopsClient ) GetPullRequest (logger logging.SimpleLogging , repo models.Repo , num int ) (* azuredevops.GitPullRequest , error ) {
259+ func (g * Client ) GetPullRequest (logger logging.SimpleLogging , repo models.Repo , num int ) (* azuredevops.GitPullRequest , error ) {
260260 opts := azuredevops.PullRequestGetOptions {
261261 IncludeWorkItemRefs : true ,
262262 }
@@ -266,7 +266,7 @@ func (g *AzureDevopsClient) GetPullRequest(logger logging.SimpleLogging, repo mo
266266}
267267
268268// UpdateStatus updates the build status of a commit.
269- func (g * AzureDevopsClient ) UpdateStatus (logger logging.SimpleLogging , repo models.Repo , pull models.PullRequest , state models.CommitStatus , src string , description string , url string ) error {
269+ func (g * Client ) UpdateStatus (logger logging.SimpleLogging , repo models.Repo , pull models.PullRequest , state models.CommitStatus , src string , description string , url string ) error {
270270 adState := azuredevops .GitError .String ()
271271 switch state {
272272 case models .PendingCommitStatus :
@@ -280,7 +280,7 @@ func (g *AzureDevopsClient) UpdateStatus(logger logging.SimpleLogging, repo mode
280280 logger .Info ("Updating Azure DevOps commit status for '%s' to '%s'" , src , adState )
281281
282282 status := azuredevops.GitPullRequestStatus {}
283- status .Context = GitStatusContextFromSrc (src )
283+ status .Context = gitStatusContextFromSrc (src )
284284 status .Description = & description
285285 status .State = & adState
286286 if url != "" {
@@ -334,7 +334,7 @@ func (g *AzureDevopsClient) UpdateStatus(logger logging.SimpleLogging, repo mode
334334// If the user has set a branch policy that disallows no fast-forward, the merge will fail
335335// until we handle branch policies
336336// https://docs.microsoft.com/en-us/azure/devops/repos/git/branch-policies?view=azure-devops
337- func (g * AzureDevopsClient ) MergePull (logger logging.SimpleLogging , pull models.PullRequest , pullOptions models.PullRequestOptions ) error {
337+ func (g * Client ) MergePull (logger logging.SimpleLogging , pull models.PullRequest , pullOptions models.PullRequestOptions ) error {
338338 owner , project , repoName := SplitAzureDevopsRepoFullName (pull .BaseRepo .FullName )
339339 descriptor := "Atlantis Terraform Pull Request Automation"
340340
@@ -392,7 +392,7 @@ func (g *AzureDevopsClient) MergePull(logger logging.SimpleLogging, pull models.
392392}
393393
394394// MarkdownPullLink specifies the string used in a pull request comment to reference another pull request.
395- func (g * AzureDevopsClient ) MarkdownPullLink (pull models.PullRequest ) (string , error ) {
395+ func (g * Client ) MarkdownPullLink (pull models.PullRequest ) (string , error ) {
396396 return fmt .Sprintf ("!%d" , pull .Num ), nil
397397}
398398
@@ -421,23 +421,23 @@ func SplitAzureDevopsRepoFullName(repoFullName string) (owner string, project st
421421}
422422
423423// GetTeamNamesForUser returns the names of the teams or groups that the user belongs to (in the organization the repository belongs to).
424- func (g * AzureDevopsClient ) GetTeamNamesForUser (_ logging.SimpleLogging , _ models.Repo , _ models.User ) ([]string , error ) { //nolint: revive
424+ func (g * Client ) GetTeamNamesForUser (_ logging.SimpleLogging , _ models.Repo , _ models.User ) ([]string , error ) { //nolint: revive
425425 return nil , nil
426426}
427427
428- func (g * AzureDevopsClient ) SupportsSingleFileDownload (repo models.Repo ) bool { //nolint: revive
428+ func (g * Client ) SupportsSingleFileDownload (repo models.Repo ) bool { //nolint: revive
429429 return false
430430}
431431
432- func (g * AzureDevopsClient ) GetFileContent (_ logging.SimpleLogging , _ models.Repo , _ string , _ string ) (bool , []byte , error ) { //nolint: revive
432+ func (g * Client ) GetFileContent (_ logging.SimpleLogging , _ models.Repo , _ string , _ string ) (bool , []byte , error ) { //nolint: revive
433433 return false , []byte {}, fmt .Errorf ("not implemented" )
434434}
435435
436436// GitStatusContextFromSrc parses an Atlantis formatted src string into a context suitable
437437// for the status update API. In the AzureDevops branch policy UI there is a single string
438438// field used to drive these contexts where all text preceding the final '/' character is
439439// treated as the 'genre'.
440- func GitStatusContextFromSrc (src string ) * azuredevops.GitStatusContext {
440+ func gitStatusContextFromSrc (src string ) * azuredevops.GitStatusContext {
441441 lastSlashIdx := strings .LastIndex (src , "/" )
442442 genre := "Atlantis Bot"
443443 name := src
@@ -452,10 +452,10 @@ func GitStatusContextFromSrc(src string) *azuredevops.GitStatusContext {
452452 }
453453}
454454
455- func (g * AzureDevopsClient ) GetCloneURL (_ logging.SimpleLogging , VCSHostType models.VCSHostType , repo string ) (string , error ) { //nolint: revive
455+ func (g * Client ) GetCloneURL (_ logging.SimpleLogging , VCSHostType models.VCSHostType , repo string ) (string , error ) { //nolint: revive
456456 return "" , fmt .Errorf ("not yet implemented" )
457457}
458458
459- func (g * AzureDevopsClient ) GetPullLabels (_ logging.SimpleLogging , _ models.Repo , _ models.PullRequest ) ([]string , error ) {
459+ func (g * Client ) GetPullLabels (_ logging.SimpleLogging , _ models.Repo , _ models.PullRequest ) ([]string , error ) {
460460 return nil , fmt .Errorf ("not yet implemented" )
461461}
0 commit comments