Documentation ¶
Index ¶
- Constants
- Variables
- func ActionToConfigs(globalContext *githubactions.GlobalContext, uses *githubactions.Uses, ...) ([]forge.ContainerConfig, error)
- func ConfigureGlobalContext(globalContext *githubactions.GlobalContext) *githubactions.GlobalContext
- func GetImageForMetadata(ctx context.Context, containerRuntime forge.ContainerRuntime, ...) (forge.Image, error)
- func GetUsesMetadata(ctx context.Context, uses *githubactions.Uses) (*githubactions.Metadata, error)
- func MetadataToImageReference(actionMetadata *githubactions.Metadata) string
- func NewWorkflowCommandStreams(globalContext *githubactions.GlobalContext, id string, drains *forge.Drains) *forge.Streams
- func SetGlobalContextFromEnvFiles(ctx context.Context, globalContext *githubactions.GlobalContext, step string, ...) error
- func UsesToActionDirectory(uses *githubactions.Uses) (string, error)
- func UsesToRootDirectory(uses *githubactions.Uses) (string, error)
- type ImageBuilder
- type Mapping
- func (m *Mapping) ActionToConfigs(globalContext *githubactions.GlobalContext, uses *githubactions.Uses, ...) ([]forge.ContainerConfig, error)
- func (m *Mapping) ConfigureGlobalContext(globalContext *githubactions.GlobalContext) *githubactions.GlobalContext
- func (m *Mapping) GetImageForMetadata(ctx context.Context, containerRuntime forge.ContainerRuntime, ...) (forge.Image, error)
- func (m *Mapping) GetUsesMetadata(ctx context.Context, uses *githubactions.Uses) (*githubactions.Metadata, error)
- func (m *Mapping) SetGlobalContextFromEnvFiles(ctx context.Context, globalContext *githubactions.GlobalContext, step string, ...) error
- func (m *Mapping) UsesToActionDirectory(uses *githubactions.Uses) (string, error)
- func (m *Mapping) UsesToRootDirectory(uses *githubactions.Uses) (string, error)
Constants ¶
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 ¶
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" )
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 )
var DefaultMapping = &Mapping{ Workspace: DefaultWorkspace, ActionPath: DefaultActionPath, RunnerTemp: DefaultRunnerTemp, RunnerToolCache: DefaultRunnerToolCache, GitHubPath: DefaultGitHubPath, GitHubPathPath: DefaultGitHubPathPath, GitHubEnvPath: DefaultGitHubEnvPath, GitHubOutputPath: DefaultGitHubOutputPath, GitHubStatePath: DefaultGitHubStatePath, }
var ErrCannotBuildDockerfile = errors.New("runtime cannot build Dockerfile")
ErrCannotBuildDockerfile 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 ErrCannotBuildDockerfile.
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.