forgeactions

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultNode12ImageReference is the default image to use
	// when an action specifies that it runs using "node12".
	DefaultNode12ImageReference = "docker.io/library/node:12"
	// DefaultNode16ImageReference is the default image to use
	// when an action specifies that it runs using "node16".
	DefaultNode16ImageReference = "docker.io/library/node:16"
	// DefaultNode16ImageReference is the default image to use
	// when an action specifies that it runs using "node20".
	DefaultNode20ImageReference = "docker.io/library/node:20"
)

Variables

View Source
var (
	DefaultRootPath         = containerfs.WorkingDir
	DefaultWorkspace        = DefaultRootPath + "/workspace"
	DefaultActionPath       = DefaultRootPath + "/action"
	DefaultRunnerPath       = DefaultRootPath + "/runner"
	DefaultRunnerTemp       = DefaultRunnerPath + "/tmp"
	DefaultRunnerToolCache  = DefaultRunnerPath + "/toolcache"
	DefaultGitHubPath       = DefaultRootPath + "/github"
	DefaultGitHubPathPath   = DefaultGitHubPath + "/add_path"
	DefaultGitHubEnvPath    = DefaultGitHubPath + "/set_env"
	DefaultGitHubOutputPath = DefaultGitHubPath + "/set_output"
	DefaultGitHubStatePath  = DefaultGitHubPath + "/save_state"
)
View Source
var (
	// Node12ImageReference is the image to use when an action
	// when an action specifies that it runs using "node12".
	// var so as to be overridable.
	Node12ImageReference = DefaultNode12ImageReference
	// Node16ImageReference is the image to use when an action
	// when an action specifies that it runs using "node16".
	// var so as to be overridable.
	Node16ImageReference = DefaultNode16ImageReference
	// Node16ImageReference is the image to use when an action
	// when an action specifies that it runs using "node20".
	// var so as to be overridable.
	Node20ImageReference = DefaultNode16ImageReference
)
View Source
var DefaultMapping = &Mapping{
	Workspace:        DefaultWorkspace,
	ActionPath:       DefaultActionPath,
	RunnerTemp:       DefaultRunnerTemp,
	RunnerToolCache:  DefaultRunnerToolCache,
	GitHubPath:       DefaultGitHubPath,
	GitHubPathPath:   DefaultGitHubPathPath,
	GitHubEnvPath:    DefaultGitHubEnvPath,
	GitHubOutputPath: DefaultGitHubOutputPath,
	GitHubStatePath:  DefaultGitHubStatePath,
}
View Source
var ErrCantBuildDockerfile = errors.New("runtime cannot build Dockerfile")

ErrCantBuildDockerfile will be returned when a forge.ContainerRuntime does not implement ImageBuilder.

Functions

func ActionToConfigs

func ActionToConfigs(globalContext *githubactions.GlobalContext, uses *githubactions.Uses, with, environment map[string]string, actionMetadata *githubactions.Metadata, image forge.Image) ([]forge.ContainerConfig, error)

func ConfigureGlobalContext

func ConfigureGlobalContext(globalContext *githubactions.GlobalContext) *githubactions.GlobalContext

ConfigureGlobalContext is a re-export of DefaultMapping.ConfigureGlobalContext for convenience purposes.

func GetImageForMetadata

func GetImageForMetadata(ctx context.Context, containerRuntime forge.ContainerRuntime, actionMetadata *githubactions.Metadata, uses *githubactions.Uses) (forge.Image, error)

GetImageForMetadata is a re-export of DefaultMapping.GetImageForMetadata for convenience purposes.

func GetUsesMetadata

func GetUsesMetadata(ctx context.Context, uses *githubactions.Uses) (*githubactions.Metadata, error)

GetUsesMetadata is a re-export of DefaultMapping.GetUsesMetadata for convenience purposes.

func MetadataToImageReference

func MetadataToImageReference(actionMetadata *githubactions.Metadata) string

