wccs

package module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 9, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

README

Woodpecker CI Config Service

Pipeline Status Matrix space Go Report Card go reference GitHub release

woodpecker-ci-config-service is a command-line interface (CLI) tool designed to work with Woodpecker CI configurations. It provides functionalities to convert and serve configuration files for Woodpecker CI, a powerful and flexible continuous integration system.

Features

  • Convert Command – Convert configuration files from a source format to Woodpecker CI format.
  • Server Command – Serve configuration files through a web service for CI runs.

Why Use Woodpecker CI Config Service?

When integrating Woodpecker CI into your development workflow, woodpecker-ci-config-service helps streamline the process of managing and serving configuration files. It provides:

  • Easy conversion from supported formats (currently Starlark) to Woodpecker CI configuration.
  • Flexible output options, either to stdout or to disk.
  • A web server to serve configurations to CI runs directly.

Commands

Convert Command

The convert command converts configuration files from a source format to Woodpecker CI format. Currently, it supports conversion from Starlark.

Usage
# using the forge environment
ENV_SECRET_GITHUB_TOKEN=XXX wccs convert testdata/convert.forge.json [--out <output-file>]
# using the fs environment
WCCS_CONVERT_PROVIDERS=fs WCCS_CONVERT_PROVIDER_FS_SOURCE=testdata/*.star wccs convert testdata/convert.fs.json [--out <output-file>]
Server Command

The server command starts a web server that serves configuration files for CI runs.

Usage
wccs server

Installation

To install woodpecker-ci-config-service, clone the repository and build the tool:

git clone https://github.com/opencloud-eu/woodpecker-ci-config-service.git
cd woodpecker-ci-config-service
go build -o bin/wccs cmd/wccs/*.go

Future Improvements

  • Support for additional source formats for conversion.
  • Support for additional forges and private repositories.
  • Improved error handling and logging.

License

This project is licensed under the Apache License 2.0.

Contributions

Contributions are welcome! Feel free to submit issues or pull requests to improve woodpecker-ci-config-service.

Acknowledgements

Special thanks to the Woodpecker CI team for their amazing work on the Woodpecker CI project.

The logo was generated using DALL-E. Thanks to the DALL-E team for providing such a fantastic tool.

Contact

For more information, reach out via the GitHub Issues.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnknownType is returned when the type is unknown.
	ErrUnknownType = fmt.Errorf("unknown type")
	// ErrNoConfig is returned when no configuration file is provided.
	ErrNoConfig = fmt.Errorf("no configuration file provided")
	// ErrNoContent is returned when no content is provided.
	ErrNoContent = fmt.Errorf("no content provided")
	// ErrNoEntrypoint is returned when no entrypoint is found.
	ErrNoEntrypoint = fmt.Errorf("no entrypoint found")
	// ErrMissingParam is returned when a parameter is missing.
	ErrMissingParam = fmt.Errorf("missing parameter")
)

Functions

func AllowedMethodsMiddlewareFactory

func AllowedMethodsMiddlewareFactory(methods ...string) (func(http.Handler) http.Handler, error)

AllowedMethodsMiddlewareFactory is a middleware that checks if the given request method is allowed.

func ConfigurationHandler

func ConfigurationHandler(logger *slog.Logger, converters Converters, providers Providers) http.Handler

ConfigurationHandler is a http handler that fetches the configuration files for the given repository.

func Must

func Must(err error)

Must is a helper that panics if the error is not nil.

func Must1

func Must1[T any](t T, err error) T

Must1 is a helper that panics if the error is not nil.

func VerifierMiddlewareFactory

func VerifierMiddlewareFactory(pubKeyPath string) (func(http.Handler) http.Handler, error)

VerifierMiddlewareFactory is a middleware that verifies the given request signature.

Types

type Converter

type Converter interface {
	Convert(File, Environment) ([]File, error)
	Compatible(f File) bool
}

Converter converts the given data to a slice of files.

type Converters

type Converters []Converter

Converters contains multiple converters.

func (Converters) Convert

func (converters Converters) Convert(files []File, env Environment) ([]File, error)

Convert converts multiple files using the available converters.

type Environment

type Environment struct {
	Repo     model.Repo     `json:"repo"`
	Pipeline model.Pipeline `json:"pipeline"`
	Netrc    model.Netrc    `json:"netrc"`
}

Environment represents the environment for the configuration.

type FSProvider

type FSProvider struct {
	// contains filtered or unexported fields
}

FSProvider provides configuration files from the filesystem.

func NewFSProvider

func NewFSProvider(p string, logger *slog.Logger) (FSProvider, error)

NewFSProvider returns a new FSProvider.

func (FSProvider) Get

func (p FSProvider) Get(_ context.Context, env Environment) ([]File, error)

Get returns the configuration file for the given environment.

type File

type File struct {
	Name string `json:"name"`
	Data string `json:"data"`
}

File represents a file.

type ForgeProvider

type ForgeProvider struct {
	// contains filtered or unexported fields
}

ForgeProvider wraps available woodpecker forges.

func NewForgeProvider

func NewForgeProvider(logger *slog.Logger) (ForgeProvider, error)

NewForgeProvider returns a new ForgeProvider.

func (ForgeProvider) Get

func (p ForgeProvider) Get(ctx context.Context, env Environment) ([]File, error)

Get returns the configuration file for the given environment.

type Provider

type Provider interface {
	Get(context.Context, Environment) ([]File, error)
}

Provider provides the configuration file.

type ProviderType

type ProviderType string

ProviderType defines the type of the provider.

const (
	// ProviderTypeForge is the type for forge providers.
	ProviderTypeForge ProviderType = "forge"
	// ProviderTypeFS is the type for filesystem providers.
	ProviderTypeFS ProviderType = "fs"
)

type Providers

type Providers []Provider

Providers contains multiple converters.

func (Providers) Get

func (providers Providers) Get(ctx context.Context, env Environment) ([]File, error)

Get returns the files by using the available providers.

type StarlarkConverter

type StarlarkConverter struct {
	// contains filtered or unexported fields
}

StarlarkConverter is a converter that reads, transpiles and migrates Starlark configuration files.

func NewStarlarkConverter

func NewStarlarkConverter(logger *slog.Logger) (StarlarkConverter, error)

NewStarlarkConverter returns a new StarlarkConverter.

func (StarlarkConverter) Compatible

func (p StarlarkConverter) Compatible(f File) bool

func (StarlarkConverter) Convert

func (p StarlarkConverter) Convert(f File, env Environment) ([]File, error)

Convert reads, transpiles and migrates Starlark configuration files to the required format.

Directories

Path Synopsis
cmd
wccs command
internal
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL