Compare commits
1 commit
Author | SHA1 | Date | |
---|---|---|---|
|
8316e7474d |
45 changed files with 73 additions and 637 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://community.harness.io/
|
||||
https://community.harness.io/c/bugs/17
|
||||
https://community.harness.io/c/ideas/11
|
||||
https://discourse.drone.io/
|
||||
https://discourse.drone.io/c/bugs
|
||||
https://discourse.drone.io/c/ideas
|
||||
|
||||
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 and Support](#community-and-support)
|
||||
- [Community](#community)
|
||||
- [Contributing](#contributing)
|
||||
- [Code of Conduct](#code-of-conduct)
|
||||
- [Setup Documentation](#setup-documentation)
|
||||
|
@ -17,18 +17,13 @@ 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 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).
|
||||
## 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).
|
||||
|
||||
## Contributing
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
|
@ -107,7 +102,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 fulfill the requirements, do not add a label.
|
||||
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.
|
||||
|
||||
**Before moving on make sure to update the version file `version/version.go && version/version_test.go`.**
|
||||
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
since-tag=v2.0.4
|
||||
issues=false
|
||||
|
||||
|
|
178
CHANGELOG.md
178
CHANGELOG.md
|
@ -1,179 +1,5 @@
|
|||
# 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)
|
||||
|
@ -182,10 +8,6 @@
|
|||
|
||||
- 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/harness/drone
|
||||
Source Code: https://github.com/drone/drone
|
||||
|
||||
This license lets you use and share this software for free,
|
||||
with a trial-length time limit on commercial use. Specifically:
|
||||
|
|
|
@ -320,10 +320,6 @@ 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.
|
||||
|
@ -493,12 +489,6 @@ 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,14 +123,8 @@ func provideGiteeClient(config config.Config) *scm.Client {
|
|||
}
|
||||
client.Client = &http.Client{
|
||||
Transport: &oauth2.Transport{
|
||||
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),
|
||||
Source: oauth2.ContextTokenSource(),
|
||||
Base: defaultTransport(config.Gitee.SkipVerify),
|
||||
},
|
||||
}
|
||||
return client
|
||||
|
@ -180,13 +174,7 @@ func provideGitlabClient(config config.Config) *scm.Client {
|
|||
}
|
||||
client.Client = &http.Client{
|
||||
Transport: &oauth2.Transport{
|
||||
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(),
|
||||
},
|
||||
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,23 +197,6 @@ 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,7 +78,6 @@ 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,7 +212,6 @@ func provideDatadog(
|
|||
EnableStash: config.IsStash(),
|
||||
EnableGogs: config.IsGogs(),
|
||||
EnableGitea: config.IsGitea(),
|
||||
EnableGitee: config.IsGitee(),
|
||||
EnableAgents: !config.Agent.Disabled,
|
||||
},
|
||||
)
|
||||
|
|
|
@ -65,7 +65,6 @@ 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"` // this is a typo, fixing it has far reaching ramifications. It should only be attempted in a major version change
|
||||
StageID int64 `json:"step_id"`
|
||||
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.7.2-0.20220308165842-f9e4fe31c2af
|
||||
github.com/drone/drone-go v1.4.1-0.20201109202657-b9e58bbbcf27
|
||||
github.com/drone/drone-runtime v1.1.1-0.20200623162453-61e33e2cab5d
|
||||
github.com/drone/drone-ui v2.8.2+incompatible
|
||||
github.com/drone/drone-ui v2.4.0+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.24.0
|
||||
github.com/drone/go-scm v1.16.1
|
||||
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,13 +73,15 @@ 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.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.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-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.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-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-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=
|
||||
|
@ -90,8 +92,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.24.0 h1:wE6bP9gnuyyKJStnl6wl0npt/SBQumjE9jilQAcFy6Q=
|
||||
github.com/drone/go-scm v1.24.0/go.mod h1:DFIJJjhMj0TSXPz+0ni4nyZ9gtTtC40Vh/TGRugtyWw=
|
||||
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/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,7 +37,6 @@ 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")
|
||||
)
|
||||
|
@ -67,9 +66,6 @@ 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,38 +139,6 @@ 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,7 +64,6 @@ 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.StripSlashes)
|
||||
r.Use(middleware.RedirectSlashes)
|
||||
|
||||
sec := secure.New(s.Options)
|
||||
r.Use(sec.Handler)
|
||||
|
|
|
@ -29,6 +29,5 @@ type Config struct {
|
|||
EnableStash bool
|
||||
EnableGogs bool
|
||||
EnableGitea bool
|
||||
EnableGitee bool
|
||||
EnableAgents bool
|
||||
}
|
||||
|
|
|
@ -42,8 +42,6 @@ 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,19 +797,3 @@ 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)
|
||||
}
|
||||
|
|
|
@ -212,14 +212,25 @@ func (t *teardown) do(ctx context.Context, stage *core.Stage) error {
|
|||
// cancelDownstream is a helper function that tests for
|
||||
// downstream stages and cancels them based on the overall
|
||||
// pipeline state.
|
||||
|
||||
func depFailed(listOne, listTwo []string) bool {
|
||||
for _, i := range listOne {
|
||||
for _, j := range listTwo {
|
||||
if i == j {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
func (t *teardown) cancelDownstream(
|
||||
ctx context.Context,
|
||||
stages []*core.Stage,
|
||||
) error {
|
||||
failed := false
|
||||
failedStages := []string{}
|
||||
for _, s := range stages {
|
||||
if s.IsFailed() {
|
||||
failed = true
|
||||
failedStages = append(failedStages, s.Name)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -230,10 +241,10 @@ func (t *teardown) cancelDownstream(
|
|||
}
|
||||
|
||||
var skip bool
|
||||
if failed == true && s.OnFailure == false {
|
||||
if depFailed(s.DependsOn, failedStages) == true && s.OnFailure == false {
|
||||
skip = true
|
||||
}
|
||||
if failed == false && s.OnSuccess == false {
|
||||
if depFailed(s.DependsOn, failedStages) == false && s.OnSuccess == false {
|
||||
skip = true
|
||||
}
|
||||
if skip == false {
|
||||
|
@ -249,7 +260,7 @@ func (t *teardown) cancelDownstream(
|
|||
"stage.id": s.ID,
|
||||
"stage.on_success": s.OnSuccess,
|
||||
"stage.on_failure": s.OnFailure,
|
||||
"stage.is_failure": failed,
|
||||
"stage.is_failure": failedStages,
|
||||
"stage.depends_on": s.DependsOn,
|
||||
},
|
||||
)
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
// 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
|
||||
|
@ -34,7 +33,7 @@ func Global(endpoint, signer string, skipVerify bool, timeout time.Duration) cor
|
|||
}
|
||||
|
||||
type global struct {
|
||||
client config.Plugin
|
||||
client config.Plugin
|
||||
timeout time.Duration
|
||||
}
|
||||
|
||||
|
@ -52,10 +51,6 @@ 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,16 +22,12 @@ import (
|
|||
|
||||
// Combine combines the conversion services, provision support
|
||||
// for multiple conversion utilities.
|
||||
func Combine(multi bool, services ...core.ConvertService) core.ConvertService {
|
||||
return &combined{multi: multi, sources: services}
|
||||
func Combine(services ...core.ConvertService) core.ConvertService {
|
||||
return &combined{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) {
|
||||
|
@ -46,11 +42,7 @@ func (c *combined) Convert(ctx context.Context, req *core.ConvertArgs) (*core.Co
|
|||
if config.Data == "" {
|
||||
continue
|
||||
}
|
||||
if c.multi {
|
||||
req.Config = config
|
||||
} else {
|
||||
return config, nil
|
||||
}
|
||||
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(false, service).Convert(noContext, args)
|
||||
result, err := Combine(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(false, service).Convert(noContext, nil)
|
||||
_, err := Combine(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(false, service1, service2, service3).Convert(noContext, args)
|
||||
result, err := Combine(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(false, service1).Convert(noContext, args)
|
||||
result, err := Combine(service1).Convert(noContext, args)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
|
|
|
@ -2,8 +2,6 @@ package jsonnet
|
|||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/drone/drone/core"
|
||||
|
@ -46,19 +44,13 @@ func TestParse(t *testing.T) {
|
|||
|
||||
req.Config.Data = string(before)
|
||||
|
||||
got, err := Parse(req, nil, 0, template, templateData)
|
||||
parsedFile, err := Parse(req, nil, 0, template, templateData)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
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 {
|
||||
if want, got := parsedFile, string(after); want != got {
|
||||
t.Errorf("Want %q got %q", want, got)
|
||||
}
|
||||
}
|
||||
|
@ -90,19 +82,13 @@ func TestParseJsonnetNotTemplateFile(t *testing.T) {
|
|||
req.Repo.Config = "plugin.jsonnet"
|
||||
req.Config.Data = string(before)
|
||||
|
||||
got, err := Parse(req, nil, 0, nil, nil)
|
||||
parsedFile, err := Parse(req, nil, 0, nil, nil)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
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 {
|
||||
if want, got := parsedFile, string(after); want != got {
|
||||
t.Errorf("Want %q got %q", want, got)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
// 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
|
||||
|
@ -37,7 +36,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) {
|
||||
|
@ -62,10 +61,6 @@ 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,8 +16,6 @@ package converter
|
|||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/drone/drone/core"
|
||||
|
@ -119,14 +117,7 @@ func TestConvert_Multi(t *testing.T) {
|
|||
return
|
||||
}
|
||||
|
||||
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 {
|
||||
if want, got := config.Data, string(after); want != got {
|
||||
t.Errorf("Want %q got %q", want, got)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,6 @@ package converter
|
|||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/drone/drone/core"
|
||||
|
@ -236,14 +234,7 @@ func TestTemplatePluginConvertJsonnet(t *testing.T) {
|
|||
return
|
||||
}
|
||||
|
||||
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 {
|
||||
if want, got := config.Data, string(after); want != got {
|
||||
t.Errorf("Want %q got %q", want, got)
|
||||
}
|
||||
}
|
||||
|
@ -397,7 +388,6 @@ 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) {
|
||||
|
@ -446,65 +436,3 @@ 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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
---
|
||||
# this is a comment
|
||||
kind: template
|
||||
load: plugin.yaml
|
||||
data:
|
||||
stepName: my_step
|
||||
image: my_image
|
||||
commands: my_command
|
|
@ -57,9 +57,7 @@ func (s *service) List(ctx context.Context, user *core.User) ([]*core.Repository
|
|||
return nil, err
|
||||
}
|
||||
for _, src := range result {
|
||||
if src != nil {
|
||||
repos = append(repos, convertRepository(src, s.visibility, s.trusted))
|
||||
}
|
||||
repos = append(repos, convertRepository(src, s.visibility, s.trusted))
|
||||
}
|
||||
opts.Page = meta.Page.Next
|
||||
opts.URL = meta.Page.NextURL
|
||||
|
|
|
@ -246,44 +246,3 @@ 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,7 +35,6 @@ 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.Deploy,
|
||||
Environment: req.Build.Target,
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -105,6 +105,7 @@ func TestCreateDesc(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestConvertStatus(t *testing.T) {
|
||||
|
||||
tests := []struct {
|
||||
from string
|
||||
to scm.State
|
||||
|
|
|
@ -16,7 +16,6 @@ package syncer
|
|||
|
||||
import (
|
||||
"context"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -67,7 +66,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.Errorf("syncer: unexpected panic\n%s\n", debug.Stack())
|
||||
logger.Errorln("syncer: unexpected panic")
|
||||
}
|
||||
|
||||
// when the synchronization process is complete
|
||||
|
@ -111,13 +110,6 @@ 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,52 +434,3 @@ 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,7 +48,6 @@ 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")
|
||||
|
@ -57,7 +56,6 @@ 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,10 +160,6 @@ 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,
|
||||
|
@ -696,16 +692,14 @@ 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
|
||||
,template_name TEXT UNIQUE
|
||||
,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
|
||||
,template_name TEXT UNIQUE
|
||||
,template_namespace VARCHAR(50)
|
||||
,template_data BYTEA
|
||||
,template_created INTEGER
|
||||
|
@ -10,6 +10,4 @@ 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,10 +160,6 @@ 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,
|
||||
|
@ -698,16 +694,14 @@ 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
|
||||
,template_name TEXT UNIQUE
|
||||
,template_namespace TEXT COLLATE NOCASE
|
||||
,template_data BLOB
|
||||
,template_created INTEGER
|
||||
,template_updated INTEGER
|
||||
,UNIQUE(template_name COLLATE NOCASE, template_namespace COLLATE NOCASE)
|
||||
,UNIQUE(template_name, template_namespace)
|
||||
);
|
||||
`
|
||||
|
||||
var createIndexTemplateNamespace = `
|
||||
CREATE INDEX IF NOT EXISTS ix_template_namespace ON templates (template_namespace);
|
||||
`
|
||||
|
||||
|
|
|
@ -2,14 +2,12 @@
|
|||
|
||||
CREATE TABLE IF NOT EXISTS templates (
|
||||
template_id INTEGER PRIMARY KEY AUTOINCREMENT
|
||||
,template_name TEXT
|
||||
,template_name TEXT UNIQUE
|
||||
,template_namespace TEXT COLLATE NOCASE
|
||||
,template_data BLOB
|
||||
,template_created INTEGER
|
||||
,template_updated INTEGER
|
||||
,UNIQUE(template_name COLLATE NOCASE, template_namespace COLLATE NOCASE)
|
||||
,UNIQUE(template_name, template_namespace)
|
||||
);
|
||||
|
||||
-- name: create-index-template-namespace
|
||||
|
||||
CREATE INDEX IF NOT EXISTS ix_template_namespace ON templates (template_namespace);
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
// 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
|
||||
|
@ -30,7 +29,7 @@ func TestTemplate(t *testing.T) {
|
|||
}()
|
||||
|
||||
store := New(conn).(*templateStore)
|
||||
t.Run("TestTemplates", testTemplateCreate(store))
|
||||
t.Run("Create", testTemplateCreate(store))
|
||||
}
|
||||
|
||||
func testTemplateCreate(store *templateStore) func(t *testing.T) {
|
||||
|
@ -51,8 +50,6 @@ 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))
|
||||
|
@ -62,43 +59,6 @@ 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)
|
||||
|
@ -135,20 +95,6 @@ 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)
|
||||
|
@ -156,11 +102,10 @@ func testTemplateListAll(store *templateStore) func(t *testing.T) {
|
|||
t.Error(err)
|
||||
return
|
||||
}
|
||||
if got, want := len(list), 2; got != want {
|
||||
if got, want := len(list), 1; 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 = 12
|
||||
VersionMinor int64 = 6
|
||||
// VersionPatch is for backwards-compatible bug fixes.
|
||||
VersionPatch int64 = 1
|
||||
VersionPatch int64 = 0
|
||||
// VersionPre indicates prerelease.
|
||||
VersionPre = ""
|
||||
// VersionDev indicates development branch. Releases will be empty string.
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
// 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
|
||||
|
@ -10,7 +9,7 @@ package version
|
|||
import "testing"
|
||||
|
||||
func TestVersion(t *testing.T) {
|
||||
if got, want := Version.String(), "2.12.1"; got != want {
|
||||
if got, want := Version.String(), "2.6.0"; got != want {
|
||||
t.Errorf("Want version %s, got %s", want, got)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue