Compare commits

...

38 Commits
v0.2.0 ... main

Author SHA1 Message Date
woodpecker-bot
1842b6efa6 fix(deps): update module golang.org/x/net to v0.26.0 2024-06-09 00:16:37 +00:00
woodpecker-bot
d493cf5c51 chore(deps): update woodpeckerci/plugin-reviewdog-golangci-lint docker tag to v1.59 2024-06-08 00:05:34 +00:00
woodpecker-bot
19c216c533 chore(deps): update golangci/golangci-lint docker tag to v1.59 (#26)
Reviewed-on: https://codeberg.org/woodpecker-plugins/go-plugin/pulls/26
Reviewed-by: qwerty287 <qwerty287@noreply.codeberg.org>
Co-authored-by: woodpecker-bot <woodpecker-bot@obermui.de>
Co-committed-by: woodpecker-bot <woodpecker-bot@obermui.de>
2024-06-02 12:06:57 +00:00
woodpecker-bot
c182818d82 fix(deps): update module github.com/rs/zerolog to v1.33.0 2024-05-25 00:09:55 +00:00
woodpecker-bot
38dcac787e fix(deps): update module golang.org/x/net to v0.25.0 2024-05-11 00:06:54 +00:00
woodpecker-bot
5c32612e8d chore(deps): update golangci/golangci-lint docker tag to v1.58 2024-05-04 00:06:24 +00:00
woodpecker-bot
567908df09 fix(deps): update module github.com/urfave/cli/v2 to v2.27.2 2024-04-28 00:13:40 +00:00
woodpecker-bot
72d3ea674d fix(deps): update module golang.org/x/net to v0.24.0 2024-04-06 00:08:04 +00:00
Lauris BH
ca1f8e48fe Update pipeline with Go code review (#25)
Reviewed-on: https://codeberg.org/woodpecker-plugins/go-plugin/pulls/25
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-committed-by: Lauris BH <lauris@nix.lv>
2024-03-30 15:52:30 +00:00
Lauris BH
b67c23ab79
Set usage text to not display default urfave cli one 2024-03-30 17:33:08 +02:00
woodpecker-bot
f6037e6127 chore(deps): update golangci/golangci-lint docker tag to v1.57 2024-03-23 00:09:05 +00:00
woodpecker-bot
fa7f39a739 fix(deps): update module golang.org/x/net to v0.22.0 2024-03-09 00:11:20 +00:00
woodpecker-bot
0ab802ca5b fix(deps): update module github.com/stretchr/testify to v1.9.0 2024-03-02 00:09:58 +00:00
anbraten
090b4571b4 Add & update some env data (#24)
- Some renamings to be more descriptive
- link -> url
- deprecated all old properties

closes #22

Co-authored-by: Anbraten <6918444+anbraten@users.noreply.github.com>
Reviewed-on: https://codeberg.org/woodpecker-plugins/go-plugin/pulls/24
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: anbraten <anbraten@noreply.codeberg.org>
Co-committed-by: anbraten <anbraten@noreply.codeberg.org>
2024-02-15 18:53:26 +00:00
woodpecker-bot
6a59bd9561 fix(deps): update module golang.org/x/net to v0.21.0 2024-02-08 11:41:26 +00:00
woodpecker-bot
f3134af984 chore(deps): update golangci/golangci-lint docker tag to v1.56 2024-02-08 11:06:03 +00:00
woodpecker-bot
890edaf1c3 chore(deps): update golang docker tag to v1.22 2024-02-08 10:36:05 +00:00
woodpecker-bot
a969947601 fix(deps): update module github.com/rs/zerolog to v1.32.0 2024-02-05 00:10:14 +00:00
woodpecker-bot
0ae47cb04a fix(deps): update module golang.org/x/net to v0.20.0 2024-01-09 00:09:10 +00:00
woodpecker-bot
125fb101dc fix(deps): update module github.com/urfave/cli/v2 to v2.27.1 2023-12-31 00:18:25 +00:00
woodpecker-bot
7b81f9a203 fix(deps): update module github.com/urfave/cli/v2 to v2.27.0 2023-12-27 00:10:03 +00:00
Lauris BH
93da4f40e1 Add Forge metadata (#20)
Adds support for loading Forge metadata from env variables

Reviewed-on: https://codeberg.org/woodpecker-plugins/go-plugin/pulls/20
Reviewed-by: qwerty287 <qwerty287@noreply.codeberg.org>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-committed-by: Lauris BH <lauris@nix.lv>
2023-12-10 20:27:57 +00:00
Lauris BH
30c031631d Fix support for woodpecker 2.0.0 (#19)
`_LINK` -> `_URL`

Reviewed-on: https://codeberg.org/woodpecker-plugins/go-plugin/pulls/19
Reviewed-by: anbraten <anbraten@noreply.codeberg.org>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-committed-by: Lauris BH <lauris@nix.lv>
2023-12-07 10:45:09 +00:00
woodpecker-bot
f02d9dcbb4 fix(deps): update module github.com/urfave/cli/v2 to v2.26.0 2023-12-04 00:11:20 +00:00
woodpecker-bot
39a7259ed0 fix(deps): update module golang.org/x/net to v0.19.0 2023-11-29 00:11:00 +00:00
jolheiser
275eb26ca7 fix: make readme example compile (#17)
Resolves #16

Also formatted it.

https://go.dev/play/p/sFpiRTwLGlq
Reviewed-on: https://codeberg.org/woodpecker-plugins/go-plugin/pulls/17
Reviewed-by: Patrick Schratz <pat-s@noreply.codeberg.org>
Co-authored-by: jolheiser <jolheiser@noreply.codeberg.org>
Co-committed-by: jolheiser <jolheiser@noreply.codeberg.org>
2023-11-15 17:33:12 +00:00
woodpecker-bot
f1c4c040ce fix(deps): update module golang.org/x/net to v0.18.0 2023-11-09 00:09:30 +00:00
pat-s
174f822f73
also run tests on renovate/ branches 2023-11-08 20:04:23 +01:00
woodpecker-bot
ab2091b8bc Update module github.com/joho/godotenv to v1.5.1 (#11)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [github.com/joho/godotenv](https://github.com/joho/godotenv) | require | minor | `v1.4.0` -> `v1.5.1` |

---

### Release Notes

<details>
<summary>joho/godotenv (github.com/joho/godotenv)</summary>

### [`v1.5.1`](https://github.com/joho/godotenv/releases/tag/v1.5.1): Fix parser regressions from multiline support

[Compare Source](https://github.com/joho/godotenv/compare/v1.5.0...v1.5.1)

Version 1.5 came with a whole new parser, and with a new parser comes new bugs.

Things that were broken in 1.5 that are now fixed:

-   unquoted variables with interior whitespace no longer split on the first space (and then break the following line if you have one)
-   inline comments now work again for both quoted and unquoted variables
-   ` export  ` statement filtering was made more robust and matched earlier versions behaviour
-   `FOO.BAR` key names are permitted again (i have no idea why you'd do it, but it's explicitly supported in ruby dotenv files)

There's one breaking change: earlier versions of this library would allow unterminated quoted variables in some instances and return a value (ie `FOO="bar` would set env of `FOO: '"bar'`), this now returns an error.

#### What's Changed

-   Fix bug where internal unquoted whitespace truncates values by [@&#8203;joho](https://github.com/joho) in https://github.com/joho/godotenv/pull/205

**Full Changelog**: https://github.com/joho/godotenv/compare/v1.5.0...v1.5.1

### [`v1.5.0`](https://github.com/joho/godotenv/releases/tag/v1.5.0): - multiline variables

[Compare Source](https://github.com/joho/godotenv/compare/v1.4.0...v1.5.0)

The big news this release is that godotenv finally, after much procrastination in review, supports multiline variables (fixes [#&#8203;64](https://github.com/joho/godotenv/issues/64)). Big shoutout to [@&#8203;x1unix](https://github.com/x1unix) for the bulk of the work on the original PR and also to [@&#8203;coolaj86](https://github.com/coolaj86) and [@&#8203;austinsasko](https://github.com/austinsasko) for some very helpful review and tweaks.

Also added a `-o` overload flag (thanks [@&#8203;2tef](https://github.com/2tef))

#### What's Changed

-   Try and fix go get in CI for power8 by [@&#8203;joho](https://github.com/joho) in https://github.com/joho/godotenv/pull/157
-   Fix typos in comments and extend README by [@&#8203;alexandear](https://github.com/alexandear) in https://github.com/joho/godotenv/pull/177
-   tune README by [@&#8203;bikbah](https://github.com/bikbah) in https://github.com/joho/godotenv/pull/170
-   Remove renovate, add dependabot by [@&#8203;joho](https://github.com/joho) in https://github.com/joho/godotenv/pull/183
-   Setup codeql by [@&#8203;joho](https://github.com/joho) in https://github.com/joho/godotenv/pull/186
-   Bump actions/checkout from 2 to 3 by [@&#8203;dependabot](https://github.com/dependabot) in https://github.com/joho/godotenv/pull/184
-   Bump actions/setup-go from 2 to 3 by [@&#8203;dependabot](https://github.com/dependabot) in https://github.com/joho/godotenv/pull/185
-   Add darwin arm64 build by [@&#8203;statik](https://github.com/statik) in https://github.com/joho/godotenv/pull/174
-   Sort Go import in README by [@&#8203;Doarakko](https://github.com/Doarakko) in https://github.com/joho/godotenv/pull/193
-   Fix godoc formatting by [@&#8203;joho](https://github.com/joho) in https://github.com/joho/godotenv/pull/197
-   fix tiny details by [@&#8203;2tef](https://github.com/2tef) in https://github.com/joho/godotenv/pull/199
-   Multiline string support by [@&#8203;x1unix](https://github.com/x1unix) in https://github.com/joho/godotenv/pull/156
-   Update CI to test go 1.20 by [@&#8203;joho](https://github.com/joho) in https://github.com/joho/godotenv/pull/201
-   fix whitespace with gofmt by [@&#8203;2tef](https://github.com/2tef) in https://github.com/joho/godotenv/pull/203
-   add overload flag by [@&#8203;2tef](https://github.com/2tef) in https://github.com/joho/godotenv/pull/200
-   -   Fix: ioutil.ReadAll() is deprecated, so removed it's dependency by [@&#8203;dreygur](https://github.com/dreygur) in https://github.com/joho/godotenv/pull/202

#### New Contributors

-   [@&#8203;x1unix](https://github.com/x1unix) made their first contribution in https://github.com/joho/godotenv/pull/118
-   [@&#8203;alexandear](https://github.com/alexandear) made their first contribution in https://github.com/joho/godotenv/pull/177
-   [@&#8203;bikbah](https://github.com/bikbah) made their first contribution in https://github.com/joho/godotenv/pull/170
-   [@&#8203;dependabot](https://github.com/dependabot) made their first contribution in https://github.com/joho/godotenv/pull/184
-   [@&#8203;statik](https://github.com/statik) made their first contribution in https://github.com/joho/godotenv/pull/174
-   [@&#8203;Doarakko](https://github.com/Doarakko) made their first contribution in https://github.com/joho/godotenv/pull/193
-   [@&#8203;2tef](https://github.com/2tef) made their first contribution in https://github.com/joho/godotenv/pull/199
-   [@&#8203;dreygur](https://github.com/dreygur) made their first contribution in https://github.com/joho/godotenv/pull/202

**Full Changelog**: https://github.com/joho/godotenv/compare/v1.4.0...v1.5.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - "before 4am" (UTC).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zMi4wIiwidXBkYXRlZEluVmVyIjoiMzcuMzMuNiIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Reviewed-on: https://codeberg.org/woodpecker-plugins/go-plugin/pulls/11
Co-authored-by: woodpecker-bot <woodpecker-bot@obermui.de>
Co-committed-by: woodpecker-bot <woodpecker-bot@obermui.de>
2023-10-27 12:27:44 +00:00
woodpecker-bot
7a77b4deb6 Update golang Docker tag to v1.21 (#9)
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| golang | minor | `1.18` -> `1.21` |

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - "before 4am" (UTC).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zMi4wIiwidXBkYXRlZEluVmVyIjoiMzcuMzIuMCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Reviewed-on: https://codeberg.org/woodpecker-plugins/go-plugin/pulls/9
Co-authored-by: woodpecker-bot <woodpecker-bot@obermui.de>
Co-committed-by: woodpecker-bot <woodpecker-bot@obermui.de>
2023-10-27 12:27:37 +00:00
woodpecker-bot
1396daf59f Update module golang.org/x/net to v0.17.0 2023-10-27 00:09:34 +00:00
woodpecker-bot
4595cecac4 Update module github.com/urfave/cli/v2 to v2.25.7 2023-10-26 00:14:32 +00:00
woodpecker-bot
629a1a9258 Update module github.com/rs/zerolog to v1.31.0 2023-10-26 00:08:32 +00:00
woodpecker-bot
875983b71f Update golangci/golangci-lint Docker tag to v1.55 2023-10-25 10:43:48 +00:00
Woodpecker Bot
1baf72dd81 Update module github.com/stretchr/testify to v1.8.4 2023-10-22 20:43:52 +00:00
pat-s
92ff2797fa No dup wfs (#6)
Reviewed-on: https://codeberg.org/woodpecker-plugins/go-plugin/pulls/6
Co-authored-by: pat-s <patrick.schratz@gmail.com>
Co-committed-by: pat-s <patrick.schratz@gmail.com>
2023-10-17 17:19:21 +00:00
Patrick Schratz
18a1562886 Configure Renovate (#4)
Welcome to [Renovate](https://github.com/renovatebot/renovate)! This is an onboarding PR to help you understand and configure settings before regular Pull Requests begin.

🚦 To activate Renovate, merge this Pull Request. To disable Renovate, simply close this Pull Request unmerged.

---
### Detected Package Files

 * `go.mod` (gomod)
 * `.woodpecker.yaml` (woodpecker)

### Configuration Summary

Based on the default config's presets, Renovate will:

  - Start dependency updates only once this onboarding PR is merged
  - Enable Renovate Dependency Dashboard creation.
  - Use semantic commit type `fix` for dependencies and `chore` for all others if semantic commits are in use.
  - Ignore `node_modules`, `bower_components`, `vendor` and various test/tests directories.
  - Group known monorepo packages together.
  - Use curated list of recommended non-monorepo package groupings.
  - Apply crowd-sourced package replacement rules.
  - Apply crowd-sourced workarounds for known problems with packages.
  - Run lock file maintenance (updates) early Monday mornings.
  - Schedule automerge daily.
  - Schedule for weekends.
  - Enable Renovate Dependency Dashboard creation.
  - Use semantic commit type `fix` for dependencies and `chore` for all others if semantic commits are in use.
  - Ignore `node_modules`, `bower_components`, `vendor` and various test/tests directories.
  - Group known monorepo packages together.
  - Use curated list of recommended non-monorepo package groupings.
  - Apply crowd-sourced package replacement rules.
  - Apply crowd-sourced workarounds for known problems with packages.
  - Run lock file maintenance (updates) early Monday mornings.
  - Schedule automerge daily.
  - Schedule for weekends.
  - Run Renovate on following schedule: every weekend

🔡 Would you like to change the way Renovate is upgrading your dependencies? Simply edit the `renovate.json` in this branch with your custom config and the list of Pull Requests in the "What to Expect" section below will be updated the next time Renovate runs.

---

### What to Expect

With your current configuration, Renovate will create 7 Pull Requests:

<details>
<summary>Update module github.com/stretchr/testify to v1.8.4</summary>

  - Schedule: ["every weekend"]
  - Branch name: `renovate/github.com-stretchr-testify-1.x`
  - Merge into: `main`
  - Upgrade [github.com/stretchr/testify](https://github.com/stretchr/testify) to `v1.8.4`

</details>

<details>
<summary>Update golang Docker tag to v1.21</summary>

  - Schedule: ["every weekend"]
  - Branch name: `renovate/golang-1.x`
  - Merge into: `main`
  - Upgrade golang to `1.21`

</details>

<details>
<summary>Update golangci/golangci-lint Docker tag to v1.54</summary>

  - Schedule: ["every weekend"]
  - Branch name: `renovate/golangci-golangci-lint-1.x`
  - Merge into: `main`
  - Upgrade golangci/golangci-lint to `v1.54-alpine`

</details>

<details>
<summary>Update module github.com/joho/godotenv to v1.5.1</summary>

  - Schedule: ["every weekend"]
  - Branch name: `renovate/github.com-joho-godotenv-1.x`
  - Merge into: `main`
  - Upgrade [github.com/joho/godotenv](https://github.com/joho/godotenv) to `v1.5.1`

</details>

<details>
<summary>Update module github.com/rs/zerolog to v1.31.0</summary>

  - Schedule: ["every weekend"]
  - Branch name: `renovate/github.com-rs-zerolog-1.x`
  - Merge into: `main`
  - Upgrade [github.com/rs/zerolog](https://github.com/rs/zerolog) to `v1.31.0`

</details>

<details>
<summary>Update module github.com/urfave/cli/v2 to v2.25.7</summary>

  - Schedule: ["every weekend"]
  - Branch name: `renovate/github.com-urfave-cli-v2-2.x`
  - Merge into: `main`
  - Upgrade [github.com/urfave/cli/v2](https://github.com/urfave/cli) to `v2.25.7`

</details>

<details>
<summary>Update module golang.org/x/net to v0.17.0</summary>

  - Schedule: ["every weekend"]
  - Branch name: `renovate/golang.org-x-net-0.x`
  - Merge into: `main`
  - Upgrade golang.org/x/net to `v0.17.0`

</details>

<br />

🚸 Branch creation will be limited to maximum 2 per hour, so it doesn't swamp any CI resources or overwhelm the project. See docs for `prhourlylimit` for details.

---

 Got questions? Check out Renovate's [Docs](https://docs.renovatebot.com/), particularly the Getting Started section.
If you need any further assistance then you can also [request help here](https://github.com/renovatebot/renovate/discussions).

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).

<!--renovate-config-hash:d0f89381ee26ddd9055d24c12fa2ffc765c573491e687875e761186223a52bc4-->

Reviewed-on: https://codeberg.org/woodpecker-plugins/go-plugin/pulls/4
Co-authored-by: Patrick Schratz <pat-s@mailbox.org>
Co-committed-by: Patrick Schratz <pat-s@mailbox.org>
2023-10-16 16:52:34 +00:00
6543
afbbefb22e
update pipeline to meet v1.0.0 standard 2023-07-31 05:24:14 +02:00
14 changed files with 283 additions and 136 deletions

View File

@ -1,15 +1,34 @@
variables:
- &golang 'golang:1.18'
when:
- event: [pull_request, tag, cron]
- event: push
branch:
- ${CI_REPO_DEFAULT_BRANCH}
- 'renovate/*'
pipeline:
- name: vendor
variables:
- &golang "golang:1.22"
- &golangci-lint "golangci/golangci-lint:v1.59-alpine"
- &reviewdog-golangci-lint "woodpeckerci/plugin-reviewdog-golangci-lint:1.59"
steps:
vendor:
image: *golang
commands: go mod vendor
- name: lint
image: golangci/golangci-lint:v1.50-alpine
commands: golangci-lint run
review-go:
image: *reviewdog-golangci-lint
settings:
token:
from_secret: reviewdog_token
when:
event: pull_request
- name: test
lint:
image: *golangci-lint
commands: golangci-lint run --timeout 5m
when:
event: [push, tag, cron]
test:
image: *golang
commands: go test --cover ./...

View File

@ -18,54 +18,56 @@ HTTP client library.
## Creating plugin
```go
import (
"context"
package main
"codeberg.org/woodpecker-plugins/go-plugin"
"github.com/urfave/cli/v2"
"github.com/rs/zerolog/log"
import (
"context"
"codeberg.org/woodpecker-plugins/go-plugin"
"github.com/rs/zerolog/log"
"github.com/urfave/cli/v2"
)
type Settings struct {
// TODO: Plugin settings
SampleFlag string
// TODO: Plugin settings
SampleFlag string
}
type Plugin struct {
*plugin.Plugin
Settings *Settings
*plugin.Plugin
Settings *Settings
}
func (p *Plugin) Flags() []cli.Flag {
return []cli.Flag{
// TODO: Add flags
&cli.StringFlag{
Name: "sample.flag",
Usage: "sample flag",
EnvVars: []string{"PLUGIN_SAMPLE_FLAG"},
Destination: &p.Settings.SampleFlag,
},
}
return []cli.Flag{
// TODO: Add flags
&cli.StringFlag{
Name: "sample.flag",
Usage: "sample flag",
EnvVars: []string{"PLUGIN_SAMPLE_FLAG"},
Destination: &p.Settings.SampleFlag,
},
}
}
func (p *Plugin) Execute(ctx context.Context) error {
// TODO: Implement execution
log.Debug().Msg("executed")
return nil
// TODO: Implement execution
log.Debug().Msg("executed")
return nil
}
func main() {
p := &Plugin{
&Settings{}
}
p.Plugin = plugin.New(Options{
Name: "sample-plugin",
Description: "Sample plugin",
Flags: p.Flags(),
Execute: p.Execute,
})
p := &Plugin{
Settings: &Settings{},
}
p.Run()
p.Plugin = plugin.New(plugin.Options{
Name: "sample-plugin",
Description: "Sample plugin",
Flags: p.Flags(),
Execute: p.Execute,
})
p.Run()
}
```

View File

@ -41,7 +41,7 @@ type (
}
)
func currFlags() []cli.Flag {
func commitFlags() []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: "commit.sha",
@ -106,7 +106,7 @@ func currFlags() []cli.Flag {
}
}
func currFromContext(c *cli.Context) Commit {
func commitFromContext(c *cli.Context) Commit {
return Commit{
Sha: c.String("commit.sha"),
Ref: c.String("commit.ref"),
@ -125,7 +125,7 @@ func currFromContext(c *cli.Context) Commit {
}
}
func prevFlags() []cli.Flag {
func previousCommitFlags() []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: "prev.commit.sha",
@ -170,7 +170,7 @@ func prevFlags() []cli.Flag {
}
}
func prevFromContext(c *cli.Context) Commit {
func previousCommitFromContext(c *cli.Context) Commit {
return Commit{
Sha: c.String("prev.commit.sha"),
Ref: c.String("prev.commit.ref"),

View File

@ -25,10 +25,11 @@ func Flags() []cli.Flag {
// Pipeline flags
flags = append(flags, repositoryFlags()...)
flags = append(flags, pipelineFlags()...)
flags = append(flags, currFlags()...)
flags = append(flags, prevFlags()...)
flags = append(flags, commitFlags()...)
flags = append(flags, previousCommitFlags()...)
flags = append(flags, stepFlags()...)
flags = append(flags, systemFlags()...)
flags = append(flags, forgeFlags()...)
// Plugin flags
flags = append(flags, loggingFlags()...)

64
forge.go Normal file
View File

@ -0,0 +1,64 @@
// Copyright 2023 Woodpecker Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package plugin
import (
"github.com/urfave/cli/v2"
)
const (
ForgeTypeGitea = "gitea"
ForgeTypeGitHub = "github"
ForgeTypeGitLab = "gitlab"
ForgeTypeBitbucket = "bitbucket"
)
// Forge defines metadata for integration with a forge.
type Forge struct {
Type string `json:"type,omitempty"`
URL string `json:"url,omitempty"`
// Deprecated: Please use URL instead.
Link string `json:"link,omitempty"`
}
func forgeFlags() []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: "forge.type",
Usage: "forge type (gitea, github, gitlab, bitbucket)",
EnvVars: []string{
"CI_FORGE_TYPE",
},
},
&cli.StringFlag{
Name: "forge.url",
Aliases: []string{"forge.link"},
Usage: "forge url",
EnvVars: []string{
"CI_FORGE_URL",
"CI_FORGE_LINK",
},
},
}
}
func forgeFromContext(ctx *cli.Context) Forge {
return Forge{
Type: ctx.String("forge.type"),
Link: ctx.String("forge.url"),
URL: ctx.String("forge.url"),
}
}

20
go.mod
View File

@ -3,21 +3,21 @@ module codeberg.org/woodpecker-plugins/go-plugin
go 1.19
require (
github.com/joho/godotenv v1.4.0
github.com/rs/zerolog v1.28.0
github.com/stretchr/testify v1.8.1
github.com/urfave/cli/v2 v2.23.7
golang.org/x/net v0.5.0
github.com/joho/godotenv v1.5.1
github.com/rs/zerolog v1.33.0
github.com/stretchr/testify v1.9.0
github.com/urfave/cli/v2 v2.27.2
golang.org/x/net v0.26.0
)
require (
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
golang.org/x/sys v0.4.0 // indirect
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 // indirect
golang.org/x/sys v0.21.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

57
go.sum
View File

@ -1,43 +1,38 @@
github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg=
github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.28.0 h1:MirSo27VyNi7RJYP3078AA1+Cyzd2GB66qy3aUHvsWY=
github.com/rs/zerolog v1.28.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/urfave/cli/v2 v2.23.7 h1:YHDQ46s3VghFHFf1DdF+Sh7H4RqhcM+t0TmZRJx4oJY=
github.com/urfave/cli/v2 v2.23.7/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw=
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/urfave/cli/v2 v2.27.2 h1:6e0H+AkS+zDckwPCUrZkKX38mRaau4nL2uipkJpbkcI=
github.com/urfave/cli/v2 v2.27.2/go.mod h1:g0+79LmHHATl7DAcHO99smiR/T7uGLw84w8Y42x+4eM=
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 h1:+qGGcbkzsfDQNPPe9UDgpxAWQrhbbBXOYJFQDq/dtJw=
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913/go.mod h1:4aEEwZQutDLsQv2Deui4iYQ6DWTxR14g6m8Wv88+Xqk=
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@ -20,22 +20,36 @@ import (
// Metadata defines runtime metadata.
type Metadata struct {
Repository Repository `json:"repo,omitempty"`
Pipeline Pipeline `json:"curr,omitempty"`
Curr Commit `json:"commit,omitempty"`
Prev Commit `json:"prev,omitempty"`
Step Step `json:"step,omitempty"`
System System `json:"sys,omitempty"`
Repository Repository `json:"repo,omitempty"`
Pipeline Pipeline `json:"curr,omitempty"`
Commit Commit `json:"commit,omitempty"`
PreviousCommit Commit `json:"previous_commit,omitempty"`
Step Step `json:"step,omitempty"`
System System `json:"sys,omitempty"`
Forge Forge `json:"forge,omitempty"`
// Deprecated: Please use Commit instead.
Curr Commit
// Deprecated: Please use PreviousCommit instead.
Prev Commit `json:"prev,omitempty"`
}
// MetadataFromContext creates a Metadata from the cli.Context.
func MetadataFromContext(ctx *cli.Context) Metadata {
commit := commitFromContext(ctx)
previousCommit := previousCommitFromContext(ctx)
return Metadata{
Repository: repositoryFromContext(ctx),
Pipeline: pipelineFromContext(ctx),
Curr: currFromContext(ctx),
Prev: prevFromContext(ctx),
Step: stepFromContext(ctx),
System: systemFromContext(ctx),
Repository: repositoryFromContext(ctx),
Pipeline: pipelineFromContext(ctx),
Commit: commit,
PreviousCommit: previousCommit,
Step: stepFromContext(ctx),
System: systemFromContext(ctx),
Forge: forgeFromContext(ctx),
Curr: commit,
Prev: previousCommit,
}
}

View File

@ -32,8 +32,8 @@ func testMetadata() map[string]string {
"CI_REPO_NAME": "woodpecker",
"CI_REPO_OWNER": "woodpecker-ci",
"CI_REPO_SCM": "git",
"CI_REPO_LINK": "https://github.com/woodpecker-ci/woodpecker",
"CI_REPO_CLONE_URL": "https://github.com/woodpecker-ci/woodpecker.git",
"CI_REPO_URL": "https://codeberg.org/woodpecker-plugins/go-plugin",
"CI_REPO_CLONE_URL": "https://codeberg.org/woodpecker-plugins/go-plugin.git",
"CI_REPO_DEFAULT_BRANCH": "main",
"CI_REPO_PRIVATE": "false",
// Commit
@ -45,11 +45,11 @@ func testMetadata() map[string]string {
"CI_COMMIT_AUTHOR": "John Doe",
"CI_COMMIT_AUTHOR_EMAIL": "john@example.com",
"CI_COMMIT_AUTHOR_AVATAR": "https://avatars.githubusercontent.com/u/1234567?v=4",
"CI_COMMIT_LINK": "https://github.com/woodpecker-ci/woodpecker/commit/a1b2c3d4",
"CI_COMMIT_URL": "https://codeberg.org/woodpecker-plugins/go-plugin/commit/a1b2c3d4",
// Build
"CI_PIPELINE_NUMBER": "1",
"CI_PIPELINE_EVENT": "push",
"CI_PIPELINE_LINK": "https://ci.woodpecker-ci.org/woodpecker-ci/woodpecker/1",
"CI_PIPELINE_EVENT": EventTypePush,
"CI_PIPELINE_URL": "https://ci.woodpecker-ci.org/woodpecker-ci/woodpecker/1",
"CI_PIPELINE_STATUS": "running",
"CI_PIPELINE_CREATED": "1611234567",
"CI_PIPELINE_STARTED": "1611234567",
@ -60,9 +60,12 @@ func testMetadata() map[string]string {
"CI_STEP_STARTED": "1611234567",
// System
"CI_SYSTEM_NAME": "woodpecker",
"CI_SYSTEM_LINK": "https://ci.woodpecker-ci.org",
"CI_SYSTEM_URL": "https://ci.woodpecker-ci.org",
"CI_SYSTEM_VERSION": "1.0.0",
"CI_SYSTEM_HOST": "woodpecker-ci.org",
// Forge
"CI_FORGE_TYPE": ForgeTypeGitea,
"CI_FORGE_URL": "https://codeberg.org",
}
}
@ -82,8 +85,8 @@ func TestMetadata(t *testing.T) {
// Repository
assert.Equal(t, "woodpecker", plugin.Metadata.Repository.Name)
assert.Equal(t, "woodpecker-ci", plugin.Metadata.Repository.Owner)
assert.Equal(t, "https://github.com/woodpecker-ci/woodpecker", plugin.Metadata.Repository.Link)
assert.Equal(t, "https://github.com/woodpecker-ci/woodpecker.git", plugin.Metadata.Repository.CloneURL)
assert.Equal(t, "https://codeberg.org/woodpecker-plugins/go-plugin", plugin.Metadata.Repository.URL)
assert.Equal(t, "https://codeberg.org/woodpecker-plugins/go-plugin.git", plugin.Metadata.Repository.CloneURL)
assert.Equal(t, "main", plugin.Metadata.Repository.Branch)
assert.False(t, plugin.Metadata.Repository.Private)
@ -99,8 +102,8 @@ func TestMetadata(t *testing.T) {
// Pipeline
assert.Equal(t, int64(1), plugin.Metadata.Pipeline.Number)
assert.Equal(t, "push", plugin.Metadata.Pipeline.Event)
assert.Equal(t, "https://ci.woodpecker-ci.org/woodpecker-ci/woodpecker/1", plugin.Metadata.Pipeline.Link)
assert.Equal(t, EventTypePush, plugin.Metadata.Pipeline.Event)
assert.Equal(t, "https://ci.woodpecker-ci.org/woodpecker-ci/woodpecker/1", plugin.Metadata.Pipeline.URL)
assert.Equal(t, "running", plugin.Metadata.Pipeline.Status)
assert.Equal(t, time.Unix(1611234567, 0), plugin.Metadata.Pipeline.Created)
assert.Equal(t, time.Unix(1611234567, 0), plugin.Metadata.Pipeline.Started)
@ -111,7 +114,11 @@ func TestMetadata(t *testing.T) {
// System
assert.Equal(t, "woodpecker", plugin.Metadata.System.Name)
assert.Equal(t, "https://ci.woodpecker-ci.org", plugin.Metadata.System.Link)
assert.Equal(t, "https://ci.woodpecker-ci.org", plugin.Metadata.System.URL)
assert.Equal(t, "1.0.0", plugin.Metadata.System.Version)
assert.Equal(t, "woodpecker-ci.org", plugin.Metadata.System.Host)
// Forge
assert.Equal(t, ForgeTypeGitea, plugin.Metadata.Forge.Type)
assert.Equal(t, "https://codeberg.org", plugin.Metadata.Forge.URL)
}

View File

@ -20,17 +20,29 @@ import (
"github.com/urfave/cli/v2"
)
const (
EventTypePush = "push"
EventTypePullRequest = "pull_request"
EventTypeTag = "tag"
EventTypeDeployment = "deployment"
EventTypeCron = "cron"
EventTypeManual = "manual"
)
// Pipeline defines runtime metadata for a pipeline.
type Pipeline struct {
Number int64 `json:"number,omitempty"`
Status string `json:"status,omitempty"`
Event string `json:"event,omitempty"`
Link string `json:"link,omitempty"`
URL string `json:"url,omitempty"`
DeployTarget string `json:"target,omitempty"`
Created time.Time `json:"created,omitempty"`
Started time.Time `json:"started,omitempty"`
Finished time.Time `json:"finished,omitempty"`
Parent int64 `json:"parent,omitempty"`
// Deprecated: Please use URL instead.
Link string `json:"link,omitempty"`
}
func pipelineFlags() []cli.Flag {
@ -60,9 +72,11 @@ func pipelineFlags() []cli.Flag {
},
},
&cli.StringFlag{
Name: "pipeline.link",
Usage: "pipeline link",
Name: "pipeline.url",
Aliases: []string{"pipeline.link"},
Usage: "pipeline url",
EnvVars: []string{
"CI_PIPELINE_URL",
"CI_PIPELINE_LINK",
"DRONE_BUILD_LINK",
},
@ -115,7 +129,8 @@ func pipelineFromContext(c *cli.Context) Pipeline {
Number: c.Int64("pipeline.number"),
Status: c.String("pipeline.status"),
Event: c.String("pipeline.event"),
Link: c.String("pipeline.link"),
URL: c.String("pipeline.url"),
Link: c.String("pipeline.url"),
DeployTarget: c.String("pipeline.deploy-target"),
Created: time.Unix(c.Int64("pipeline.created"), 0),
Started: time.Unix(c.Int64("pipeline.started"), 0),

View File

@ -58,6 +58,7 @@ func New(opt Options) *Plugin {
app := &cli.App{
Name: opt.Name,
Usage: "Run the Woodpecker CI plugin",
Description: opt.Description,
Version: opt.Version,
Flags: append(opt.Flags, Flags()...),

6
renovate.json Normal file
View File

@ -0,0 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"local>woodpecker-plugins/renovate-config"
]
}

45
repo.go
View File

@ -20,16 +20,28 @@ import (
// Repository defines runtime metadata for a repository.
type Repository struct {
Name string `json:"name,omitempty"`
Owner string `json:"owner,omitempty"`
Link string `json:"link,omitempty"`
CloneURL string `json:"clone_url,omitempty"`
Private bool `json:"private,omitempty"`
Branch string `json:"default_branch,omitempty"`
RemoteID string `json:"remote_id,omitempty"`
Name string `json:"name,omitempty"`
Owner string `json:"owner,omitempty"`
Link string `json:"link,omitempty"`
URL string `json:"url,omitempty"`
CloneURL string `json:"clone_url,omitempty"`
Private bool `json:"private,omitempty"`
DefaultBranch string `json:"default_branch,omitempty"`
// Deprecated: Please use DefaultBranch instead.
Branch string
}
func repositoryFlags() []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: "repo.remote-id",
Usage: "repo remote id",
EnvVars: []string{
"CI_REPO_REMOTE_ID",
},
},
&cli.StringFlag{
Name: "repo.name",
Usage: "repo name",
@ -47,9 +59,11 @@ func repositoryFlags() []cli.Flag {
},
},
&cli.StringFlag{
Name: "repo.link",
Usage: "repo link",
Name: "repo.url",
Aliases: []string{"repo.link"},
Usage: "repo url",
EnvVars: []string{
"CI_REPO_URL",
"CI_REPO_LINK",
"DRONE_REPO_LINK",
},
@ -83,11 +97,14 @@ func repositoryFlags() []cli.Flag {
func repositoryFromContext(c *cli.Context) Repository {
return Repository{
Name: c.String("repo.name"),
Owner: c.String("repo.owner"),
Link: c.String("repo.link"),
CloneURL: c.String("repo.clone-url"),
Private: c.Bool("repo.private"),
Branch: c.String("repo.default-branch"),
RemoteID: c.String("repo.remote-id"),
Name: c.String("repo.name"),
Owner: c.String("repo.owner"),
URL: c.String("repo.url"),
Link: c.String("repo.url"),
CloneURL: c.String("repo.clone-url"),
Private: c.Bool("repo.private"),
Branch: c.String("repo.default-branch"),
DefaultBranch: c.String("repo.default-branch"),
}
}

View File

@ -24,9 +24,12 @@ import (
type System struct {
Name string `json:"name,omitempty"`
Host string `json:"host,omitempty"`
Link string `json:"link,omitempty"`
Platform string `json:"arch,omitempty"`
Version string `json:"version,omitempty"`
URL string `json:"url,omitempty"`
// Deprecated: Please use URL instead.
Link string `json:"link,omitempty"`
}
func systemFlags() []cli.Flag {
@ -48,9 +51,11 @@ func systemFlags() []cli.Flag {
},
},
&cli.StringFlag{
Name: "system.link",
Usage: "system link",
Name: "system.url",
Aliases: []string{"system.link"},
Usage: "system url",
EnvVars: []string{
"CI_SYSTEM_URL",
"CI_SYSTEM_LINK",
},
},
@ -74,19 +79,20 @@ func systemFlags() []cli.Flag {
}
func systemFromContext(ctx *cli.Context) System {
link := ctx.String("system.link")
url := ctx.String("system.url")
host := ctx.String("system.host")
if link == "" && host != "" {
// Alternative link format used by Drone.
if url == "" && host != "" {
// Alternative url format used by Drone.
proto := os.Getenv("DRONE_SYSTEM_PROTO")
if proto != "" {
link = proto + "://" + host
url = proto + "://" + host
}
}
return System{
Name: ctx.String("system.name"),
Host: host,
Link: link,
URL: url,
Link: url,
Platform: ctx.String("system.arch"),
Version: ctx.String("system.version"),
}