diff --git a/go.mod b/go.mod index 491561230..05baf990e 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/runatlantis/atlantis go 1.14 require ( - github.com/Laisky/graphql v1.0.4 + github.com/Laisky/graphql v1.0.5 github.com/Masterminds/sprig/v3 v3.1.0 github.com/agext/levenshtein v1.2.3 // indirect github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a // indirect @@ -27,9 +27,8 @@ require ( github.com/hashicorp/hcl/v2 v2.6.0 // indirect github.com/hashicorp/terraform-config-inspect v0.0.0-20200806211835-c481b8bfa41e github.com/inconshreveable/mousetrap v1.0.0 // indirect - github.com/magiconair/properties v1.8.1 // indirect - github.com/mcdafydd/go-azuredevops v0.12.0 github.com/leodido/go-urn v1.2.0 // indirect + github.com/mcdafydd/go-azuredevops v0.12.0 github.com/microcosm-cc/bluemonday v1.0.1 github.com/mitchellh/colorstring v0.0.0-20150917214807-8631ce90f286 github.com/mitchellh/go-homedir v1.0.0 diff --git a/go.sum b/go.sum index aa52ba558..f90db7dc8 100644 --- a/go.sum +++ b/go.sum @@ -20,8 +20,8 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7 github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/Laisky/graphql v1.0.4 h1:GQF3eKXK1m+viDIvafW7P3zB8qY0PxHwrNUlmonhIC8= -github.com/Laisky/graphql v1.0.4/go.mod h1:8nTxZuOwua8Ga6EFL1HuF9rNiJtvSEnwGXGLnW+9i9k= +github.com/Laisky/graphql v1.0.5 h1:8eJ7mrXKVkKxZ+Nw1HPs3iQPVNxXGctysqTEY0lNBlc= +github.com/Laisky/graphql v1.0.5/go.mod h1:ITUrUa/tkyD3MezVt4FKGGIGZokhG13kP8sImV86I1o= github.com/Masterminds/goutils v1.1.0 h1:zukEsf/1JZwCMgHiK3GZftabmxiCw4apj3a28RPBiVg= github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= github.com/Masterminds/semver/v3 v3.1.0 h1:Y2lUDsFKVRSYGojLJ1yLxSXdMmMYTYls0rCvoqmMUQk= @@ -139,7 +139,7 @@ github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORR github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/graph-gophers/graphql-go v0.0.0-20191115155744-f33e81362277/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= +github.com/graph-gophers/graphql-go v0.0.0-20200309224638-dae41bde9ef9/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= @@ -230,8 +230,8 @@ github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/mcdafydd/go-azuredevops v0.11.1 h1:NO4wlkyFpdxqZZzNzn5m3fJc4box0jnkC8LBhAaPXeA= -github.com/mcdafydd/go-azuredevops v0.11.1/go.mod h1:B4UDyn7WEj1/97f45j3VnzEfkWKe05+/dCcAPdOET4A= +github.com/mcdafydd/go-azuredevops v0.12.0 h1:CmG9uheFF6M3WnSykVNVLxR7zXrtg4p3pE2/lNDnPEE= +github.com/mcdafydd/go-azuredevops v0.12.0/go.mod h1:B4UDyn7WEj1/97f45j3VnzEfkWKe05+/dCcAPdOET4A= github.com/microcosm-cc/bluemonday v1.0.1 h1:SIYunPjnlXcW+gVfvm0IlSeR5U3WZUOLfVmqg85Go44= github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= diff --git a/vendor/github.com/Laisky/graphql/README.md b/vendor/github.com/Laisky/graphql/README.md index 26e3ea8a7..372bee46f 100644 --- a/vendor/github.com/Laisky/graphql/README.md +++ b/vendor/github.com/Laisky/graphql/README.md @@ -14,6 +14,8 @@ Fully compatible with v0.0.0-2018123106124 You can simply replace `github.com/shurcooL/graphql` --> `github.com/Laisky/graphql` to access new features. +* [GraphQL 学习笔记](https://blog.laisky.com/p/graphql/) + ## New Features ### Cache friendly diff --git a/vendor/github.com/Laisky/graphql/go.mod b/vendor/github.com/Laisky/graphql/go.mod index 765ab15ac..85c5d6197 100644 --- a/vendor/github.com/Laisky/graphql/go.mod +++ b/vendor/github.com/Laisky/graphql/go.mod @@ -3,6 +3,6 @@ module github.com/Laisky/graphql go 1.13 require ( - github.com/graph-gophers/graphql-go v0.0.0-20191115155744-f33e81362277 - github.com/stretchr/testify v1.4.0 // indirect + github.com/graph-gophers/graphql-go v0.0.0-20200309224638-dae41bde9ef9 + github.com/stretchr/testify v1.5.1 // indirect ) diff --git a/vendor/github.com/Laisky/graphql/go.sum b/vendor/github.com/Laisky/graphql/go.sum index 4c89b175e..2fdd6017b 100644 --- a/vendor/github.com/Laisky/graphql/go.sum +++ b/vendor/github.com/Laisky/graphql/go.sum @@ -1,14 +1,15 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/graph-gophers/graphql-go v0.0.0-20191115155744-f33e81362277 h1:E0whKxgp2ojts0FDgUA8dl62bmH0LxKanMoBr6MDTDM= -github.com/graph-gophers/graphql-go v0.0.0-20191115155744-f33e81362277/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= +github.com/graph-gophers/graphql-go v0.0.0-20200309224638-dae41bde9ef9 h1:kLnsdud6Fl1/7ZX/5oD23cqYAzBfuZBhNkGr2NvuEsU= +github.com/graph-gophers/graphql-go v0.0.0-20200309224638-dae41bde9ef9/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= diff --git a/vendor/github.com/Laisky/graphql/graphql.go b/vendor/github.com/Laisky/graphql/graphql.go index 414c3b1e5..605707973 100644 --- a/vendor/github.com/Laisky/graphql/graphql.go +++ b/vendor/github.com/Laisky/graphql/graphql.go @@ -11,11 +11,11 @@ import ( "github.com/Laisky/graphql/internal/jsonutil" ) -var ( - defaultClientHeaders = map[string]string{ +func defaultClientHeaders() map[string]string { + return map[string]string{ "Content-Type": "application/json", } -) +} // ClientOptFunc graphql client option type ClientOptFunc func(*Client) @@ -53,7 +53,7 @@ func NewClient(url string, httpClient *http.Client, opts ...ClientOptFunc) (c *C httpClient = http.DefaultClient } c = &Client{ - headers: defaultClientHeaders, + headers: defaultClientHeaders(), url: url, httpClient: httpClient, } @@ -146,7 +146,7 @@ func (c *Client) do(ctx context.Context, op operationType, v interface{}, variab } var out struct { Data *json.RawMessage - Errors errors + Errors Errors //Extensions interface{} // Unused. } err = json.NewDecoder(resp.Body).Decode(&out) @@ -167,20 +167,21 @@ func (c *Client) do(ctx context.Context, op operationType, v interface{}, variab return nil } -// errors represents the "errors" array in a response from a GraphQL server. +// Errors represents the "errors" array in a response from a GraphQL server. // If returned via error interface, the slice is expected to contain at least 1 element. // // Specification: https://facebook.github.io/graphql/#sec-Errors. -type errors []struct { +type Errors []struct { Message string Locations []struct { Line int Column int } + Extensions interface{} } // Error implements error interface. -func (e errors) Error() string { +func (e Errors) Error() string { return e[0].Message } diff --git a/vendor/github.com/mcdafydd/go-azuredevops/azuredevops/azuredevops-accessors.go b/vendor/github.com/mcdafydd/go-azuredevops/azuredevops/azuredevops-accessors.go index 8d3c414d1..7e4dd6cf8 100644 --- a/vendor/github.com/mcdafydd/go-azuredevops/azuredevops/azuredevops-accessors.go +++ b/vendor/github.com/mcdafydd/go-azuredevops/azuredevops/azuredevops-accessors.go @@ -1231,6 +1231,62 @@ func (g *GitCommitChanges) GetChangeCounts() map[string]int { return *g.ChangeCounts } +// GetAheadCount returns the AheadCount field if it's non-nil, zero value otherwise. +func (g *GitCommitDiffs) GetAheadCount() int { + if g == nil || g.AheadCount == nil { + return 0 + } + return *g.AheadCount +} + +// GetAllChangesIncluded returns the AllChangesIncluded field if it's non-nil, zero value otherwise. +func (g *GitCommitDiffs) GetAllChangesIncluded() bool { + if g == nil || g.AllChangesIncluded == nil { + return false + } + return *g.AllChangesIncluded +} + +// GetBaseCommit returns the BaseCommit field if it's non-nil, zero value otherwise. +func (g *GitCommitDiffs) GetBaseCommit() string { + if g == nil || g.BaseCommit == nil { + return "" + } + return *g.BaseCommit +} + +// GetBehindCount returns the BehindCount field if it's non-nil, zero value otherwise. +func (g *GitCommitDiffs) GetBehindCount() int { + if g == nil || g.BehindCount == nil { + return 0 + } + return *g.BehindCount +} + +// GetChangeCounts returns the ChangeCounts field if it's non-nil, zero value otherwise. +func (g *GitCommitDiffs) GetChangeCounts() map[VersionControlChangeType]int { + if g == nil || g.ChangeCounts == nil { + return map[VersionControlChangeType]int{} + } + return *g.ChangeCounts +} + +// GetCommonCommit returns the CommonCommit field if it's non-nil, zero value otherwise. +func (g *GitCommitDiffs) GetCommonCommit() string { + if g == nil || g.CommonCommit == nil { + return "" + } + return *g.CommonCommit +} + +// GetTargetCommit returns the TargetCommit field if it's non-nil, zero value otherwise. +func (g *GitCommitDiffs) GetTargetCommit() string { + if g == nil || g.TargetCommit == nil { + return "" + } + return *g.TargetCommit +} + // GetAuthor returns the Author field. func (g *GitCommitRef) GetAuthor() *GitUserDate { if g == nil { @@ -2911,6 +2967,158 @@ func (m *Message) GetText() string { return *m.Text } +// GetCreatedBy returns the CreatedBy field. +func (p *PolicyConfiguration) GetCreatedBy() *IdentityRef { + if p == nil { + return nil + } + return p.CreatedBy +} + +// GetCreatedDate returns the CreatedDate field if it's non-nil, zero value otherwise. +func (p *PolicyConfiguration) GetCreatedDate() string { + if p == nil || p.CreatedDate == nil { + return "" + } + return *p.CreatedDate +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (p *PolicyConfiguration) GetID() int { + if p == nil || p.ID == nil { + return 0 + } + return *p.ID +} + +// GetIsBlocking returns the IsBlocking field if it's non-nil, zero value otherwise. +func (p *PolicyConfiguration) GetIsBlocking() bool { + if p == nil || p.IsBlocking == nil { + return false + } + return *p.IsBlocking +} + +// GetIsDeleted returns the IsDeleted field if it's non-nil, zero value otherwise. +func (p *PolicyConfiguration) GetIsDeleted() bool { + if p == nil || p.IsDeleted == nil { + return false + } + return *p.IsDeleted +} + +// GetIsEnabled returns the IsEnabled field if it's non-nil, zero value otherwise. +func (p *PolicyConfiguration) GetIsEnabled() bool { + if p == nil || p.IsEnabled == nil { + return false + } + return *p.IsEnabled +} + +// GetRevision returns the Revision field if it's non-nil, zero value otherwise. +func (p *PolicyConfiguration) GetRevision() int { + if p == nil || p.Revision == nil { + return 0 + } + return *p.Revision +} + +// GetType returns the Type field. +func (p *PolicyConfiguration) GetType() *PolicyTypeRef { + if p == nil { + return nil + } + return p.Type +} + +// GetUrl returns the Url field if it's non-nil, zero value otherwise. +func (p *PolicyConfiguration) GetUrl() string { + if p == nil || p.Url == nil { + return "" + } + return *p.Url +} + +// GetArtifactID returns the ArtifactID field if it's non-nil, zero value otherwise. +func (p *PolicyEvaluationRecord) GetArtifactID() string { + if p == nil || p.ArtifactID == nil { + return "" + } + return *p.ArtifactID +} + +// GetCompletedDate returns the CompletedDate field if it's non-nil, zero value otherwise. +func (p *PolicyEvaluationRecord) GetCompletedDate() string { + if p == nil || p.CompletedDate == nil { + return "" + } + return *p.CompletedDate +} + +// GetConfiguration returns the Configuration field. +func (p *PolicyEvaluationRecord) GetConfiguration() *PolicyConfiguration { + if p == nil { + return nil + } + return p.Configuration +} + +// GetEvaluationID returns the EvaluationID field if it's non-nil, zero value otherwise. +func (p *PolicyEvaluationRecord) GetEvaluationID() string { + if p == nil || p.EvaluationID == nil { + return "" + } + return *p.EvaluationID +} + +// GetLinks returns the Links field if it's non-nil, zero value otherwise. +func (p *PolicyEvaluationRecord) GetLinks() map[string]Link { + if p == nil || p.Links == nil { + return map[string]Link{} + } + return *p.Links +} + +// GetStartedDate returns the StartedDate field if it's non-nil, zero value otherwise. +func (p *PolicyEvaluationRecord) GetStartedDate() string { + if p == nil || p.StartedDate == nil { + return "" + } + return *p.StartedDate +} + +// GetStatus returns the Status field if it's non-nil, zero value otherwise. +func (p *PolicyEvaluationRecord) GetStatus() string { + if p == nil || p.Status == nil { + return "" + } + return *p.Status +} + +// GetDisplayName returns the DisplayName field if it's non-nil, zero value otherwise. +func (p *PolicyTypeRef) GetDisplayName() string { + if p == nil || p.DisplayName == nil { + return "" + } + return *p.DisplayName +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (p *PolicyTypeRef) GetID() string { + if p == nil || p.ID == nil { + return "" + } + return *p.ID +} + +// GetUrl returns the Url field if it's non-nil, zero value otherwise. +func (p *PolicyTypeRef) GetUrl() string { + if p == nil || p.Url == nil { + return "" + } + return *p.Url +} + // GetDescription returns the Description field if it's non-nil, zero value otherwise. func (p *Project) GetDescription() string { if p == nil || p.Description == nil { diff --git a/vendor/github.com/mcdafydd/go-azuredevops/azuredevops/git.go b/vendor/github.com/mcdafydd/go-azuredevops/azuredevops/git.go index b07d53837..e899b93da 100644 --- a/vendor/github.com/mcdafydd/go-azuredevops/azuredevops/git.go +++ b/vendor/github.com/mcdafydd/go-azuredevops/azuredevops/git.go @@ -257,6 +257,18 @@ type GitPullRequestMergeOptions struct { DisableRenames *bool `json:"disableRenames,omitempty"` } +// GitCommitDiffs describes the difference between two commits +type GitCommitDiffs struct { + AheadCount *int `json:"aheadCount,omitempty"` + AllChangesIncluded *bool `json:"allChangesIncluded,omitempty"` + BaseCommit *string `json:"baseCommit,omitempty"` + BehindCount *int `json:"behindCount,omitempty"` + ChangeCounts *map[VersionControlChangeType]int `json:"changeCounts,omitempty"` + Changes []*GitChange `json:"changes,omitempty"` + CommonCommit *string `json:"commonCommit,omitempty"` + TargetCommit *string `json:"targetCommit,omitempty"` +} + // GitPullRequestMergeStrategy specifies the strategy used to merge the pull request // during completion. type GitPullRequestMergeStrategy int @@ -527,3 +539,27 @@ func (s *GitService) CreateStatus(ctx context.Context, owner, project, repoName, return r, resp, err } + +// GetDiffs finds the closest common commit (the merge base) between base and target commits, +// and get the diff between either the base and target commits or common and target commits. +// https://docs.microsoft.com/en-us/rest/api/azure/devops/git/diffs/get?view=azure-devops-rest-5.1 +func (s *GitService) GetDiffs(ctx context.Context, owner string, project string, repoName string, baseVersion string, targetVersion string) (*GitCommitDiffs, *http.Response, error) { + URL := fmt.Sprintf( + "%s/%s/_apis/git/repositories/%s/diffs/commits?api-version=5.1&baseVersion=%s&targetVersion=%s", + owner, + project, + repoName, + baseVersion, + targetVersion, + ) + + req, err := s.client.NewRequest("GET", URL, nil) + if err != nil { + return nil, nil, err + } + + r := new(GitCommitDiffs) + resp, err := s.client.Execute(ctx, req, r) + + return r, resp, err +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 11194a275..441dff083 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -10,7 +10,7 @@ cloud.google.com/go/internal/version cloud.google.com/go/storage # github.com/BurntSushi/toml v0.3.1 github.com/BurntSushi/toml -# github.com/Laisky/graphql v1.0.4 +# github.com/Laisky/graphql v1.0.5 ## explicit github.com/Laisky/graphql github.com/Laisky/graphql/ident @@ -201,10 +201,11 @@ github.com/konsorten/go-windows-terminal-sequences ## explicit github.com/leodido/go-urn # github.com/magiconair/properties v1.8.1 -## explicit github.com/magiconair/properties # github.com/mattn/go-colorable v0.0.9 github.com/mattn/go-colorable +# github.com/mattn/go-isatty v0.0.4 +github.com/mattn/go-isatty # github.com/mcdafydd/go-azuredevops v0.12.0 ## explicit github.com/mcdafydd/go-azuredevops/azuredevops