Woodpecker CI plugin library
Go to file
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.yaml Update golang Docker tag to v1.21 (#9) 2023-10-27 12:27:37 +00:00
commit.go Initial implementation 2023-01-08 04:53:03 +02:00
flags.go Initial implementation 2023-01-08 04:53:03 +02:00
go.mod Update module golang.org/x/net to v0.17.0 2023-10-27 00:09:34 +00:00
go.sum Update module golang.org/x/net to v0.17.0 2023-10-27 00:09:34 +00:00
http.go Initial implementation 2023-01-08 04:53:03 +02:00
LICENSE Initial implementation 2023-01-08 04:53:03 +02:00
logger.go Fix to not log time in output (#3) 2023-01-09 12:33:18 +00:00
metadata_test.go Initial implementation 2023-01-08 04:53:03 +02:00
metadata.go Initial implementation 2023-01-08 04:53:03 +02:00
pipeline.go Initial implementation 2023-01-08 04:53:03 +02:00
plugin_test.go Initial implementation 2023-01-08 04:53:03 +02:00
plugin.go Initial implementation 2023-01-08 04:53:03 +02:00
README.md Initial implementation 2023-01-08 04:53:03 +02:00
renovate.json Configure Renovate (#4) 2023-10-16 16:52:34 +00:00
repo.go Initial implementation 2023-01-08 04:53:03 +02:00
step.go Initial implementation 2023-01-08 04:53:03 +02:00
system.go Initial implementation 2023-01-08 04:53:03 +02:00

Library for creating Woodpecker CI plugins

Provides basic structure and helpers to load Woodpecker CI environment variables while also supporting reading Drone CI environment variables where available.

Adds logging support based on zerolog library and allows configurable 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 -
SOCKS_PROXY none SOCKS5 proxy to use for connections
SOCKS_PROXY_OFF none Do not use SOCKS5 proxy

Creating plugin

import (
    "context"

    "codeberg.org/woodpecker-plugins/go-plugin"
    "github.com/urfave/cli/v2"
    "github.com/rs/zerolog/log"
)

type Settings struct {
    // TODO: Plugin settings
    SampleFlag string
}

type Plugin struct {
    *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,
        },
    }
}

func (p *Plugin) Execute(ctx context.Context) error {
    // 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.Run()
}