Compare commits

...

35 Commits

Author SHA1 Message Date
woodpecker-bot ff27774e34 fix(deps): update module github.com/urfave/cli/v3 to v3.10.0 2026-06-14 14:05:17 +00:00
woodpecker-bot 0307b473fd fix(deps): update module golang.org/x/net to v0.56.0 2026-06-13 01:06:30 +00:00
woodpecker-bot 39109f4f0d fix(deps): update module github.com/urfave/cli/v3 to v3.9.1 2026-06-13 00:06:03 +00:00
woodpecker-bot d79c1b9e73 chore(deps): update go toolchain directive to v1.26.4 2026-06-06 00:05:36 +00:00
oauth 9b54bb824c 🎉 Release 1.2.0 (#85)
This PR was opened by the [ready-release-go](https://github.com/woodpecker-ci/plugin-ready-release-go) plugin. When you're ready to do a release, you can merge this pull-request and a new release with version `1.2.0` will be created automatically. If you're not ready to do a release yet, that's fine, whenever you add more changes to `main` this pull-request will be updated.

## Options

- [ ] Mark this version as a release candidate

## [1.2.0](https://codeberg.org/woodpecker-plugins/go-plugin/releases/tag/v1.2.0) - 2026-05-30

###  Features

- Support CI_STEP_NAME and CI_STEP_TYPE [[#88](https://codeberg.org/woodpecker-plugins/go-plugin/pulls/88)]

### 📦️ Dependency

- fix(deps): update module golang.org/x/net to v0.55.0 [[#86](https://codeberg.org/woodpecker-plugins/go-plugin/pulls/86)]
- fix(deps): update module golang.org/x/net to v0.54.0 [[#84](https://codeberg.org/woodpecker-plugins/go-plugin/pulls/84)]

Reviewed-on: https://codeberg.org/woodpecker-plugins/go-plugin/pulls/85
Reviewed-by: 6543 <6543@obermui.de>
2026-05-30 16:19:11 +02:00
6543 04d11d71e2 Support CI_STEP_NAME and CI_STEP_TYPE (#88)
needs https://github.com/woodpecker-ci/woodpecker/pull/4290 (woodpecker >= v3.15.0)

Reviewed-on: https://codeberg.org/woodpecker-plugins/go-plugin/pulls/88
Reviewed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2026-05-30 16:17:54 +02:00
woodpecker-bot 6c31fd4eca fix(deps): update module golang.org/x/net to v0.55.0 (#86)
Reviewed-on: https://codeberg.org/woodpecker-plugins/go-plugin/pulls/86
2026-05-25 11:25:46 +02:00
woodpecker-bot 6d2dd250f2 fix(deps): update module github.com/urfave/cli/v3 to v3.9.0 2026-05-16 00:06:01 +00:00
woodpecker-bot b9901cb0a4 fix(deps): update module golang.org/x/net to v0.54.0 (#84)
Reviewed-on: https://codeberg.org/woodpecker-plugins/go-plugin/pulls/84
2026-05-09 08:30:54 +02:00
woodpecker-bot 35e4580f92 chore(deps): update go toolchain directive to v1.26.3 2026-05-09 00:07:23 +00:00
woodpecker-bot 7c2ff72c02 fix(deps): update module github.com/rs/zerolog to v1.35.1 2026-04-25 00:06:29 +00:00
woodpecker-bot 8cc8f11ed6 chore(deps): update docker.io/woodpeckerci/plugin-ready-release-go docker tag to v4.1.1 2026-04-18 00:06:55 +00:00
woodpecker-bot c437b69716 fix(deps): update module golang.org/x/net to v0.53.0 2026-04-11 01:04:23 +00:00
woodpecker-bot ff7388263c chore(deps): update dependency go to v1.26.2 2026-04-11 00:06:09 +00:00
oauth deb8bebb75 🎉 Release 1.1.0 (#83)
Reviewed-on: https://codeberg.org/woodpecker-plugins/go-plugin/pulls/83
Co-authored-by: oauth <woodpecker-bot@obermui.de>
Co-committed-by: oauth <woodpecker-bot@obermui.de>
2026-03-30 16:35:24 +02:00
qwerty287 715e1e0802 Fix lint 2026-03-30 16:33:30 +02:00
qwerty287 c8a8fc1983 Format code 2026-03-30 16:31:40 +02:00
OCram85 320f95afae feat(flags): adds support for http proxy config (#82)
Reviewed-on: https://codeberg.org/woodpecker-plugins/go-plugin/pulls/82
Reviewed-by: qwerty287 <qwerty287@noreply.codeberg.org>
Co-authored-by: OCram85 <marco.blessing@googlemail.com>
Co-committed-by: OCram85 <marco.blessing@googlemail.com>
2026-03-30 16:29:13 +02:00
woodpecker-bot 4fba2ed06e fix(deps): update module github.com/urfave/cli/v3 to v3.8.0 2026-03-28 02:04:40 +00:00
woodpecker-bot 64071307b1 fix(deps): update module github.com/rs/zerolog to v1.35.0 2026-03-28 01:05:09 +00:00
woodpecker-bot 00f2fd05f9 chore(deps): update docker.io/woodpeckerci/plugin-ready-release-go docker tag to v4.1.0 2026-03-28 00:05:26 +00:00
woodpecker-bot 4cfd9035eb fix(deps): update module golang.org/x/net to v0.52.0 2026-03-14 00:05:10 +00:00
oauth e8db412499 🎉 Release 1.0.3 (#77)
This PR was opened by the [ready-release-go](https://github.com/woodpecker-ci/plugin-ready-release-go) plugin. When you're ready to do a release, you can merge this pull-request and a new release with version `1.0.3` will be created automatically. If you're not ready to do a release yet, that's fine, whenever you add more changes to `main` this pull-request will be updated.

## Options

- [ ] Mark this version as a release candidate

## [1.0.3](https://codeberg.org/woodpecker-plugins/go-plugin/releases/tag/v1.0.3) - 2026-03-07

### 📦️ Dependency

- fix(deps): update module github.com/urfave/cli/v3 to v3.7.0 [[#80](https://codeberg.org/woodpecker-plugins/go-plugin/pulls/80)]
- chore(deps): update docker.io/woodpeckerci/plugin-ready-release-go docker tag to v4 [[#78](https://codeberg.org/woodpecker-plugins/go-plugin/pulls/78)]
- fix(deps): update module golang.org/x/net to v0.51.0 [[#79](https://codeberg.org/woodpecker-plugins/go-plugin/pulls/79)]
- chore(deps): update dependency go to v1.26.0 [[#74](https://codeberg.org/woodpecker-plugins/go-plugin/pulls/74)]
- chore(deps): update golang docker tag to v1.26 [[#75](https://codeberg.org/woodpecker-plugins/go-plugin/pulls/75)]
- fix(deps): update module golang.org/x/net to v0.50.0 [[#76](https://codeberg.org/woodpecker-plugins/go-plugin/pulls/76)]

Reviewed-on: https://codeberg.org/woodpecker-plugins/go-plugin/pulls/77
Reviewed-by: Lauris BH <lafriks@noreply.codeberg.org>
Co-authored-by: oauth <woodpecker-bot@obermui.de>
Co-committed-by: oauth <woodpecker-bot@obermui.de>
2026-03-11 17:16:33 +01:00
woodpecker-bot 685ac42fc4 chore(deps): update dependency go to v1.26.1 2026-03-07 00:05:47 +00:00
woodpecker-bot f0168dce22 fix(deps): update module github.com/urfave/cli/v3 to v3.7.0 (#80)
Reviewed-on: https://codeberg.org/woodpecker-plugins/go-plugin/pulls/80
Co-authored-by: woodpecker-bot <woodpecker-bot@obermui.de>
Co-committed-by: woodpecker-bot <woodpecker-bot@obermui.de>
2026-03-03 09:17:44 +01:00
woodpecker-bot a811e40032 chore(deps): update docker.io/woodpeckerci/plugin-ready-release-go docker tag to v4 (#78)
Reviewed-on: https://codeberg.org/woodpecker-plugins/go-plugin/pulls/78
Co-authored-by: woodpecker-bot <woodpecker-bot@obermui.de>
Co-committed-by: woodpecker-bot <woodpecker-bot@obermui.de>
2026-02-28 08:13:43 +01:00
woodpecker-bot e5e33d41e5 fix(deps): update module golang.org/x/net to v0.51.0 (#79)
Reviewed-on: https://codeberg.org/woodpecker-plugins/go-plugin/pulls/79
Co-authored-by: woodpecker-bot <woodpecker-bot@obermui.de>
Co-committed-by: woodpecker-bot <woodpecker-bot@obermui.de>
2026-02-28 08:04:12 +01:00
woodpecker-bot 8eadd31abf chore(deps): update dependency go to v1.26.0 (#74)
Reviewed-on: https://codeberg.org/woodpecker-plugins/go-plugin/pulls/74
Co-authored-by: woodpecker-bot <woodpecker-bot@obermui.de>
Co-committed-by: woodpecker-bot <woodpecker-bot@obermui.de>
2026-02-14 08:52:34 +01:00
woodpecker-bot aded02e977 chore(deps): update golang docker tag to v1.26 (#75)
Reviewed-on: https://codeberg.org/woodpecker-plugins/go-plugin/pulls/75
Co-authored-by: woodpecker-bot <woodpecker-bot@obermui.de>
Co-committed-by: woodpecker-bot <woodpecker-bot@obermui.de>
2026-02-14 08:52:15 +01:00
woodpecker-bot 9e3162422c fix(deps): update module golang.org/x/net to v0.50.0 (#76)
Reviewed-on: https://codeberg.org/woodpecker-plugins/go-plugin/pulls/76
Co-authored-by: woodpecker-bot <woodpecker-bot@obermui.de>
Co-committed-by: woodpecker-bot <woodpecker-bot@obermui.de>
2026-02-14 08:52:00 +01:00
woodpecker-bot e9e7d50eb6 chore(deps): update dependency go to v1.25.7 2026-02-07 00:08:34 +00:00
woodpecker-bot 5959a73881 fix(deps): update module github.com/urfave/cli/v3 to v3.6.2 2026-01-31 16:04:49 +00:00
woodpecker-bot dc3aea27df fix(deps): update module golang.org/x/net to v0.49.0 2026-01-17 01:08:11 +00:00
woodpecker-bot 87698ede13 chore(deps): update dependency go to v1.25.6 2026-01-17 00:11:52 +00:00
woodpecker-bot 3393bdb542 chore(deps): update docker.io/woodpeckerci/plugin-ready-release-go docker tag to v3.4.1 2026-01-10 05:02:57 +00:00
10 changed files with 198 additions and 40 deletions
+8
View File
@@ -34,6 +34,14 @@ linters:
- third_party$
- builtin$
- examples$
revive:
rules:
- name: var-naming
arguments:
- []
- []
- - skipPackageNameChecks: true
skip-package-name-collision-with-go-std: true
formatters:
enable:
- gci
+1 -1
View File
@@ -6,7 +6,7 @@ when:
- "renovate/*"
variables:
- &golang "golang:1.25"
- &golang "golang:1.26"
steps:
vendor:
+1 -1
View File
@@ -6,7 +6,7 @@ when:
steps:
- name: release-helper
image: docker.io/woodpeckerci/plugin-ready-release-go:3.4.0
image: docker.io/woodpeckerci/plugin-ready-release-go:4.1.1
settings:
release_branch: ${CI_COMMIT_BRANCH}
git_email: woodpecker-bot@obermui.de
+40
View File
@@ -1,5 +1,45 @@
# Changelog
## [1.2.0](https://codeberg.org/woodpecker-plugins/go-plugin/releases/tag/v1.2.0) - 2026-05-30
### ❤️ Thanks to all contributors! ❤️
@6543, @woodpecker-bot
### ✨ Features
- Support CI_STEP_NAME and CI_STEP_TYPE [[#88](https://codeberg.org/woodpecker-plugins/go-plugin/pulls/88)]
### 📦️ Dependency
- fix(deps): update module golang.org/x/net to v0.55.0 [[#86](https://codeberg.org/woodpecker-plugins/go-plugin/pulls/86)]
- fix(deps): update module golang.org/x/net to v0.54.0 [[#84](https://codeberg.org/woodpecker-plugins/go-plugin/pulls/84)]
## [1.1.0](https://codeberg.org/woodpecker-plugins/go-plugin/releases/tag/v1.1.0) - 2026-03-30
### ❤️ Thanks to all contributors! ❤️
@OCram85
### 📈 Enhancement
- feat(flags): adds support for http proxy config [[#82](https://codeberg.org/woodpecker-plugins/go-plugin/pulls/82)]
## [1.0.3](https://codeberg.org/woodpecker-plugins/go-plugin/releases/tag/v1.0.3) - 2026-03-07
### ❤️ Thanks to all contributors! ❤️
@woodpecker-bot
### 📦️ Dependency
- fix(deps): update module github.com/urfave/cli/v3 to v3.7.0 [[#80](https://codeberg.org/woodpecker-plugins/go-plugin/pulls/80)]
- chore(deps): update docker.io/woodpeckerci/plugin-ready-release-go docker tag to v4 [[#78](https://codeberg.org/woodpecker-plugins/go-plugin/pulls/78)]
- fix(deps): update module golang.org/x/net to v0.51.0 [[#79](https://codeberg.org/woodpecker-plugins/go-plugin/pulls/79)]
- chore(deps): update dependency go to v1.26.0 [[#74](https://codeberg.org/woodpecker-plugins/go-plugin/pulls/74)]
- chore(deps): update golang docker tag to v1.26 [[#75](https://codeberg.org/woodpecker-plugins/go-plugin/pulls/75)]
- fix(deps): update module golang.org/x/net to v0.50.0 [[#76](https://codeberg.org/woodpecker-plugins/go-plugin/pulls/76)]
## [1.0.2](https://codeberg.org/woodpecker-plugins/go-plugin/releases/tag/v1.0.2) - 2026-01-09
### ❤️ Thanks to all contributors! ❤️
+35 -6
View File
@@ -9,12 +9,40 @@ HTTP client library.
## Builtin settings
| Settings Name | Environment variable | Default | Description |
| ------------- | -------------------- | ------- | ---------------------------------------------------------------------------- | ------------------------------------ |
| ------------- | -------------------- | ------- | ---------------------------------------------------------------------------- |
| `log_level` | - | `info` | Sets log level (`panic`, `fatal`, `error`, `warn`, `info`, `debug`, `trace`) |
| `skip_verify` | - | `false` | - | Skip verification of TLS certificate |
| `skip_verify` | - | `false` | Skip verification of TLS certificate |
| | `SOCKS_PROXY` | _none_ | SOCKS5 proxy to use for connections |
| | `SOCKS_PROXY_OFF` | _none_ | Do not use SOCKS5 proxy |
### Optional: HTTP proxy support
HTTP proxy support is **opt-in** and must be explicitly enabled by the plugin author via `EnableHTTPProxy: true` in `plugin.Options`. When enabled, the following settings become available:
| Settings Name | Environment variable | Default | Description |
| ------------- | -------------------- | ------- | ------------------------------------------------------ |
| `http_proxy` | `HTTP_PROXY` | _none_ | HTTP proxy URL for outgoing connections |
| `https_proxy` | `HTTPS_PROXY` | _none_ | HTTPS proxy URL for outgoing connections |
| `no_proxy` | `NO_PROXY` | _none_ | Comma-separated list of hosts to exclude from proxying |
The settings are resolved in the following order of precedence:
1. **Plugin settings**`PLUGIN_HTTP_PROXY`, `PLUGIN_HTTPS_PROXY`, `PLUGIN_NO_PROXY`
2. **Lowercase env vars**`http_proxy`, `https_proxy`, `no_proxy`
3. **Uppercase env vars**`HTTP_PROXY`, `HTTPS_PROXY`, `NO_PROXY`
Example Woodpecker CI pipeline configuration:
```yaml
steps:
- name: my-plugin
image: my-plugin:latest
settings:
http_proxy: http://proxy.example.com:3128
https_proxy: http://proxy.example.com:3128
no_proxy: "localhost,internal.example.com"
```
## Creating plugin
```go
@@ -62,10 +90,11 @@ func main() {
}
p.Plugin = plugin.New(plugin.Options{
Name: "sample-plugin",
Description: "Sample plugin",
Flags: p.Flags(),
Execute: p.Execute,
Name: "sample-plugin",
Description: "Sample plugin",
Flags: p.Flags(),
Execute: p.Execute,
EnableHTTPProxy: true, // opt-in to HTTP proxy support
})
p.Run()
+8 -8
View File
@@ -1,22 +1,22 @@
module codeberg.org/woodpecker-plugins/go-plugin
go 1.24.0
go 1.25.0
toolchain go1.25.5
toolchain go1.26.4
require (
github.com/joho/godotenv v1.5.1
github.com/rs/zerolog v1.34.0
github.com/rs/zerolog v1.35.1
github.com/stretchr/testify v1.11.1
github.com/urfave/cli/v3 v3.6.1
golang.org/x/net v0.48.0
github.com/urfave/cli/v3 v3.10.0
golang.org/x/net v0.56.0
)
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/sys v0.39.0 // indirect
golang.org/x/sys v0.46.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
+12 -19
View File
@@ -1,31 +1,24 @@
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
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.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/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
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.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
github.com/rs/zerolog v1.34.0 h1:k43nTLIwcTVQAncfCw4KZ2VY6ukYoZaBPNOE8txlOeY=
github.com/rs/zerolog v1.34.0/go.mod h1:bJsvje4Z08ROH4Nhs5iH600c3IkWhwp44iRc54W6wYQ=
github.com/rs/zerolog v1.35.1 h1:m7xQeoiLIiV0BCEY4Hs+j2NG4Gp2o2KPKmhnnLiazKI=
github.com/rs/zerolog v1.35.1/go.mod h1:EjML9kdfa/RMA7h/6z6pYmq1ykOuA8/mjWaEvGI+jcw=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/urfave/cli/v3 v3.6.1 h1:j8Qq8NyUawj/7rTYdBGrxcH7A/j7/G8Q5LhWEW4G3Mo=
github.com/urfave/cli/v3 v3.6.1/go.mod h1:ysVLtOEmg2tOy6PknnYVhDoouyC/6N42TMeoMzskhso=
golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU=
golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
github.com/urfave/cli/v3 v3.10.0 h1:0aU8yOObVDMkM13Cj4G+zb4P0PdeJMec65f81Ak1ioM=
github.com/urfave/cli/v3 v3.10.0/go.mod h1:ysVLtOEmg2tOy6PknnYVhDoouyC/6N42TMeoMzskhso=
golang.org/x/net v0.56.0 h1:Rw8j/hFzGvJUZwNBXnAtf5sVDVt+65SK2C7IxCxZt5o=
golang.org/x/net v0.56.0/go.mod h1:D3Ku6r+V6JROoZK144D2XfMHFcMq/0zSfLelVTCFKec=
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.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw=
golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
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.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
+48 -1
View File
@@ -20,6 +20,7 @@ import (
"crypto/x509"
"net"
"net/http"
"os"
"time"
"github.com/rs/zerolog/log"
@@ -55,13 +56,59 @@ func httpClientFlags() []cli.Flag {
}
}
func HTTPClientFromContext(c *cli.Command) *http.Client {
// httpProxyFlags returns the optional HTTP proxy flags.
// Only added to the app when EnableHTTPProxy is set in Options.
func httpProxyFlags() []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: "transport.http-proxy",
Usage: "HTTP proxy URL",
Sources: cli.EnvVars(
"PLUGIN_HTTP_PROXY",
),
Hidden: true,
},
&cli.StringFlag{
Name: "transport.https-proxy",
Usage: "HTTPS proxy URL",
Sources: cli.EnvVars(
"PLUGIN_HTTPS_PROXY",
),
Hidden: true,
},
&cli.StringFlag{
Name: "transport.no-proxy",
Usage: "Hosts to exclude from proxy (comma-separated)",
Sources: cli.EnvVars(
"PLUGIN_NO_PROXY",
),
Hidden: true,
},
}
}
func HTTPClientFromContext(c *cli.Command, httpProxyEnabled bool) *http.Client {
var (
skip = c.Bool("transport.skip-verify")
socks = c.String("transport.socks-proxy")
socksOff = c.Bool("transport.socks-proxy-off")
)
if httpProxyEnabled {
if v := c.String("transport.http-proxy"); v != "" {
os.Setenv("HTTP_PROXY", v)
os.Setenv("http_proxy", v)
}
if v := c.String("transport.https-proxy"); v != "" {
os.Setenv("HTTPS_PROXY", v)
os.Setenv("https_proxy", v)
}
if v := c.String("transport.no-proxy"); v != "" {
os.Setenv("NO_PROXY", v)
os.Setenv("no_proxy", v)
}
}
certs, err := x509.SystemCertPool()
if err != nil {
log.Error().Err(err).Msg("failed to find system CA certs")
+16 -4
View File
@@ -38,6 +38,10 @@ type Options struct {
Execute ExecuteFunc
// Context the plugin will use while executing.
Context context.Context
// EnableHTTPProxy allows plugins to opt-in to HTTP/HTTPS proxy support.
// When true, PLUGIN_HTTP_PROXY, PLUGIN_HTTPS_PROXY and PLUGIN_NO_PROXY
// are accepted as settings and applied to the HTTP client.
EnableHTTPProxy bool
}
// Plugin defines the plugin instance.
@@ -46,6 +50,8 @@ type Plugin struct {
execute ExecuteFunc
client *http.Client
ctx context.Context
// enableHTTPProxy controls whether HTTP proxy flags are registered and applied.
enableHTTPProxy bool
// Metadata of the current pipeline.
Metadata Metadata
}
@@ -68,10 +74,16 @@ func New(opt Options) *Plugin {
}
plugin := &Plugin{
App: app,
execute: opt.Execute,
ctx: opt.Context,
App: app,
execute: opt.Execute,
ctx: opt.Context,
enableHTTPProxy: opt.EnableHTTPProxy,
}
if opt.EnableHTTPProxy {
app.Flags = append(app.Flags, httpProxyFlags()...)
}
plugin.App.Action = plugin.action
if plugin.ctx == nil {
@@ -87,7 +99,7 @@ func (p *Plugin) action(ctx context.Context, c *cli.Command) error {
}
p.Metadata = MetadataFromContext(c)
p.client = HTTPClientFromContext(c)
p.client = HTTPClientFromContext(c, p.enableHTTPProxy)
if p.execute == nil {
panic("plugin execute function is not set")
+29
View File
@@ -22,13 +22,40 @@ import (
// Step defines runtime metadata for a step.
type Step struct {
Name string `json:"name,omitempty"`
Type StepType `json:"type,omitempty"`
Number int `json:"number,omitempty"`
Started time.Time `json:"started,omitempty"`
Finished time.Time `json:"finished,omitempty"`
}
// StepType identifies the type of step.
type StepType string
const (
StepTypeClone StepType = "clone"
StepTypeService StepType = "service"
StepTypePlugin StepType = "plugin"
StepTypeCommands StepType = "commands"
StepTypeCache StepType = "cache"
)
func stepFlags() []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: "step.name",
Usage: "step name",
Sources: cli.EnvVars(
"CI_STEP_NAME",
),
},
&cli.StringFlag{
Name: "step.type",
Usage: "step type",
Sources: cli.EnvVars(
"CI_STEP_TYPE",
),
},
&cli.IntFlag{
Name: "step.number",
Usage: "step number",
@@ -56,6 +83,8 @@ func stepFlags() []cli.Flag {
func stepFromContext(c *cli.Command) Step {
return Step{
Name: c.String("step.name"),
Type: StepType(c.String("step.type")),
Number: c.Int("step.number"),
Started: time.Unix(c.Int64("step.started"), 0),
Finished: time.Unix(c.Int64("step.finished"), 0),