Documentation
¶
Index ¶
- Variables
- func AllowedMethodsMiddlewareFactory(methods ...string) (func(http.Handler) http.Handler, error)
- func ConfigurationHandler(logger *slog.Logger, converters Converters, providers Providers) http.Handler
- func Must(err error)
- func Must1[T any](t T, err error) T
- func VerifierMiddlewareFactory(pubKeyPath string) (func(http.Handler) http.Handler, error)
- type Converter
- type Converters
- type Environment
- type FSProvider
- type File
- type ForgeProvider
- type Provider
- type ProviderType
- type Providers
- type StarlarkConverter
Constants ¶
This section is empty.
Variables ¶
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 ¶
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.
Types ¶
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 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 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.