Compare commits

...

29 commits

Author SHA1 Message Date
TP Honey
3a23b0d0d4
Merge pull request #3233 from alikhil/patch-1
Update links to discourse in issue template
2022-06-21 10:48:36 +01:00
Alik Khilazhev
9b89662825
chore(issue_template): update links to discourse 2022-06-21 12:36:37 +03:00
Eoin McAfee
1ac59bcac2
release prep for v2.12.1 (#3232)
* release prep for 2.12.1
2022-06-15 11:15:14 +01:00
Eoin McAfee
d7e34af1de
(bug) - fix original template scripts & remove amend scripts (#3229)
* removing amend template scripts and fixing original scripts due to Brads feedback
2022-06-15 09:11:28 +01:00
TP Honey
39e194ab11
Merge pull request #3230 from tphoney/starlark_windows_tests
(maint) fix starlark test on windows
2022-06-14 11:56:19 +01:00
TP Honey
2a70ce51cc (maint) fix starlark/jsonnet tests on windows 2022-06-14 11:47:36 +01:00
TP Honey
086c4b3f82
Merge pull request #3228 from tphoney/windows_unit_tests
(maint) fix unit tests so they pass on windows
2022-06-14 10:49:59 +01:00
Endymion Wight
b6053394ef
Added OAuth2 token refresher for Gitlab (#3215) 2022-06-14 10:46:35 +01:00
TP Honey
784c2e9e26 (maint) fix unit tests so they pass on windows 2022-06-13 17:46:57 +01:00
Eoin McAfee
f7a3c375a2
(bug) - remove unique index on template name (#3226)
* (bug) - remove unique index on template names
2022-06-09 14:30:18 +01:00
kit101
0fcf2536d2
Bump scm version to v1.24.0 (#3219)
* go-scm v1.24.0
2022-06-08 15:19:48 +01:00
Brad Rydzewski
0c764871d7
Merge pull request #3223 from hrittikhere/master [ci skip]
Update Readme to Fix Typo
2022-06-05 11:57:53 -04:00
Hrittik Roy
38dea1b91e Remove Typo for Readme.md 2022-06-04 17:08:05 +00:00
TP Honey
806833fe63
Merge pull request #3221 from harness/dron-239-template-comments
(bug) add unit test for comments in template file
2022-05-31 11:46:18 +01:00
Eoin McAfee
8cdafdf367 add unit test for comments in template file 2022-05-30 16:09:20 +01:00
TP Honey
95e091f093
Merge pull request #3214 from tphoney/prep_v2.12.0
release prep v2.12.0
2022-05-16 10:05:14 +01:00
TP Honey
aa18fc5322 release prep v2.12.0 2022-05-13 11:52:09 +01:00
TP Honey
724bd35cfc
Merge pull request #3210 from tphoney/dron-267
(dron-267) correctly set parent for promotion retry
2022-05-09 15:33:59 +01:00
TP Honey
046ad743e8
Merge pull request #3211 from tphoney/drone-ui_2.8.2
(fix) update drone ui to 2.8.2
2022-05-09 14:39:37 +01:00
TP Honey
12a70ea9a3 (fix) update drone ui to 2.8.2 2022-05-09 14:34:22 +01:00
TP Honey
eb26c8bce7 (dron-267) correctly set parent for promotion retry 2022-05-09 11:11:54 +01:00
Brad Rydzewski
6fb7bb00cc
Merge pull request #3208 from dnielsen/patch-1 [ci skip]
fixing URL
2022-04-28 10:48:17 -04:00
Dave Nielsen
0c3ef97409
fixing URL
changed URL from https://github.com/drone/drone to https://github.com/harness/drone
2022-04-28 02:21:02 -07:00
Dan Wilson
f5d9c05374
Merge pull request #3204 from harness/bump-go-scm-version
bump SCM version to v1.21.1
2022-04-22 15:18:53 +01:00
Dan Wilson
f4bb0f5797 bump SCM version to v1.21.1 2022-04-22 15:10:49 +01:00
Dan Wilson
8cbca28127
Merge pull request #3202 from harness/bump-ui-version
bump ui version
2022-04-14 11:48:19 +01:00
Dan Wilson
3aa920bae0 bump ui version 2022-04-14 11:41:43 +01:00
Marie Antons
65a367fa39
Merge pull request #3199 from harness/update-community-information
update community information with updated links
2022-04-05 08:33:53 -04:00
Marie
97afdfa7d7 update community information with updated links 2022-04-04 09:22:00 -03:00
23 changed files with 288 additions and 37 deletions

View file

@ -4,9 +4,9 @@ Bugs or Issues? Please create a new topic in our Discourse forum.
We are migrating all Drone repositories to Discourse for bug tracking. We are migrating all Drone repositories to Discourse for bug tracking.
New GitHub issues may be automatically deleted. New GitHub issues may be automatically deleted.
https://discourse.drone.io/ https://community.harness.io/
https://discourse.drone.io/c/bugs https://community.harness.io/c/bugs/17
https://discourse.drone.io/c/ideas https://community.harness.io/c/ideas/11
Failing Builds? Please do not use GitHub issues for generic support Failing Builds? Please do not use GitHub issues for generic support
questions. Instead please use Stack Overflow: questions. Instead please use Stack Overflow:

17
.github/readme.md vendored
View file

@ -8,7 +8,7 @@ Drone is a continuous delivery system built on container technology. Drone uses
- [What is Drone?](#what-is-drone) - [What is Drone?](#what-is-drone)
- [Table of Contents](#table-of-contents) - [Table of Contents](#table-of-contents)
- [Community](#community) - [Community and Support](#community-and-support)
- [Contributing](#contributing) - [Contributing](#contributing)
- [Code of Conduct](#code-of-conduct) - [Code of Conduct](#code-of-conduct)
- [Setup Documentation](#setup-documentation) - [Setup Documentation](#setup-documentation)
@ -17,13 +17,18 @@ Drone is a continuous delivery system built on container technology. Drone uses
- [Plugin Index](#plugin-index) - [Plugin Index](#plugin-index)
- [Documentation and Other Links](#documentation-and-Other-Links) - [Documentation and Other Links](#documentation-and-Other-Links)
## Community ## Community and Support
[Harness Community Slack](https://join.slack.com/t/harnesscommunity/shared_invite/zt-y4hdqh7p-RVuEQyIl5Hcx4Ck8VCvzBw) - Join the #drone slack channel to connect with our engineers and other users running Drone CI.
You can visit us at [Discourse](https://discourse.drone.io/) as well as our [Slack](https://join.slack.com/t/harnesscommunity/shared_invite/zt-90wb0w6u-OATJvUBkSDR3W9oYX7D~4A). </br>
[Harness Community Forum](https://community.harness.io/) - Ask questions, find answers, and help other users.
</br>
[Report A Bug](https://community.harness.io/c/bugs/17) - Find a bug? Please report in our forum under Drone Bugs. Please provide screenshots and steps to reproduce.
</br>
[Events](https://www.meetup.com/harness/) - Keep up to date with Drone events and check out previous events [here](https://www.youtube.com/watch?v=Oq34ImUGcHA&list=PLXsYHFsLmqf3zwelQDAKoVNmLeqcVsD9o).
## Contributing ## Contributing
We encourage you to contribute to Drone! whether thats joining in on the community slack or discourse, or contributing pull requests / documentation changes or raising issues. We encourage you to contribute to Drone! Whether that's joining in on the community slack or discourse, or contributing pull requests / documentation changes or raising issues.
## Code of Conduct ## Code of Conduct
@ -102,7 +107,7 @@ docker run -it --rm -v "$(pwd)":/usr/local/src/your-app githubchangeloggenerator
You can generate a token by logging into your GitHub account and going to Settings -> Personal access tokens. You can generate a token by logging into your GitHub account and going to Settings -> Personal access tokens.
Next we tag the PR's with the fixes or enhancements labels. If the PR does not fufil the requirements, do not add a label. Next we tag the PR's with the fixes or enhancements labels. If the PR does not fulfill the requirements, do not add a label.
**Before moving on make sure to update the version file `version/version.go && version/version_test.go`.** **Before moving on make sure to update the version file `version/version.go && version/version_test.go`.**

View file

@ -1,2 +1,3 @@
since-tag=v2.0.4 since-tag=v2.0.4
issues=false

View file

@ -1,5 +1,43 @@
# Changelog # Changelog
## [v2.12.1](https://github.com/harness/drone/tree/v2.12.1) (2022-06-15)
[Full Changelog](https://github.com/harness/drone/compare/v2.12.0...v2.12.1)
**Fixed bugs:**
- \(bug\) - fix original template scripts & remove amend scripts [\#3229](https://github.com/harness/drone/pull/3229) ([eoinmcafee00](https://github.com/eoinmcafee00))
- \(bug\) - remove unique index on template name [\#3226](https://github.com/harness/drone/pull/3226) ([eoinmcafee00](https://github.com/eoinmcafee00))
- Added OAuth2 token refresher for Gitlab [\#3215](https://github.com/harness/drone/pull/3215) ([EndymionWight](https://github.com/EndymionWight))
**Merged pull requests:**
- \(maint\) fix starlark test on windows [\#3230](https://github.com/harness/drone/pull/3230) ([tphoney](https://github.com/tphoney))
- \(maint\) fix unit tests so they pass on windows [\#3228](https://github.com/harness/drone/pull/3228) ([tphoney](https://github.com/tphoney))
- Update Readme to Fix Typo [\#3223](https://github.com/harness/drone/pull/3223) ([hrittikhere](https://github.com/hrittikhere))
- \(bug\) add unit test for comments in template file [\#3221](https://github.com/harness/drone/pull/3221) ([eoinmcafee00](https://github.com/eoinmcafee00))
- Bump scm version to v1.24.0 [\#3219](https://github.com/harness/drone/pull/3219) ([kit101](https://github.com/kit101))
## [v2.12.0](https://github.com/harness/drone/tree/v2.12.0) (2022-05-16)
[Full Changelog](https://github.com/harness/drone/compare/v2.11.1...v2.12.0)
**Implemented enhancements:**
- bump SCM version to v1.21.1 [\#3204](https://github.com/harness/drone/pull/3204) ([d1wilko](https://github.com/d1wilko))
- bump ui version [\#3202](https://github.com/harness/drone/pull/3202) ([d1wilko](https://github.com/d1wilko))
**Fixed bugs:**
- \(fix\) update drone ui to 2.8.2 [\#3211](https://github.com/harness/drone/pull/3211) ([tphoney](https://github.com/tphoney))
- \(dron-267\) correctly set parent for promotion retry [\#3210](https://github.com/harness/drone/pull/3210) ([tphoney](https://github.com/tphoney))
**Merged pull requests:**
- release prep v2.12.0 [\#3214](https://github.com/harness/drone/pull/3214) ([tphoney](https://github.com/tphoney))
- fixing URL [\#3208](https://github.com/harness/drone/pull/3208) ([dnielsen](https://github.com/dnielsen))
- update community information with updated links [\#3199](https://github.com/harness/drone/pull/3199) ([mrsantons](https://github.com/mrsantons))
## [v2.11.1](https://github.com/harness/drone/tree/v2.11.1) (2022-03-15) ## [v2.11.1](https://github.com/harness/drone/tree/v2.11.1) (2022-03-15)
[Full Changelog](https://github.com/harness/drone/compare/v2.11.0...v2.11.1) [Full Changelog](https://github.com/harness/drone/compare/v2.11.0...v2.11.1)
@ -8,6 +46,10 @@
- ignore nil repos in list and add better debugging [\#3196](https://github.com/harness/drone/pull/3196) ([d1wilko](https://github.com/d1wilko)) - ignore nil repos in list and add better debugging [\#3196](https://github.com/harness/drone/pull/3196) ([d1wilko](https://github.com/d1wilko))
**Merged pull requests:**
- \(maint\) release prep for 2.11.1 [\#3197](https://github.com/harness/drone/pull/3197) ([d1wilko](https://github.com/d1wilko))
## [v2.11.0](https://github.com/harness/drone/tree/v2.11.0) (2022-03-08) ## [v2.11.0](https://github.com/harness/drone/tree/v2.11.0) (2022-03-08)
[Full Changelog](https://github.com/harness/drone/compare/v2.10.0...v2.11.0) [Full Changelog](https://github.com/harness/drone/compare/v2.10.0...v2.11.0)

View file

@ -21,7 +21,7 @@ Drone Non-Commercial License
Contributor: Drone.IO, Inc. Contributor: Drone.IO, Inc.
Source Code: https://github.com/drone/drone Source Code: https://github.com/harness/drone
This license lets you use and share this software for free, This license lets you use and share this software for free,
with a trial-length time limit on commercial use. Specifically: with a trial-length time limit on commercial use. Specifically:

View file

@ -180,7 +180,13 @@ func provideGitlabClient(config config.Config) *scm.Client {
} }
client.Client = &http.Client{ client.Client = &http.Client{
Transport: &oauth2.Transport{ Transport: &oauth2.Transport{
Source: oauth2.ContextTokenSource(), Scheme: oauth2.SchemeBearer,
Source: &oauth2.Refresher{
ClientID: config.GitLab.ClientID,
ClientSecret: config.GitLab.ClientSecret,
Endpoint: strings.TrimSuffix(config.GitLab.Server, "/") + "/oauth/token",
Source: oauth2.ContextTokenSource(),
},
Base: defaultTransport(config.GitLab.SkipVerify), Base: defaultTransport(config.GitLab.SkipVerify),
}, },
} }

View file

@ -197,6 +197,14 @@ func provideRefresher(config config.Config) *oauth2.Refresher {
Source: oauth2.ContextTokenSource(), Source: oauth2.ContextTokenSource(),
Client: defaultClient(config.Gitea.SkipVerify), Client: defaultClient(config.Gitea.SkipVerify),
} }
case config.GitLab.ClientID != "":
return &oauth2.Refresher{
ClientID: config.GitLab.ClientID,
ClientSecret: config.GitLab.ClientSecret,
Endpoint: strings.TrimSuffix(config.GitLab.Server, "/") + "/oauth/token",
Source: oauth2.ContextTokenSource(),
Client: defaultClient(config.GitLab.SkipVerify),
}
case config.Gitee.ClientID != "": case config.Gitee.ClientID != "":
return &oauth2.Refresher{ return &oauth2.Refresher{
ClientID: config.Gitee.ClientID, ClientID: config.Gitee.ClientID,

4
go.mod
View file

@ -14,13 +14,13 @@ require (
github.com/dchest/uniuri v0.0.0-20160212164326-8902c56451e9 github.com/dchest/uniuri v0.0.0-20160212164326-8902c56451e9
github.com/drone/drone-go v1.7.2-0.20220308165842-f9e4fe31c2af github.com/drone/drone-go v1.7.2-0.20220308165842-f9e4fe31c2af
github.com/drone/drone-runtime v1.1.1-0.20200623162453-61e33e2cab5d github.com/drone/drone-runtime v1.1.1-0.20200623162453-61e33e2cab5d
github.com/drone/drone-ui v2.7.1+incompatible github.com/drone/drone-ui v2.8.2+incompatible
github.com/drone/drone-yaml v1.2.4-0.20200326192514-6f4d6dfb39e4 github.com/drone/drone-yaml v1.2.4-0.20200326192514-6f4d6dfb39e4
github.com/drone/envsubst v1.0.3-0.20200709231038-aa43e1c1a629 github.com/drone/envsubst v1.0.3-0.20200709231038-aa43e1c1a629
github.com/drone/funcmap v0.0.0-20210823160631-9e9dec149056 github.com/drone/funcmap v0.0.0-20210823160631-9e9dec149056
github.com/drone/go-license v1.0.2 github.com/drone/go-license v1.0.2
github.com/drone/go-login v1.1.0 github.com/drone/go-login v1.1.0
github.com/drone/go-scm v1.20.0 github.com/drone/go-scm v1.24.0
github.com/drone/signal v1.0.0 github.com/drone/signal v1.0.0
github.com/dustin/go-humanize v1.0.0 github.com/dustin/go-humanize v1.0.0
github.com/go-chi/chi v3.3.3+incompatible github.com/go-chi/chi v3.3.3+incompatible

12
go.sum
View file

@ -73,17 +73,13 @@ github.com/docker/go-connections v0.3.0 h1:3lOnM9cSzgGwx8VfK/NGOW5fLQ0GjIlCkaktF
github.com/docker/go-connections v0.3.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-connections v0.3.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
github.com/docker/go-units v0.3.3 h1:Xk8S3Xj5sLGlG5g67hJmYMmUgXv5N4PhkjJHHqrwnTk= github.com/docker/go-units v0.3.3 h1:Xk8S3Xj5sLGlG5g67hJmYMmUgXv5N4PhkjJHHqrwnTk=
github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/drone/drone-go v1.4.1-0.20201109202657-b9e58bbbcf27 h1:58xKlW/Kwp/Apz+R5qNGzBUIzfq1Z57L7Udz1B6bgWE=
github.com/drone/drone-go v1.4.1-0.20201109202657-b9e58bbbcf27/go.mod h1:fxCf9jAnXDZV1yDr0ckTuWd1intvcQwfJmTRpTZ1mXg=
github.com/drone/drone-go v1.7.1 h1:ZX+3Rs8YHUSUQ5mkuMLmm1zr1ttiiE2YGNxF3AnyDKw=
github.com/drone/drone-go v1.7.1/go.mod h1:fxCf9jAnXDZV1yDr0ckTuWd1intvcQwfJmTRpTZ1mXg=
github.com/drone/drone-go v1.7.2-0.20220308165842-f9e4fe31c2af h1:I+xfWPZLMaskFvfFO5fEJ6tVI1Q9bWR9tuORZeaCTPo= github.com/drone/drone-go v1.7.2-0.20220308165842-f9e4fe31c2af h1:I+xfWPZLMaskFvfFO5fEJ6tVI1Q9bWR9tuORZeaCTPo=
github.com/drone/drone-go v1.7.2-0.20220308165842-f9e4fe31c2af/go.mod h1:fxCf9jAnXDZV1yDr0ckTuWd1intvcQwfJmTRpTZ1mXg= github.com/drone/drone-go v1.7.2-0.20220308165842-f9e4fe31c2af/go.mod h1:fxCf9jAnXDZV1yDr0ckTuWd1intvcQwfJmTRpTZ1mXg=
github.com/drone/drone-runtime v1.0.7-0.20190729202838-87c84080f4a1/go.mod h1:+osgwGADc/nyl40J0fdsf8Z09bgcBZXvXXnLOY48zYs= github.com/drone/drone-runtime v1.0.7-0.20190729202838-87c84080f4a1/go.mod h1:+osgwGADc/nyl40J0fdsf8Z09bgcBZXvXXnLOY48zYs=
github.com/drone/drone-runtime v1.1.1-0.20200623162453-61e33e2cab5d h1:P5HI/Y9hARTZ3F3EKs0kYijhjXZWQRQHYn1neTi0pWM= github.com/drone/drone-runtime v1.1.1-0.20200623162453-61e33e2cab5d h1:P5HI/Y9hARTZ3F3EKs0kYijhjXZWQRQHYn1neTi0pWM=
github.com/drone/drone-runtime v1.1.1-0.20200623162453-61e33e2cab5d/go.mod h1:4/2QToW5+HGD0y1sTw7X35W1f7YINS14UfDY4isggT8= github.com/drone/drone-runtime v1.1.1-0.20200623162453-61e33e2cab5d/go.mod h1:4/2QToW5+HGD0y1sTw7X35W1f7YINS14UfDY4isggT8=
github.com/drone/drone-ui v2.7.1+incompatible h1:2RPN9/ZBMyJtcX+YBkf6eXz3k2LOHS/j8cPtH7mNfXA= github.com/drone/drone-ui v2.8.2+incompatible h1:7F/MlcSEIZVi5VND/qmOnDDwQOkgqwsCVOQOsGJ2HJc=
github.com/drone/drone-ui v2.7.1+incompatible/go.mod h1:NBtVWW7NNJpD9+huMD/5TAE1db2nrEh0i35/9Rf1MPI= github.com/drone/drone-ui v2.8.2+incompatible/go.mod h1:NBtVWW7NNJpD9+huMD/5TAE1db2nrEh0i35/9Rf1MPI=
github.com/drone/drone-yaml v1.2.4-0.20200326192514-6f4d6dfb39e4 h1:XsstoCeXC2t8lA9OLTdoFwckaptqahxwjCWsenySfX8= github.com/drone/drone-yaml v1.2.4-0.20200326192514-6f4d6dfb39e4 h1:XsstoCeXC2t8lA9OLTdoFwckaptqahxwjCWsenySfX8=
github.com/drone/drone-yaml v1.2.4-0.20200326192514-6f4d6dfb39e4/go.mod h1:QsqliFK8nG04AHFN9tTn9XJomRBQHD4wcejWW1uz/10= github.com/drone/drone-yaml v1.2.4-0.20200326192514-6f4d6dfb39e4/go.mod h1:QsqliFK8nG04AHFN9tTn9XJomRBQHD4wcejWW1uz/10=
github.com/drone/envsubst v1.0.3-0.20200709231038-aa43e1c1a629 h1:rIaZZalMGGPb2cU/+ypuggZ8aMlpa17RUlJUtsMv8pw= github.com/drone/envsubst v1.0.3-0.20200709231038-aa43e1c1a629 h1:rIaZZalMGGPb2cU/+ypuggZ8aMlpa17RUlJUtsMv8pw=
@ -94,8 +90,8 @@ github.com/drone/go-license v1.0.2 h1:7OwndfYk+Lp/cGHkxe4HUn/Ysrrw3WYH2pnd99yrko
github.com/drone/go-license v1.0.2/go.mod h1:fGRHf+F1cEaw3YVYiJ6js3G3dVhcxyS617RnNRUMsms= github.com/drone/go-license v1.0.2/go.mod h1:fGRHf+F1cEaw3YVYiJ6js3G3dVhcxyS617RnNRUMsms=
github.com/drone/go-login v1.1.0 h1:anQFRh2Z5ketEJ/LvL6SJ6rIwDdfysGXK5bSXkFLInI= github.com/drone/go-login v1.1.0 h1:anQFRh2Z5ketEJ/LvL6SJ6rIwDdfysGXK5bSXkFLInI=
github.com/drone/go-login v1.1.0/go.mod h1:FLxy9vRzLbyBxoCJYxGbG9R0WGn6OyuvBmAtYNt43uw= github.com/drone/go-login v1.1.0/go.mod h1:FLxy9vRzLbyBxoCJYxGbG9R0WGn6OyuvBmAtYNt43uw=
github.com/drone/go-scm v1.20.0 h1:SGB8TnE/85rklK+Gb3ZRTHQRt2atSCFHgtDKNqPwBQU= github.com/drone/go-scm v1.24.0 h1:wE6bP9gnuyyKJStnl6wl0npt/SBQumjE9jilQAcFy6Q=
github.com/drone/go-scm v1.20.0/go.mod h1:DFIJJjhMj0TSXPz+0ni4nyZ9gtTtC40Vh/TGRugtyWw= github.com/drone/go-scm v1.24.0/go.mod h1:DFIJJjhMj0TSXPz+0ni4nyZ9gtTtC40Vh/TGRugtyWw=
github.com/drone/signal v1.0.0 h1:NrnM2M/4yAuU/tXs6RP1a1ZfxnaHwYkd0kJurA1p6uI= github.com/drone/signal v1.0.0 h1:NrnM2M/4yAuU/tXs6RP1a1ZfxnaHwYkd0kJurA1p6uI=
github.com/drone/signal v1.0.0/go.mod h1:S8t92eFT0g4WUgEc/LxG+LCuiskpMNsG0ajAMGnyZpc= github.com/drone/signal v1.0.0/go.mod h1:S8t92eFT0g4WUgEc/LxG+LCuiskpMNsG0ajAMGnyZpc=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=

View file

@ -64,6 +64,7 @@ func HandleRetry(
} }
hook := &core.Hook{ hook := &core.Hook{
Parent: prev.Number,
Trigger: user.Login, Trigger: user.Login,
Event: prev.Event, Event: prev.Event,
Action: prev.Action, Action: prev.Action,

View file

@ -797,3 +797,19 @@ func (mr *MockUserServiceMockRecorder) FindLogin(arg0, arg1 interface{}) *gomock
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindLogin", reflect.TypeOf((*MockUserService)(nil).FindLogin), arg0, arg1) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindLogin", reflect.TypeOf((*MockUserService)(nil).FindLogin), arg0, arg1)
} }
// ListEmail mocks base method
func (m *MockUserService) ListEmail(arg0 context.Context, arg1 scm.ListOptions) ([]*scm.Email, *scm.Response, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ListEmail", arg0, arg1)
ret0, _ := ret[0].([]*scm.Email)
ret1, _ := ret[1].(*scm.Response)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
}
// ListEmail indicates an expected call of ListEmail.
func (mr *MockUserServiceMockRecorder) ListEmail(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListEmail", reflect.TypeOf((*MockUserService)(nil).ListEmail), arg0, arg1)
}

View file

@ -2,6 +2,8 @@ package jsonnet
import ( import (
"io/ioutil" "io/ioutil"
"runtime"
"strings"
"testing" "testing"
"github.com/drone/drone/core" "github.com/drone/drone/core"
@ -44,13 +46,19 @@ func TestParse(t *testing.T) {
req.Config.Data = string(before) req.Config.Data = string(before)
parsedFile, err := Parse(req, nil, 0, template, templateData) got, err := Parse(req, nil, 0, template, templateData)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
return return
} }
if want, got := parsedFile, string(after); want != got { want := string(after)
// on windows line endings are \r\n, lets change them to linux for comparison
if runtime.GOOS == "windows" {
want = strings.Replace(want, "\r\n", "\n", -1)
}
if want != got {
t.Errorf("Want %q got %q", want, got) t.Errorf("Want %q got %q", want, got)
} }
} }
@ -82,13 +90,19 @@ func TestParseJsonnetNotTemplateFile(t *testing.T) {
req.Repo.Config = "plugin.jsonnet" req.Repo.Config = "plugin.jsonnet"
req.Config.Data = string(before) req.Config.Data = string(before)
parsedFile, err := Parse(req, nil, 0, nil, nil) got, err := Parse(req, nil, 0, nil, nil)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
return return
} }
if want, got := parsedFile, string(after); want != got { want := string(after)
// on windows line endings are \r\n, lets change them to linux for comparison
if runtime.GOOS == "windows" {
want = strings.Replace(want, "\r\n", "\n", -1)
}
if want != got {
t.Errorf("Want %q got %q", want, got) t.Errorf("Want %q got %q", want, got)
} }
} }

View file

@ -16,6 +16,8 @@ package converter
import ( import (
"io/ioutil" "io/ioutil"
"runtime"
"strings"
"testing" "testing"
"github.com/drone/drone/core" "github.com/drone/drone/core"
@ -117,7 +119,14 @@ func TestConvert_Multi(t *testing.T) {
return return
} }
if want, got := config.Data, string(after); want != got { want := string(after)
// on windows line endings are \r\n, lets change them to linux for comparison
if runtime.GOOS == "windows" {
want = strings.Replace(want, "\r\n", "\n", -1)
}
got := config.Data
if want != got {
t.Errorf("Want %q got %q", want, got) t.Errorf("Want %q got %q", want, got)
} }
} }

View file

@ -17,6 +17,8 @@ package converter
import ( import (
"encoding/json" "encoding/json"
"io/ioutil" "io/ioutil"
"runtime"
"strings"
"testing" "testing"
"github.com/drone/drone/core" "github.com/drone/drone/core"
@ -234,7 +236,14 @@ func TestTemplatePluginConvertJsonnet(t *testing.T) {
return return
} }
if want, got := config.Data, string(after); want != got { want := string(after)
// on windows line endings are \r\n, lets change them to linux for comparison
if runtime.GOOS == "windows" {
want = strings.Replace(want, "\r\n", "\n", -1)
}
got := config.Data
if want != got {
t.Errorf("Want %q got %q", want, got) t.Errorf("Want %q got %q", want, got)
} }
} }
@ -388,6 +397,7 @@ func TestTemplatePluginConvertYaml(t *testing.T) {
t.Errorf("Want %q got %q", want, got) t.Errorf("Want %q got %q", want, got)
} }
} }
// tests to check error is thrown if user has already loaded a template file of invalid extension // tests to check error is thrown if user has already loaded a template file of invalid extension
// and refers to it in the drone.yml file // and refers to it in the drone.yml file
func TestTemplatePluginConvertInvalidTemplateExtension(t *testing.T) { func TestTemplatePluginConvertInvalidTemplateExtension(t *testing.T) {
@ -436,3 +446,65 @@ func TestTemplatePluginConvertInvalidTemplateExtension(t *testing.T) {
t.Errorf("template extension invalid. must be yaml, starlark or jsonnet") t.Errorf("template extension invalid. must be yaml, starlark or jsonnet")
} }
} }
func TestTemplatePluginConvertYamlWithComment(t *testing.T) {
templateArgs, err := ioutil.ReadFile("testdata/yaml.template.comment.yml")
if err != nil {
t.Error(err)
return
}
req := &core.ConvertArgs{
Build: &core.Build{
After: "3d21ec53a331a6f037a91c368710b99387d012c1",
},
Repo: &core.Repository{
Slug: "octocat/hello-world",
Config: ".drone.yml",
Namespace: "octocat",
},
Config: &core.Config{
Data: string(templateArgs),
},
}
beforeInput, err := ioutil.ReadFile("testdata/yaml.input.yml")
if err != nil {
t.Error(err)
return
}
after, err := ioutil.ReadFile("testdata/yaml.input.golden")
if err != nil {
t.Error(err)
return
}
template := &core.Template{
Name: "plugin.yaml",
Data: string(beforeInput),
Namespace: "octocat",
}
controller := gomock.NewController(t)
defer controller.Finish()
templates := mock.NewMockTemplateStore(controller)
templates.EXPECT().FindName(gomock.Any(), template.Name, req.Repo.Namespace).Return(template, nil)
plugin := Template(templates, 0)
config, err := plugin.Convert(noContext, req)
if err != nil {
t.Error(err)
return
}
if config == nil {
t.Error("Want non-nil configuration")
return
}
if want, got := config.Data, string(after); want != got {
t.Errorf("Want %q got %q", want, got)
}
}

View file

@ -0,0 +1,8 @@
---
# this is a comment
kind: template
load: plugin.yaml
data:
stepName: my_step
image: my_image
commands: my_command

View file

@ -48,6 +48,7 @@ func Connect() (*db.DB, error) {
func Reset(d *db.DB) { func Reset(d *db.DB) {
d.Lock(func(tx db.Execer, _ db.Binder) error { d.Lock(func(tx db.Execer, _ db.Binder) error {
tx.Exec("DELETE FROM cron") tx.Exec("DELETE FROM cron")
tx.Exec("DELETE FROM cards")
tx.Exec("DELETE FROM logs") tx.Exec("DELETE FROM logs")
tx.Exec("DELETE FROM steps") tx.Exec("DELETE FROM steps")
tx.Exec("DELETE FROM stages") tx.Exec("DELETE FROM stages")
@ -56,6 +57,7 @@ func Reset(d *db.DB) {
tx.Exec("DELETE FROM perms") tx.Exec("DELETE FROM perms")
tx.Exec("DELETE FROM repos") tx.Exec("DELETE FROM repos")
tx.Exec("DELETE FROM users") tx.Exec("DELETE FROM users")
tx.Exec("DELETE FROM templates")
tx.Exec("DELETE FROM orgsecrets") tx.Exec("DELETE FROM orgsecrets")
return nil return nil
}) })

View file

@ -160,6 +160,10 @@ var migrations = []struct {
name: "create-table-template", name: "create-table-template",
stmt: createTableTemplate, stmt: createTableTemplate,
}, },
{
name: "create-index-template-namespace",
stmt: createIndexTemplateNamespace,
},
{ {
name: "alter-table-steps-add-column-step-depends-on", name: "alter-table-steps-add-column-step-depends-on",
stmt: alterTableStepsAddColumnStepDependsOn, stmt: alterTableStepsAddColumnStepDependsOn,
@ -692,14 +696,16 @@ CREATE INDEX IF NOT EXISTS ix_latest_repo ON latest (latest_repo_id);
var createTableTemplate = ` var createTableTemplate = `
CREATE TABLE IF NOT EXISTS templates ( CREATE TABLE IF NOT EXISTS templates (
template_id SERIAL PRIMARY KEY template_id SERIAL PRIMARY KEY
,template_name TEXT UNIQUE ,template_name TEXT
,template_namespace VARCHAR(50) ,template_namespace VARCHAR(50)
,template_data BYTEA ,template_data BYTEA
,template_created INTEGER ,template_created INTEGER
,template_updated INTEGER ,template_updated INTEGER
,UNIQUE(template_name, template_namespace) ,UNIQUE(template_name, template_namespace)
); );
`
var createIndexTemplateNamespace = `
CREATE INDEX IF NOT EXISTS ix_template_namespace ON templates (template_namespace); CREATE INDEX IF NOT EXISTS ix_template_namespace ON templates (template_namespace);
` `

View file

@ -2,7 +2,7 @@
CREATE TABLE IF NOT EXISTS templates ( CREATE TABLE IF NOT EXISTS templates (
template_id SERIAL PRIMARY KEY template_id SERIAL PRIMARY KEY
,template_name TEXT UNIQUE ,template_name TEXT
,template_namespace VARCHAR(50) ,template_namespace VARCHAR(50)
,template_data BYTEA ,template_data BYTEA
,template_created INTEGER ,template_created INTEGER
@ -10,4 +10,6 @@ CREATE TABLE IF NOT EXISTS templates (
,UNIQUE(template_name, template_namespace) ,UNIQUE(template_name, template_namespace)
); );
-- name: create-index-template-namespace
CREATE INDEX IF NOT EXISTS ix_template_namespace ON templates (template_namespace); CREATE INDEX IF NOT EXISTS ix_template_namespace ON templates (template_namespace);

View file

@ -160,6 +160,10 @@ var migrations = []struct {
name: "create-table-templates", name: "create-table-templates",
stmt: createTableTemplates, stmt: createTableTemplates,
}, },
{
name: "create-index-template-namespace",
stmt: createIndexTemplateNamespace,
},
{ {
name: "alter-table-steps-add-column-step-depends-on", name: "alter-table-steps-add-column-step-depends-on",
stmt: alterTableStepsAddColumnStepDependsOn, stmt: alterTableStepsAddColumnStepDependsOn,
@ -694,14 +698,16 @@ CREATE INDEX IF NOT EXISTS ix_latest_repo ON latest (latest_repo_id);
var createTableTemplates = ` var createTableTemplates = `
CREATE TABLE IF NOT EXISTS templates ( CREATE TABLE IF NOT EXISTS templates (
template_id INTEGER PRIMARY KEY AUTOINCREMENT template_id INTEGER PRIMARY KEY AUTOINCREMENT
,template_name TEXT UNIQUE ,template_name TEXT
,template_namespace TEXT COLLATE NOCASE ,template_namespace TEXT COLLATE NOCASE
,template_data BLOB ,template_data BLOB
,template_created INTEGER ,template_created INTEGER
,template_updated INTEGER ,template_updated INTEGER
,UNIQUE(template_name, template_namespace) ,UNIQUE(template_name COLLATE NOCASE, template_namespace COLLATE NOCASE)
); );
`
var createIndexTemplateNamespace = `
CREATE INDEX IF NOT EXISTS ix_template_namespace ON templates (template_namespace); CREATE INDEX IF NOT EXISTS ix_template_namespace ON templates (template_namespace);
` `

View file

@ -2,12 +2,14 @@
CREATE TABLE IF NOT EXISTS templates ( CREATE TABLE IF NOT EXISTS templates (
template_id INTEGER PRIMARY KEY AUTOINCREMENT template_id INTEGER PRIMARY KEY AUTOINCREMENT
,template_name TEXT UNIQUE ,template_name TEXT
,template_namespace TEXT COLLATE NOCASE ,template_namespace TEXT COLLATE NOCASE
,template_data BLOB ,template_data BLOB
,template_created INTEGER ,template_created INTEGER
,template_updated INTEGER ,template_updated INTEGER
,UNIQUE(template_name, template_namespace) ,UNIQUE(template_name COLLATE NOCASE, template_namespace COLLATE NOCASE)
); );
-- name: create-index-template-namespace
CREATE INDEX IF NOT EXISTS ix_template_namespace ON templates (template_namespace); CREATE INDEX IF NOT EXISTS ix_template_namespace ON templates (template_namespace);

View file

@ -2,6 +2,7 @@
// Use of this source code is governed by the Drone Non-Commercial License // Use of this source code is governed by the Drone Non-Commercial License
// that can be found in the LICENSE file. // that can be found in the LICENSE file.
//go:build !oss
// +build !oss // +build !oss
package template package template
@ -29,7 +30,7 @@ func TestTemplate(t *testing.T) {
}() }()
store := New(conn).(*templateStore) store := New(conn).(*templateStore)
t.Run("Create", testTemplateCreate(store)) t.Run("TestTemplates", testTemplateCreate(store))
} }
func testTemplateCreate(store *templateStore) func(t *testing.T) { func testTemplateCreate(store *templateStore) func(t *testing.T) {
@ -50,6 +51,8 @@ func testTemplateCreate(store *templateStore) func(t *testing.T) {
t.Errorf("Want template Id assigned, got %d", item.Id) t.Errorf("Want template Id assigned, got %d", item.Id)
} }
t.Run("CreateSameNameDiffOrg", testCreateWithSameNameDiffOrg(store))
t.Run("CreateSameNameSameOrgShouldError", testCreateSameNameSameOrgShouldError(store))
t.Run("Find", testTemplateFind(store, item)) t.Run("Find", testTemplateFind(store, item))
t.Run("FindName", testTemplateFindName(store)) t.Run("FindName", testTemplateFindName(store))
t.Run("ListAll", testTemplateListAll(store)) t.Run("ListAll", testTemplateListAll(store))
@ -59,6 +62,43 @@ func testTemplateCreate(store *templateStore) func(t *testing.T) {
} }
} }
func testCreateWithSameNameDiffOrg(store *templateStore) func(t *testing.T) {
return func(t *testing.T) {
item := &core.Template{
Id: 1,
Name: "my_template",
Namespace: "my_org2",
Data: "some_template_data",
Created: 1,
Updated: 2,
}
err := store.Create(noContext, item)
if err != nil {
t.Error(err)
}
if item.Id == 0 {
t.Errorf("Want template Id assigned, got %d", item.Id)
}
}
}
func testCreateSameNameSameOrgShouldError(store *templateStore) func(t *testing.T) {
return func(t *testing.T) {
item := &core.Template{
Id: 3,
Name: "my_template",
Namespace: "my_org2",
Data: "some_template_data",
Created: 1,
Updated: 2,
}
err := store.Create(noContext, item)
if err == nil {
t.Error(err)
}
}
}
func testTemplateFind(store *templateStore, template *core.Template) func(t *testing.T) { func testTemplateFind(store *templateStore, template *core.Template) func(t *testing.T) {
return func(t *testing.T) { return func(t *testing.T) {
item, err := store.Find(noContext, template.Id) item, err := store.Find(noContext, template.Id)
@ -95,6 +135,20 @@ func testTemplate(item *core.Template) func(t *testing.T) {
} }
} }
func testTemplate2(item *core.Template) func(t *testing.T) {
return func(t *testing.T) {
if got, want := item.Name, "my_template"; got != want {
t.Errorf("Want template name %q, got %q", want, got)
}
if got, want := item.Data, "some_template_data"; got != want {
t.Errorf("Want template data %q, got %q", want, got)
}
if got, want := item.Namespace, "my_org2"; got != want {
t.Errorf("Want template org %q, got %q", want, got)
}
}
}
func testTemplateListAll(store *templateStore) func(t *testing.T) { func testTemplateListAll(store *templateStore) func(t *testing.T) {
return func(t *testing.T) { return func(t *testing.T) {
list, err := store.ListAll(noContext) list, err := store.ListAll(noContext)
@ -102,10 +156,11 @@ func testTemplateListAll(store *templateStore) func(t *testing.T) {
t.Error(err) t.Error(err)
return return
} }
if got, want := len(list), 1; got != want { if got, want := len(list), 2; got != want {
t.Errorf("Want count %d, got %d", want, got) t.Errorf("Want count %d, got %d", want, got)
} else { } else {
t.Run("Fields", testTemplate(list[0])) t.Run("Fields", testTemplate(list[0]))
t.Run("Fields", testTemplate2(list[1]))
} }
} }
} }

View file

@ -25,7 +25,7 @@ var (
// VersionMajor is for an API incompatible changes. // VersionMajor is for an API incompatible changes.
VersionMajor int64 = 2 VersionMajor int64 = 2
// VersionMinor is for functionality in a backwards-compatible manner. // VersionMinor is for functionality in a backwards-compatible manner.
VersionMinor int64 = 11 VersionMinor int64 = 12
// VersionPatch is for backwards-compatible bug fixes. // VersionPatch is for backwards-compatible bug fixes.
VersionPatch int64 = 1 VersionPatch int64 = 1
// VersionPre indicates prerelease. // VersionPre indicates prerelease.

View file

@ -10,7 +10,7 @@ package version
import "testing" import "testing"
func TestVersion(t *testing.T) { func TestVersion(t *testing.T) {
if got, want := Version.String(), "2.11.1"; got != want { if got, want := Version.String(), "2.12.1"; got != want {
t.Errorf("Want version %s, got %s", want, got) t.Errorf("Want version %s, got %s", want, got)
} }
} }