modules

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2022 License: BlueOak-1.0.0 Imports: 8 Imported by: 1

Documentation

Overview

modules provides an extendable interface for executable components in the build pipeline.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterModule

func RegisterModule(definition *ModuleRegistration)

RegisterModule allows modules to register themselves during init(), by providing a definition of type ModuleRegistration.

Types

type Module

type Module struct {
	Type string
	Pluggable
}

Module is a single module, specifying its type and its Pluggable

func (*Module) Run

func (mod *Module) Run(ctx context.Context) error

Run executes a module, and measures its wallclock time spent

type ModuleRegistration

type ModuleRegistration struct {
	// Stage is a string representation of the stage the module is
	// registered into. To register a module into every stage, specify
	// "*" as stage.
	Stage string
	// Type is a string representation of the module's name.
	Type string
	// Factory is the factory method to create a new module
	// with defaults.
	Factory PluggableFactory
}

ModuleRegistration is a Pluggable registration entry for module registration

func (*ModuleRegistration) Kind

func (mod *ModuleRegistration) Kind() string

type Pluggable

type Pluggable interface {
	Run(context.Context) error
}

Pluggable is a module, which can be pluggable into a pipeline

type PluggableFactory

type PluggableFactory func() Pluggable

PluggableFactory is a method, which yields a Pluggable

func LookupModule

func LookupModule(kind string) (PluggableFactory, bool)

LookupModule returns a PluggableFactory based on its Kind as a side effect, it also flags the module as loaded

type TemplateData

type TemplateData struct {
	// Algo represents algorithm. Hashing and signing modules use them.
	Algo string
	// Arch defines target architecture
	Arch string
	// ArchName is a textual representation of Arch, optionally combining 32bit ARM versions
	// eg. GOARCH=arm GOARM=6 means ArchName=armv6
	ArchName string
	// ArmVersion is the 32bit arm version (supported: 5, 6, 7)
	ArmVersion int32
	// ArchiveName defines a URL where the resource will be remotely available
	ArchiveName string
	// Env is a copy of environment variables set in ctx.Context
	Env *withenv.Env
	// Git is a copy of git-related info from ctx.Context
	Git *ctx.GitData
	// OS defines target operating system
	OS string
	// ProjectName defines local filename of the resource
	ProjectName string
	// Version defines artifact's version
	Version string
	// Ext contains executable extension
	Ext string
}

TemplateData is the data all template-based text replacement takes place. Modules are responsible of filling in the appropriate fields, and handle dependencies (for example, ArchiveName is often depends on ProjectName, therefore modules have to render them in ProjectName then ArchiveName order)

func NewTemplate

func NewTemplate(cx context.Context) (*TemplateData, error)

func (*TemplateData) Parse

func (td *TemplateData) Parse(name, text string) (string, error)

Parse parses a string based on TemplateData, and returns output in string format

Jump to

Keyboard shortcuts

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