MetadataToImageReference takes an action.yaml and finds the reference to the OCI image that forge should run it inside of.

func NewWorkflowCommandStreams

func NewWorkflowCommandStreams(globalContext *githubactions.GlobalContext, id string, drains *forge.Drains) *forge.Streams

NewWorkflowCommandStreams takes io.Writers and returns wrapped writers to pass to a process executing a GitHub Action as stdout and stderr. These streams process workflow commands that are written to them and write any corresponding bytes to the underlying writers. They write any non-workflow command bytes directly to the underlying writers.

func SetGlobalContextFromEnvFiles added in v0.5.0

func SetGlobalContextFromEnvFiles(ctx context.Context, globalContext *githubactions.GlobalContext, step string, container forge.Container) error

func UsesToActionDirectory

func UsesToActionDirectory(uses *githubactions.Uses) (string, error)

UsesToActionDirectory is a re-export of DefaultMapping.UsesToActionDirectory for convenience purposes.

func UsesToRootDirectory

func UsesToRootDirectory(uses *githubactions.Uses) (string, error)

UsesToRootDirectory is a re-export of DefaultMapping.UsesToRootDirectory for convenience purposes.

Types

type ImageBuilder

type ImageBuilder interface {
	BuildDockerfile(context.Context, string, string) (forge.Image, error)
}

ImageBuilder is for a ContainerRuntime to implement building a Dockerfile. Because building an OCI image is not ubiquitous, forge.ContainerRuntimes are not required to implement this, but they may. The default runtime (Docker) happens to so as to support GitHub Actions that run using "docker".

type Mapping

type Mapping struct {
	ActionPath       string
	Workspace        string
	RunnerToolCache  string
	RunnerTemp       string
	GitHubPath       string
	GitHubPathPath   string
	GitHubEnvPath    string
	GitHubOutputPath string
	GitHubStatePath  string
}

func (*Mapping) ActionToConfigs

func (m *Mapping) ActionToConfigs(globalContext *githubactions.GlobalContext, uses *githubactions.Uses, with, environment map[string]string, actionMetadata *githubactions.Metadata, image forge.Image) ([]forge.ContainerConfig, error)

func (*Mapping) ConfigureGlobalContext

func (m *Mapping) ConfigureGlobalContext(globalContext *githubactions.GlobalContext) *githubactions.GlobalContext

ConfigureGlobalContext updates the given *githubactions.GlobalContext to use this Mapping's values for various filesystem paths.

func (*Mapping) GetImageForMetadata

func (m *Mapping) GetImageForMetadata(ctx context.Context, containerRuntime forge.ContainerRuntime, actionMetadata *githubactions.Metadata, uses *githubactions.Uses) (forge.Image, error)

GetImageForMetadata takes an action.yml and returns the OCI image that forge should run it inside of. If the action.yml runs using "dockerfile" and the forge.ContainerRuntime does not implement ImageBuilder, returns ErrCantBuildDockerfile.

func (*Mapping) GetUsesMetadata

func (m *Mapping) GetUsesMetadata(ctx context.Context, uses *githubactions.Uses) (*githubactions.Metadata, error)

GetUsesMetadata gets the action.yml for the given *githubactions.Uses.

func (*Mapping) SetGlobalContextFromEnvFiles added in v0.5.0

func (m *Mapping) SetGlobalContextFromEnvFiles(ctx context.Context, globalContext *githubactions.GlobalContext, step string, container forge.Container) error

func (*Mapping) UsesToActionDirectory

func (m *Mapping) UsesToActionDirectory(uses *githubactions.Uses) (string, error)

UsesToRootDirectory takes a *githubactions.Uses and returns the path to the directory where the corresponding action.yml can be found on the host machine.

func (*Mapping) UsesToRootDirectory

func (m *Mapping) UsesToRootDirectory(uses *githubactions.Uses) (string, error)

UsesToRootDirectory takes a *githubactions.Uses and returns the path to where the corresponding git repository can be found on the host machine.

Jump to

Keyboard shortcuts

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