Compare commits
75 commits
Author | SHA1 | Date | |
---|---|---|---|
|
3a23b0d0d4 | ||
|
9b89662825 | ||
|
1ac59bcac2 | ||
|
d7e34af1de | ||
|
39e194ab11 | ||
|
2a70ce51cc | ||
|
086c4b3f82 | ||
|
b6053394ef | ||
|
784c2e9e26 | ||
|
f7a3c375a2 | ||
|
0fcf2536d2 | ||
|
0c764871d7 | ||
|
38dea1b91e | ||
|
806833fe63 | ||
|
8cdafdf367 | ||
|
95e091f093 | ||
|
aa18fc5322 | ||
|
724bd35cfc | ||
|
046ad743e8 | ||
|
12a70ea9a3 | ||
|
eb26c8bce7 | ||
|
6fb7bb00cc | ||
|
0c3ef97409 | ||
|
f5d9c05374 | ||
|
f4bb0f5797 | ||
|
8cbca28127 | ||
|
3aa920bae0 | ||
|
65a367fa39 | ||
|
97afdfa7d7 | ||
|
1de855eb61 | ||
|
62f1086680 | ||
|
7b42cd9bbd | ||
|
6a81c655ff | ||
|
a4995ca7f3 | ||
|
f9627f8e40 | ||
|
dc6c94b7af | ||
|
80629d12fa | ||
|
e3c598109b | ||
|
3e52b2f4ed | ||
|
3f6096325b | ||
|
359cefc2a7 | ||
|
be2660aac9 | ||
|
e909c5f7d8 | ||
|
c7b8403a7c | ||
|
a6c0937cc3 | ||
|
9fb00fc478 | ||
|
67cb161eaf | ||
|
bb9844ab3c | ||
|
12c83861eb | ||
|
a687caacbb | ||
|
9a3dfe318c | ||
|
1f61646ba8 | ||
|
987683c723 | ||
|
c2104a18f0 | ||
|
07731e4df8 | ||
|
3088c670ae | ||
|
f889ae8eb0 | ||
|
0aca433670 | ||
|
cee773ac6a | ||
|
7e757c4a3d | ||
|
3398f2eb57 | ||
|
62be60f9ac | ||
|
979c06957a | ||
|
fab2899a2b | ||
|
f51eb4ed22 | ||
|
c9c1f82c7a | ||
|
cb6fb442cd | ||
|
92f6f66c33 | ||
|
ee99e86b2c | ||
|
f67ec3cc50 | ||
|
abe1824354 | ||
|
50c8911f2a | ||
|
64a7e8f92a | ||
|
996353bfff | ||
|
8de5eac502 |
44 changed files with 632 additions and 57 deletions
6
.github/issue_template.md
vendored
6
.github/issue_template.md
vendored
|
@ -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.
|
||||
New GitHub issues may be automatically deleted.
|
||||
|
||||
https://discourse.drone.io/
|
||||
https://discourse.drone.io/c/bugs
|
||||
https://discourse.drone.io/c/ideas
|
||||
https://community.harness.io/
|
||||
https://community.harness.io/c/bugs/17
|
||||
https://community.harness.io/c/ideas/11
|
||||
|
||||
Failing Builds? Please do not use GitHub issues for generic support
|
||||
questions. Instead please use Stack Overflow:
|
||||
|
|
17
.github/readme.md
vendored
17
.github/readme.md
vendored
|
@ -8,7 +8,7 @@ Drone is a continuous delivery system built on container technology. Drone uses
|
|||
|
||||
- [What is Drone?](#what-is-drone)
|
||||
- [Table of Contents](#table-of-contents)
|
||||
- [Community](#community)
|
||||
- [Community and Support](#community-and-support)
|
||||
- [Contributing](#contributing)
|
||||
- [Code of Conduct](#code-of-conduct)
|
||||
- [Setup Documentation](#setup-documentation)
|
||||
|
@ -17,13 +17,18 @@ Drone is a continuous delivery system built on container technology. Drone uses
|
|||
- [Plugin Index](#plugin-index)
|
||||
- [Documentation and Other Links](#documentation-and-Other-Links)
|
||||
|
||||
## Community
|
||||
|
||||
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).
|
||||
## 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.
|
||||
</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
|
||||
|
||||
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
|
||||
|
||||
|
@ -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.
|
||||
|
||||
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`.**
|
||||
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
since-tag=v2.0.4
|
||||
issues=false
|
||||
|
||||
|
|
178
CHANGELOG.md
178
CHANGELOG.md
|
@ -1,5 +1,179 @@
|
|||
# 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)
|
||||
|
||||
[Full Changelog](https://github.com/harness/drone/compare/v2.11.0...v2.11.1)
|
||||
|
||||
**Fixed bugs:**
|
||||
|
||||
- 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)
|
||||
|
||||
[Full Changelog](https://github.com/harness/drone/compare/v2.10.0...v2.11.0)
|
||||
|
||||
**Implemented enhancements:**
|
||||
|
||||
- bump UI and SCM versions [\#3193](https://github.com/harness/drone/pull/3193) ([d1wilko](https://github.com/d1wilko))
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- \(maint\) release prep for 2.11.0 [\#3194](https://github.com/harness/drone/pull/3194) ([d1wilko](https://github.com/d1wilko))
|
||||
|
||||
## [v2.10.0](https://github.com/harness/drone/tree/v2.10.0) (2022-03-03)
|
||||
|
||||
[Full Changelog](https://github.com/harness/drone/compare/v2.9.1...v2.10.0)
|
||||
|
||||
**Implemented enhancements:**
|
||||
|
||||
- bump UI version to v2.7.0 [\#3190](https://github.com/harness/drone/pull/3190) ([d1wilko](https://github.com/d1wilko))
|
||||
- bump UI version to v2.6.2 [\#3188](https://github.com/harness/drone/pull/3188) ([d1wilko](https://github.com/d1wilko))
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- \(maint\) release prep for 2.10.0 [\#3191](https://github.com/harness/drone/pull/3191) ([d1wilko](https://github.com/d1wilko))
|
||||
|
||||
## [v2.9.1](https://github.com/harness/drone/tree/v2.9.1) (2022-01-27)
|
||||
|
||||
[Full Changelog](https://github.com/harness/drone/compare/v2.9.0...v2.9.1)
|
||||
|
||||
**Fixed bugs:**
|
||||
|
||||
- bump ui version 2.6.1 [\#3185](https://github.com/harness/drone/pull/3185) ([d1wilko](https://github.com/d1wilko))
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- \(maint\) release prep for 2.9.1 [\#3186](https://github.com/harness/drone/pull/3186) ([tphoney](https://github.com/tphoney))
|
||||
|
||||
## [v2.9.0](https://github.com/harness/drone/tree/v2.9.0) (2022-01-26)
|
||||
|
||||
[Full Changelog](https://github.com/harness/drone/compare/v2.8.0...v2.9.0)
|
||||
|
||||
**Implemented enhancements:**
|
||||
|
||||
- bump ui to v2.6.0 [\#3183](https://github.com/harness/drone/pull/3183) ([eoinmcafee00](https://github.com/eoinmcafee00))
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- release prep for v2.9.0 [\#3184](https://github.com/harness/drone/pull/3184) ([eoinmcafee00](https://github.com/eoinmcafee00))
|
||||
|
||||
## [v2.8.0](https://github.com/harness/drone/tree/v2.8.0) (2022-01-11)
|
||||
|
||||
[Full Changelog](https://github.com/harness/drone/compare/v2.7.3...v2.8.0)
|
||||
|
||||
**Implemented enhancements:**
|
||||
|
||||
- bump UI to v2.5.0 [\#3180](https://github.com/harness/drone/pull/3180) ([eoinmcafee00](https://github.com/eoinmcafee00))
|
||||
- \(feat\) ignore archive repos on sync [\#3178](https://github.com/harness/drone/pull/3178) ([eoinmcafee00](https://github.com/eoinmcafee00))
|
||||
- Datadog add the tag of 'remote:gitee' [\#3174](https://github.com/harness/drone/pull/3174) ([kit101](https://github.com/kit101))
|
||||
- Add tag filter when call build list endpoint [\#3173](https://github.com/harness/drone/pull/3173) ([michelangelomo](https://github.com/michelangelomo))
|
||||
|
||||
**Fixed bugs:**
|
||||
|
||||
- \(maint\) add warning around typo for stage\_id in step struct [\#3179](https://github.com/harness/drone/pull/3179) ([tphoney](https://github.com/tphoney))
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- release prep v2.8.0 [\#3181](https://github.com/harness/drone/pull/3181) ([eoinmcafee00](https://github.com/eoinmcafee00))
|
||||
|
||||
## [v2.7.3](https://github.com/harness/drone/tree/v2.7.3) (2021-12-30)
|
||||
|
||||
[Full Changelog](https://github.com/harness/drone/compare/v2.7.2...v2.7.3)
|
||||
|
||||
**Fixed bugs:**
|
||||
|
||||
- bump go-scm to v1.16.3 [\#3175](https://github.com/harness/drone/pull/3175) ([eoinmcafee00](https://github.com/eoinmcafee00))
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- release prep v2.7.3 [\#3176](https://github.com/harness/drone/pull/3176) ([eoinmcafee00](https://github.com/eoinmcafee00))
|
||||
|
||||
## [v2.7.2](https://github.com/harness/drone/tree/v2.7.2) (2021-12-19)
|
||||
|
||||
[Full Changelog](https://github.com/harness/drone/compare/v2.7.1...v2.7.2)
|
||||
|
||||
**Implemented enhancements:**
|
||||
|
||||
- bump go-scm to v1.16.2 [\#3169](https://github.com/harness/drone/pull/3169) ([kit101](https://github.com/kit101))
|
||||
|
||||
**Fixed bugs:**
|
||||
|
||||
- fixbug gitee provide refresher [\#3168](https://github.com/harness/drone/pull/3168) ([kit101](https://github.com/kit101))
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- release prep 2.7.2 [\#3172](https://github.com/harness/drone/pull/3172) ([eoinmcafee00](https://github.com/eoinmcafee00))
|
||||
|
||||
## [v2.7.1](https://github.com/harness/drone/tree/v2.7.1) (2021-12-17)
|
||||
|
||||
[Full Changelog](https://github.com/harness/drone/compare/v2.7.0...v2.7.1)
|
||||
|
||||
**Fixed bugs:**
|
||||
|
||||
- fixes issue with redirects on double slashes in url [\#3170](https://github.com/harness/drone/pull/3170) ([eoinmcafee00](https://github.com/eoinmcafee00))
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- release prep v2.7.1 [\#3171](https://github.com/harness/drone/pull/3171) ([eoinmcafee00](https://github.com/eoinmcafee00))
|
||||
|
||||
## [v2.7.0](https://github.com/harness/drone/tree/v2.7.0) (2021-12-15)
|
||||
|
||||
[Full Changelog](https://github.com/harness/drone/compare/v2.6.0...v2.7.0)
|
||||
|
||||
**Implemented enhancements:**
|
||||
|
||||
- bump UI to v2.4.1 [\#3167](https://github.com/harness/drone/pull/3167) ([d1wilko](https://github.com/d1wilko))
|
||||
|
||||
**Fixed bugs:**
|
||||
|
||||
- \(DRON-157\) use deploy string in deployment [\#3165](https://github.com/harness/drone/pull/3165) ([tphoney](https://github.com/tphoney))
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- release v2.7.0 [\#3166](https://github.com/harness/drone/pull/3166) ([d1wilko](https://github.com/d1wilko))
|
||||
|
||||
## [v2.6.0](https://github.com/harness/drone/tree/v2.6.0) (2021-11-30)
|
||||
|
||||
[Full Changelog](https://github.com/harness/drone/compare/v2.5.0...v2.6.0)
|
||||
|
@ -8,6 +182,10 @@
|
|||
|
||||
- Feat: implemented gitee client [\#3156](https://github.com/harness/drone/pull/3156) ([kit101](https://github.com/kit101))
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- release prep for v2.6.0 [\#3163](https://github.com/harness/drone/pull/3163) ([tphoney](https://github.com/tphoney))
|
||||
|
||||
## [v2.5.0](https://github.com/harness/drone/tree/v2.5.0) (2021-11-17)
|
||||
|
||||
[Full Changelog](https://github.com/harness/drone/compare/v2.4.0...v2.5.0)
|
||||
|
|
2
LICENSE
2
LICENSE
|
@ -21,7 +21,7 @@ Drone Non-Commercial License
|
|||
|
||||
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,
|
||||
with a trial-length time limit on commercial use. Specifically:
|
||||
|
|
|
@ -320,6 +320,10 @@ type (
|
|||
SkipVerify bool `envconfig:"DRONE_CONVERT_PLUGIN_SKIP_VERIFY"`
|
||||
CacheSize int `envconfig:"DRONE_CONVERT_PLUGIN_CACHE_SIZE" default:"10"`
|
||||
Timeout time.Duration `envconfig:"DRONE_CONVERT_TIMEOUT" default:"1m"`
|
||||
|
||||
// this flag can be removed once we solve for
|
||||
// https://github.com/harness/drone/pull/2994#issuecomment-795955312
|
||||
Multi bool `envconfig:"DRONE_CONVERT_MULTI"`
|
||||
}
|
||||
|
||||
// Validate provides the validation webhook configuration.
|
||||
|
@ -489,6 +493,12 @@ func (c *Config) IsGitea() bool {
|
|||
return c.Gitea.Server != ""
|
||||
}
|
||||
|
||||
// IsGitee returns true if the Gitee integration
|
||||
// is activated.
|
||||
func (c *Config) IsGitee() bool {
|
||||
return c.Gitee.ClientID != ""
|
||||
}
|
||||
|
||||
// IsBitbucket returns true if the Bitbucket Cloud
|
||||
// integration is activated.
|
||||
func (c *Config) IsBitbucket() bool {
|
||||
|
|
|
@ -123,8 +123,14 @@ func provideGiteeClient(config config.Config) *scm.Client {
|
|||
}
|
||||
client.Client = &http.Client{
|
||||
Transport: &oauth2.Transport{
|
||||
Source: oauth2.ContextTokenSource(),
|
||||
Base: defaultTransport(config.Gitee.SkipVerify),
|
||||
Scheme: oauth2.SchemeBearer,
|
||||
Source: &oauth2.Refresher{
|
||||
ClientID: config.Gitee.ClientID,
|
||||
ClientSecret: config.Gitee.ClientSecret,
|
||||
Endpoint: strings.TrimSuffix(config.Gitee.Server, "/") + "/oauth/token",
|
||||
Source: oauth2.ContextTokenSource(),
|
||||
},
|
||||
Base: defaultTransport(config.Gitee.SkipVerify),
|
||||
},
|
||||
}
|
||||
return client
|
||||
|
@ -174,7 +180,13 @@ func provideGitlabClient(config config.Config) *scm.Client {
|
|||
}
|
||||
client.Client = &http.Client{
|
||||
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),
|
||||
},
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ func provideGiteaLogin(config config.Config) login.Middleware {
|
|||
if config.Gitea.Server == "" {
|
||||
return nil
|
||||
}
|
||||
return &gitea.Config {
|
||||
return &gitea.Config{
|
||||
ClientID: config.Gitea.ClientID,
|
||||
ClientSecret: config.Gitea.ClientSecret,
|
||||
Server: config.Gitea.Server,
|
||||
|
@ -197,6 +197,23 @@ func provideRefresher(config config.Config) *oauth2.Refresher {
|
|||
Source: oauth2.ContextTokenSource(),
|
||||
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 != "":
|
||||
return &oauth2.Refresher{
|
||||
ClientID: config.Gitee.ClientID,
|
||||
ClientSecret: config.Gitee.ClientSecret,
|
||||
Endpoint: strings.TrimSuffix(config.Gitee.Server, "/") + "/oauth/token",
|
||||
Source: oauth2.ContextTokenSource(),
|
||||
Client: defaultClient(config.Gitee.SkipVerify),
|
||||
}
|
||||
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -78,6 +78,7 @@ func provideConfigPlugin(client *scm.Client, contents core.FileService, conf spe
|
|||
// configuration.
|
||||
func provideConvertPlugin(client *scm.Client, fileService core.FileService, conf spec.Config, templateStore core.TemplateStore) core.ConvertService {
|
||||
return converter.Combine(
|
||||
conf.Convert.Multi,
|
||||
converter.Legacy(false),
|
||||
converter.Starlark(
|
||||
conf.Starlark.Enabled,
|
||||
|
|
|
@ -212,6 +212,7 @@ func provideDatadog(
|
|||
EnableStash: config.IsStash(),
|
||||
EnableGogs: config.IsGogs(),
|
||||
EnableGitea: config.IsGitea(),
|
||||
EnableGitee: config.IsGitee(),
|
||||
EnableAgents: !config.Agent.Disabled,
|
||||
},
|
||||
)
|
||||
|
|
|
@ -65,6 +65,7 @@ type (
|
|||
Secret string `json:"-"`
|
||||
Build *Build `json:"build,omitempty"`
|
||||
Perms *Perm `json:"permissions,omitempty"`
|
||||
Archived bool `json:"archived"`
|
||||
}
|
||||
|
||||
RepoBuildStage struct {
|
||||
|
|
|
@ -20,7 +20,7 @@ type (
|
|||
// Step represents an individual step in the stage.
|
||||
Step struct {
|
||||
ID int64 `json:"id"`
|
||||
StageID int64 `json:"step_id"`
|
||||
StageID int64 `json:"step_id"` // this is a typo, fixing it has far reaching ramifications. It should only be attempted in a major version change
|
||||
Number int `json:"number"`
|
||||
Name string `json:"name"`
|
||||
Status string `json:"status"`
|
||||
|
|
6
go.mod
6
go.mod
|
@ -12,15 +12,15 @@ require (
|
|||
github.com/coreos/go-semver v0.2.0
|
||||
github.com/dchest/authcookie v0.0.0-20120917135355-fbdef6e99866
|
||||
github.com/dchest/uniuri v0.0.0-20160212164326-8902c56451e9
|
||||
github.com/drone/drone-go v1.4.1-0.20201109202657-b9e58bbbcf27
|
||||
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-ui v2.4.0+incompatible
|
||||
github.com/drone/drone-ui v2.8.2+incompatible
|
||||
github.com/drone/drone-yaml v1.2.4-0.20200326192514-6f4d6dfb39e4
|
||||
github.com/drone/envsubst v1.0.3-0.20200709231038-aa43e1c1a629
|
||||
github.com/drone/funcmap v0.0.0-20210823160631-9e9dec149056
|
||||
github.com/drone/go-license v1.0.2
|
||||
github.com/drone/go-login v1.1.0
|
||||
github.com/drone/go-scm v1.16.1
|
||||
github.com/drone/go-scm v1.24.0
|
||||
github.com/drone/signal v1.0.0
|
||||
github.com/dustin/go-humanize v1.0.0
|
||||
github.com/go-chi/chi v3.3.3+incompatible
|
||||
|
|
14
go.sum
14
go.sum
|
@ -73,15 +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-units v0.3.3 h1:Xk8S3Xj5sLGlG5g67hJmYMmUgXv5N4PhkjJHHqrwnTk=
|
||||
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.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-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/go.mod h1:4/2QToW5+HGD0y1sTw7X35W1f7YINS14UfDY4isggT8=
|
||||
github.com/drone/drone-ui v2.3.1+incompatible h1:JYOer5JRttNjXGJhJnH/ELksr3ORO/OWZS19VdlGtro=
|
||||
github.com/drone/drone-ui v2.3.1+incompatible/go.mod h1:NBtVWW7NNJpD9+huMD/5TAE1db2nrEh0i35/9Rf1MPI=
|
||||
github.com/drone/drone-ui v2.4.0+incompatible h1:AEuauuZRe8n2vj97/QWCugBEnUOkV/iVVaUYR1ipiQ4=
|
||||
github.com/drone/drone-ui v2.4.0+incompatible/go.mod h1:NBtVWW7NNJpD9+huMD/5TAE1db2nrEh0i35/9Rf1MPI=
|
||||
github.com/drone/drone-ui v2.8.2+incompatible h1:7F/MlcSEIZVi5VND/qmOnDDwQOkgqwsCVOQOsGJ2HJc=
|
||||
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/go.mod h1:QsqliFK8nG04AHFN9tTn9XJomRBQHD4wcejWW1uz/10=
|
||||
github.com/drone/envsubst v1.0.3-0.20200709231038-aa43e1c1a629 h1:rIaZZalMGGPb2cU/+ypuggZ8aMlpa17RUlJUtsMv8pw=
|
||||
|
@ -92,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-login v1.1.0 h1:anQFRh2Z5ketEJ/LvL6SJ6rIwDdfysGXK5bSXkFLInI=
|
||||
github.com/drone/go-login v1.1.0/go.mod h1:FLxy9vRzLbyBxoCJYxGbG9R0WGn6OyuvBmAtYNt43uw=
|
||||
github.com/drone/go-scm v1.16.1 h1:OuCJ/d9iUzxSDqryOn5EW2sdOK92gSSMLhMe9Vf+r3c=
|
||||
github.com/drone/go-scm v1.16.1/go.mod h1:DFIJJjhMj0TSXPz+0ni4nyZ9gtTtC40Vh/TGRugtyWw=
|
||||
github.com/drone/go-scm v1.24.0 h1:wE6bP9gnuyyKJStnl6wl0npt/SBQumjE9jilQAcFy6Q=
|
||||
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/go.mod h1:S8t92eFT0g4WUgEc/LxG+LCuiskpMNsG0ajAMGnyZpc=
|
||||
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
|
||||
|
|
|
@ -37,6 +37,7 @@ func HandleList(
|
|||
namespace = chi.URLParam(r, "owner")
|
||||
name = chi.URLParam(r, "name")
|
||||
branch = r.FormValue("branch")
|
||||
tag = r.FormValue("tag")
|
||||
page = r.FormValue("page")
|
||||
perPage = r.FormValue("per_page")
|
||||
)
|
||||
|
@ -66,6 +67,9 @@ func HandleList(
|
|||
if branch != "" {
|
||||
ref := fmt.Sprintf("refs/heads/%s", branch)
|
||||
results, err = builds.ListRef(r.Context(), repo.ID, ref, limit, offset)
|
||||
} else if tag != "" {
|
||||
ref := fmt.Sprintf("refs/tags/%s", tag)
|
||||
results, err = builds.ListRef(r.Context(), repo.ID, ref, limit, offset)
|
||||
} else {
|
||||
results, err = builds.List(r.Context(), repo.ID, limit, offset)
|
||||
}
|
||||
|
|
|
@ -139,6 +139,38 @@ func TestListBranch(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestListTag(t *testing.T) {
|
||||
controller := gomock.NewController(t)
|
||||
defer controller.Finish()
|
||||
|
||||
repos := mock.NewMockRepositoryStore(controller)
|
||||
repos.EXPECT().FindName(gomock.Any(), gomock.Any(), mockRepo.Name).Return(mockRepo, nil)
|
||||
|
||||
builds := mock.NewMockBuildStore(controller)
|
||||
builds.EXPECT().ListRef(gomock.Any(), mockRepo.ID, "refs/tags/1.33.7", 25, 0).Return(mockBuilds, nil)
|
||||
|
||||
c := new(chi.Context)
|
||||
c.URLParams.Add("owner", "octocat")
|
||||
c.URLParams.Add("name", "hello-world")
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
r := httptest.NewRequest("GET", "/?tag=1.33.7", nil)
|
||||
r = r.WithContext(
|
||||
context.WithValue(context.Background(), chi.RouteCtxKey, c),
|
||||
)
|
||||
|
||||
HandleList(repos, builds)(w, r)
|
||||
if got, want := w.Code, 200; want != got {
|
||||
t.Errorf("Want response code %d, got %d", want, got)
|
||||
}
|
||||
|
||||
got, want := []*core.Build{}, mockBuilds
|
||||
json.NewDecoder(w.Body).Decode(&got)
|
||||
if diff := cmp.Diff(got, want); len(diff) != 0 {
|
||||
t.Errorf(diff)
|
||||
}
|
||||
}
|
||||
|
||||
func TestList_RepositoryNotFound(t *testing.T) {
|
||||
controller := gomock.NewController(t)
|
||||
defer controller.Finish()
|
||||
|
|
|
@ -64,6 +64,7 @@ func HandleRetry(
|
|||
}
|
||||
|
||||
hook := &core.Hook{
|
||||
Parent: prev.Number,
|
||||
Trigger: user.Login,
|
||||
Event: prev.Event,
|
||||
Action: prev.Action,
|
||||
|
|
|
@ -97,7 +97,7 @@ func (s Server) Handler() http.Handler {
|
|||
r.Use(middleware.Recoverer)
|
||||
r.Use(middleware.NoCache)
|
||||
r.Use(logger.Middleware)
|
||||
r.Use(middleware.RedirectSlashes)
|
||||
r.Use(middleware.StripSlashes)
|
||||
|
||||
sec := secure.New(s.Options)
|
||||
r.Use(sec.Handler)
|
||||
|
|
|
@ -29,5 +29,6 @@ type Config struct {
|
|||
EnableStash bool
|
||||
EnableGogs bool
|
||||
EnableGitea bool
|
||||
EnableGitee bool
|
||||
EnableAgents bool
|
||||
}
|
||||
|
|
|
@ -42,6 +42,8 @@ func createTags(config Config) []string {
|
|||
tags = append(tags, "remote:gogs")
|
||||
case config.EnableGitea:
|
||||
tags = append(tags, "remote:gitea")
|
||||
case config.EnableGitee:
|
||||
tags = append(tags, "remote:gitee")
|
||||
default:
|
||||
tags = append(tags, "remote:undefined")
|
||||
}
|
||||
|
|
|
@ -797,3 +797,19 @@ func (mr *MockUserServiceMockRecorder) FindLogin(arg0, arg1 interface{}) *gomock
|
|||
mr.mock.ctrl.T.Helper()
|
||||
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)
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Use of this source code is governed by the Drone Non-Commercial License
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
//go:build !oss
|
||||
// +build !oss
|
||||
|
||||
package config
|
||||
|
@ -33,7 +34,7 @@ func Global(endpoint, signer string, skipVerify bool, timeout time.Duration) cor
|
|||
}
|
||||
|
||||
type global struct {
|
||||
client config.Plugin
|
||||
client config.Plugin
|
||||
timeout time.Duration
|
||||
}
|
||||
|
||||
|
@ -51,6 +52,10 @@ func (g *global) Find(ctx context.Context, in *core.ConfigArgs) (*core.Config, e
|
|||
req := &config.Request{
|
||||
Repo: toRepo(in.Repo),
|
||||
Build: toBuild(in.Build),
|
||||
Token: drone.Token{
|
||||
Access: in.User.Token,
|
||||
Refresh: in.User.Refresh,
|
||||
},
|
||||
}
|
||||
|
||||
res, err := g.client.Find(ctx, req)
|
||||
|
|
|
@ -22,12 +22,16 @@ import (
|
|||
|
||||
// Combine combines the conversion services, provision support
|
||||
// for multiple conversion utilities.
|
||||
func Combine(services ...core.ConvertService) core.ConvertService {
|
||||
return &combined{services}
|
||||
func Combine(multi bool, services ...core.ConvertService) core.ConvertService {
|
||||
return &combined{multi: multi, sources: services}
|
||||
}
|
||||
|
||||
type combined struct {
|
||||
sources []core.ConvertService
|
||||
|
||||
// this feature flag can be removed once we solve for
|
||||
// https://github.com/harness/drone/pull/2994#issuecomment-795955312
|
||||
multi bool
|
||||
}
|
||||
|
||||
func (c *combined) Convert(ctx context.Context, req *core.ConvertArgs) (*core.Config, error) {
|
||||
|
@ -42,7 +46,11 @@ func (c *combined) Convert(ctx context.Context, req *core.ConvertArgs) (*core.Co
|
|||
if config.Data == "" {
|
||||
continue
|
||||
}
|
||||
return config, nil
|
||||
if c.multi {
|
||||
req.Config = config
|
||||
} else {
|
||||
return config, nil
|
||||
}
|
||||
}
|
||||
return req.Config, nil
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ func TestCombine(t *testing.T) {
|
|||
service := mock.NewMockConvertService(controller)
|
||||
service.EXPECT().Convert(noContext, args).Return(resp, nil)
|
||||
|
||||
result, err := Combine(service).Convert(noContext, args)
|
||||
result, err := Combine(false, service).Convert(noContext, args)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
|
@ -58,7 +58,7 @@ func TestCombineErr(t *testing.T) {
|
|||
service := mock.NewMockConvertService(controller)
|
||||
service.EXPECT().Convert(noContext, nil).Return(nil, resp)
|
||||
|
||||
_, err := Combine(service).Convert(noContext, nil)
|
||||
_, err := Combine(false, service).Convert(noContext, nil)
|
||||
if err != resp {
|
||||
t.Errorf("expected convert service error")
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ func TestCombineNoConfig(t *testing.T) {
|
|||
service3 := mock.NewMockConvertService(controller)
|
||||
service3.EXPECT().Convert(noContext, args).Return(resp, nil)
|
||||
|
||||
result, err := Combine(service1, service2, service3).Convert(noContext, args)
|
||||
result, err := Combine(false, service1, service2, service3).Convert(noContext, args)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
|
@ -110,7 +110,7 @@ func TestCombineEmptyConfig(t *testing.T) {
|
|||
service1 := mock.NewMockConvertService(controller)
|
||||
service1.EXPECT().Convert(noContext, args).Return(nil, nil)
|
||||
|
||||
result, err := Combine(service1).Convert(noContext, args)
|
||||
result, err := Combine(false, service1).Convert(noContext, args)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
|
|
|
@ -2,6 +2,8 @@ package jsonnet
|
|||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/drone/drone/core"
|
||||
|
@ -44,13 +46,19 @@ func TestParse(t *testing.T) {
|
|||
|
||||
req.Config.Data = string(before)
|
||||
|
||||
parsedFile, err := Parse(req, nil, 0, template, templateData)
|
||||
got, err := Parse(req, nil, 0, template, templateData)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -82,13 +90,19 @@ func TestParseJsonnetNotTemplateFile(t *testing.T) {
|
|||
req.Repo.Config = "plugin.jsonnet"
|
||||
req.Config.Data = string(before)
|
||||
|
||||
parsedFile, err := Parse(req, nil, 0, nil, nil)
|
||||
got, err := Parse(req, nil, 0, nil, nil)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Use of this source code is governed by the Drone Non-Commercial License
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
//go:build !oss
|
||||
// +build !oss
|
||||
|
||||
package converter
|
||||
|
@ -36,7 +37,7 @@ func Remote(endpoint, signer, extension string, skipVerify bool, timeout time.Du
|
|||
type remote struct {
|
||||
client converter.Plugin
|
||||
extension string
|
||||
timeout time.Duration
|
||||
timeout time.Duration
|
||||
}
|
||||
|
||||
func (g *remote) Convert(ctx context.Context, in *core.ConvertArgs) (*core.Config, error) {
|
||||
|
@ -61,6 +62,10 @@ func (g *remote) Convert(ctx context.Context, in *core.ConvertArgs) (*core.Confi
|
|||
Config: drone.Config{
|
||||
Data: in.Config.Data,
|
||||
},
|
||||
Token: drone.Token{
|
||||
Access: in.User.Token,
|
||||
Refresh: in.User.Refresh,
|
||||
},
|
||||
}
|
||||
|
||||
res, err := g.client.Convert(ctx, req)
|
||||
|
|
|
@ -16,6 +16,8 @@ package converter
|
|||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/drone/drone/core"
|
||||
|
@ -117,7 +119,14 @@ func TestConvert_Multi(t *testing.T) {
|
|||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@ package converter
|
|||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/drone/drone/core"
|
||||
|
@ -234,7 +236,14 @@ func TestTemplatePluginConvertJsonnet(t *testing.T) {
|
|||
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)
|
||||
}
|
||||
}
|
||||
|
@ -388,6 +397,7 @@ func TestTemplatePluginConvertYaml(t *testing.T) {
|
|||
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
|
||||
// and refers to it in the drone.yml file
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
8
plugin/converter/testdata/yaml.template.comment.yml
vendored
Normal file
8
plugin/converter/testdata/yaml.template.comment.yml
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
# this is a comment
|
||||
kind: template
|
||||
load: plugin.yaml
|
||||
data:
|
||||
stepName: my_step
|
||||
image: my_image
|
||||
commands: my_command
|
|
@ -57,7 +57,9 @@ func (s *service) List(ctx context.Context, user *core.User) ([]*core.Repository
|
|||
return nil, err
|
||||
}
|
||||
for _, src := range result {
|
||||
repos = append(repos, convertRepository(src, s.visibility, s.trusted))
|
||||
if src != nil {
|
||||
repos = append(repos, convertRepository(src, s.visibility, s.trusted))
|
||||
}
|
||||
}
|
||||
opts.Page = meta.Page.Next
|
||||
opts.URL = meta.Page.NextURL
|
||||
|
|
|
@ -246,3 +246,44 @@ func TestList_RefreshErr(t *testing.T) {
|
|||
t.Errorf("Expect error refreshing token")
|
||||
}
|
||||
}
|
||||
|
||||
func TestListWithNilRepo(t *testing.T) {
|
||||
controller := gomock.NewController(t)
|
||||
defer controller.Finish()
|
||||
|
||||
mockUser := &core.User{}
|
||||
mockRepos := []*scm.Repository{
|
||||
{
|
||||
Namespace: "octocat",
|
||||
Name: "hello-world",
|
||||
},
|
||||
nil,
|
||||
}
|
||||
|
||||
mockRepoService := mockscm.NewMockRepositoryService(controller)
|
||||
mockRepoService.EXPECT().List(gomock.Any(), gomock.Any()).Return(mockRepos, &scm.Response{}, nil)
|
||||
|
||||
mockRenewer := mock.NewMockRenewer(controller)
|
||||
mockRenewer.EXPECT().Renew(gomock.Any(), mockUser, false)
|
||||
|
||||
client := new(scm.Client)
|
||||
client.Repositories = mockRepoService
|
||||
|
||||
want := []*core.Repository{
|
||||
{
|
||||
Namespace: "octocat",
|
||||
Name: "hello-world",
|
||||
Slug: "octocat/hello-world",
|
||||
Visibility: "public",
|
||||
},
|
||||
}
|
||||
|
||||
service := New(client, mockRenewer, "", false)
|
||||
got, err := service.List(noContext, mockUser)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if diff := cmp.Diff(got, want); diff != "" {
|
||||
t.Errorf(diff)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ func convertRepository(src *scm.Repository, visibility string, trusted bool) *co
|
|||
Visibility: convertVisibility(src, visibility),
|
||||
Branch: src.Branch,
|
||||
Trusted: trusted,
|
||||
Archived: src.Archived,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ func (s *service) Send(ctx context.Context, user *core.User, req *core.StatusInp
|
|||
Desc: createDesc(req.Build.Status),
|
||||
State: convertStatus(req.Build.Status),
|
||||
Target: fmt.Sprintf("%s/%s/%d", s.base, req.Repo.Slug, req.Build.Number),
|
||||
Environment: req.Build.Target,
|
||||
Environment: req.Build.Deploy,
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -105,7 +105,6 @@ func TestCreateDesc(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestConvertStatus(t *testing.T) {
|
||||
|
||||
tests := []struct {
|
||||
from string
|
||||
to scm.State
|
||||
|
|
|
@ -16,6 +16,7 @@ package syncer
|
|||
|
||||
import (
|
||||
"context"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -66,7 +67,7 @@ func (s *Synchronizer) Sync(ctx context.Context, user *core.User) (*core.Batch,
|
|||
// a panic that should absolutely never happen.
|
||||
if err := recover(); err != nil {
|
||||
logger = logger.WithField("error", err)
|
||||
logger.Errorln("syncer: unexpected panic")
|
||||
logger.Errorf("syncer: unexpected panic\n%s\n", debug.Stack())
|
||||
}
|
||||
|
||||
// when the synchronization process is complete
|
||||
|
@ -110,6 +111,13 @@ func (s *Synchronizer) Sync(ctx context.Context, user *core.User) (*core.Batch,
|
|||
WithField("uid", repo.UID).
|
||||
Traceln("syncer: skipping subrepositories")
|
||||
}
|
||||
} else if repo.Archived {
|
||||
if logrus.GetLevel() == logrus.TraceLevel {
|
||||
logger.WithField("namespace", repo.Namespace).
|
||||
WithField("name", repo.Name).
|
||||
WithField("uid", repo.UID).
|
||||
Traceln("syncer: skipping archived repositories")
|
||||
}
|
||||
} else if s.match(repo) {
|
||||
remote[repo.UID] = repo
|
||||
if logrus.GetLevel() == logrus.TraceLevel {
|
||||
|
|
|
@ -434,3 +434,52 @@ func TestSync_SkipSubrepo(t *testing.T) {
|
|||
t.Errorf(diff)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSyncArchive(t *testing.T) {
|
||||
controller := gomock.NewController(t)
|
||||
defer controller.Finish()
|
||||
|
||||
user := &core.User{ID: 1}
|
||||
|
||||
userStore := mock.NewMockUserStore(controller)
|
||||
userStore.EXPECT().Update(gomock.Any(), user).Return(nil)
|
||||
userStore.EXPECT().Update(gomock.Any(), user).Return(nil)
|
||||
|
||||
batcher := mock.NewMockBatcher(controller)
|
||||
batcher.EXPECT().Batch(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil)
|
||||
|
||||
repoStore := mock.NewMockRepositoryStore(controller)
|
||||
repoStore.EXPECT().List(gomock.Any(), gomock.Any()).Return([]*core.Repository{}, nil)
|
||||
|
||||
repoService := mock.NewMockRepositoryService(controller)
|
||||
repoService.EXPECT().List(gomock.Any(), user).Return([]*core.Repository{
|
||||
{
|
||||
UID: "1",
|
||||
Slug: "octocat/hello-world",
|
||||
Namespace: "octocat",
|
||||
Name: "hello-world",
|
||||
Private: false,
|
||||
Visibility: core.VisibilityPublic,
|
||||
Archived: true,
|
||||
},
|
||||
}, nil)
|
||||
|
||||
s := New(
|
||||
repoService,
|
||||
repoStore,
|
||||
userStore,
|
||||
batcher,
|
||||
)
|
||||
got, err := s.Sync(context.Background(), user)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
want := &core.Batch{}
|
||||
|
||||
ignore := cmpopts.IgnoreFields(core.Repository{},
|
||||
"Synced", "Created", "Updated")
|
||||
if diff := cmp.Diff(got, want, ignore); len(diff) != 0 {
|
||||
t.Errorf(diff)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ func Connect() (*db.DB, error) {
|
|||
func Reset(d *db.DB) {
|
||||
d.Lock(func(tx db.Execer, _ db.Binder) error {
|
||||
tx.Exec("DELETE FROM cron")
|
||||
tx.Exec("DELETE FROM cards")
|
||||
tx.Exec("DELETE FROM logs")
|
||||
tx.Exec("DELETE FROM steps")
|
||||
tx.Exec("DELETE FROM stages")
|
||||
|
@ -56,6 +57,7 @@ func Reset(d *db.DB) {
|
|||
tx.Exec("DELETE FROM perms")
|
||||
tx.Exec("DELETE FROM repos")
|
||||
tx.Exec("DELETE FROM users")
|
||||
tx.Exec("DELETE FROM templates")
|
||||
tx.Exec("DELETE FROM orgsecrets")
|
||||
return nil
|
||||
})
|
||||
|
|
|
@ -160,6 +160,10 @@ var migrations = []struct {
|
|||
name: "create-table-template",
|
||||
stmt: createTableTemplate,
|
||||
},
|
||||
{
|
||||
name: "create-index-template-namespace",
|
||||
stmt: createIndexTemplateNamespace,
|
||||
},
|
||||
{
|
||||
name: "alter-table-steps-add-column-step-depends-on",
|
||||
stmt: alterTableStepsAddColumnStepDependsOn,
|
||||
|
@ -692,14 +696,16 @@ CREATE INDEX IF NOT EXISTS ix_latest_repo ON latest (latest_repo_id);
|
|||
var createTableTemplate = `
|
||||
CREATE TABLE IF NOT EXISTS templates (
|
||||
template_id SERIAL PRIMARY KEY
|
||||
,template_name TEXT UNIQUE
|
||||
,template_name TEXT
|
||||
,template_namespace VARCHAR(50)
|
||||
,template_data BYTEA
|
||||
,template_created INTEGER
|
||||
,template_updated INTEGER
|
||||
,UNIQUE(template_name, template_namespace)
|
||||
);
|
||||
`
|
||||
|
||||
var createIndexTemplateNamespace = `
|
||||
CREATE INDEX IF NOT EXISTS ix_template_namespace ON templates (template_namespace);
|
||||
`
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
CREATE TABLE IF NOT EXISTS templates (
|
||||
template_id SERIAL PRIMARY KEY
|
||||
,template_name TEXT UNIQUE
|
||||
,template_name TEXT
|
||||
,template_namespace VARCHAR(50)
|
||||
,template_data BYTEA
|
||||
,template_created INTEGER
|
||||
|
@ -10,4 +10,6 @@ CREATE TABLE IF NOT EXISTS templates (
|
|||
,UNIQUE(template_name, template_namespace)
|
||||
);
|
||||
|
||||
-- name: create-index-template-namespace
|
||||
|
||||
CREATE INDEX IF NOT EXISTS ix_template_namespace ON templates (template_namespace);
|
||||
|
|
|
@ -160,6 +160,10 @@ var migrations = []struct {
|
|||
name: "create-table-templates",
|
||||
stmt: createTableTemplates,
|
||||
},
|
||||
{
|
||||
name: "create-index-template-namespace",
|
||||
stmt: createIndexTemplateNamespace,
|
||||
},
|
||||
{
|
||||
name: "alter-table-steps-add-column-step-depends-on",
|
||||
stmt: alterTableStepsAddColumnStepDependsOn,
|
||||
|
@ -694,14 +698,16 @@ CREATE INDEX IF NOT EXISTS ix_latest_repo ON latest (latest_repo_id);
|
|||
var createTableTemplates = `
|
||||
CREATE TABLE IF NOT EXISTS templates (
|
||||
template_id INTEGER PRIMARY KEY AUTOINCREMENT
|
||||
,template_name TEXT UNIQUE
|
||||
,template_name TEXT
|
||||
,template_namespace TEXT COLLATE NOCASE
|
||||
,template_data BLOB
|
||||
,template_created 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);
|
||||
`
|
||||
|
||||
|
|
|
@ -2,12 +2,14 @@
|
|||
|
||||
CREATE TABLE IF NOT EXISTS templates (
|
||||
template_id INTEGER PRIMARY KEY AUTOINCREMENT
|
||||
,template_name TEXT UNIQUE
|
||||
,template_name TEXT
|
||||
,template_namespace TEXT COLLATE NOCASE
|
||||
,template_data BLOB
|
||||
,template_created 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);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Use of this source code is governed by the Drone Non-Commercial License
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
//go:build !oss
|
||||
// +build !oss
|
||||
|
||||
package template
|
||||
|
@ -29,7 +30,7 @@ func TestTemplate(t *testing.T) {
|
|||
}()
|
||||
|
||||
store := New(conn).(*templateStore)
|
||||
t.Run("Create", testTemplateCreate(store))
|
||||
t.Run("TestTemplates", testTemplateCreate(store))
|
||||
}
|
||||
|
||||
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.Run("CreateSameNameDiffOrg", testCreateWithSameNameDiffOrg(store))
|
||||
t.Run("CreateSameNameSameOrgShouldError", testCreateSameNameSameOrgShouldError(store))
|
||||
t.Run("Find", testTemplateFind(store, item))
|
||||
t.Run("FindName", testTemplateFindName(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) {
|
||||
return func(t *testing.T) {
|
||||
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) {
|
||||
return func(t *testing.T) {
|
||||
list, err := store.ListAll(noContext)
|
||||
|
@ -102,10 +156,11 @@ func testTemplateListAll(store *templateStore) func(t *testing.T) {
|
|||
t.Error(err)
|
||||
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)
|
||||
} else {
|
||||
t.Run("Fields", testTemplate(list[0]))
|
||||
t.Run("Fields", testTemplate2(list[1]))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,9 +25,9 @@ var (
|
|||
// VersionMajor is for an API incompatible changes.
|
||||
VersionMajor int64 = 2
|
||||
// VersionMinor is for functionality in a backwards-compatible manner.
|
||||
VersionMinor int64 = 6
|
||||
VersionMinor int64 = 12
|
||||
// VersionPatch is for backwards-compatible bug fixes.
|
||||
VersionPatch int64 = 0
|
||||
VersionPatch int64 = 1
|
||||
// VersionPre indicates prerelease.
|
||||
VersionPre = ""
|
||||
// VersionDev indicates development branch. Releases will be empty string.
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Use of this source code is governed by the Drone Non-Commercial License
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
//go:build !oss
|
||||
// +build !oss
|
||||
|
||||
package version
|
||||
|
@ -9,7 +10,7 @@ package version
|
|||
import "testing"
|
||||
|
||||
func TestVersion(t *testing.T) {
|
||||
if got, want := Version.String(), "2.6.0"; got != want {
|
||||
if got, want := Version.String(), "2.12.1"; got != want {
|
||||
t.Errorf("Want version %s, got %s", want, got)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue