job

package
v0.2.11 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetErrMsg

func GetErrMsg(jobName, jobId, msg string, err error) string

func GetInfoMsg

func GetInfoMsg(jobName, jobId, msg string) string

Types

type InitOptions

type InitOptions struct {
	Name        string
	Stack       string
	PipelineCfg *pipeline.Config

	// Directories that the task will use.
	WorkDir   string
	MountDir  string
	TargetDir string

	// Scanned Environment variables to resolve, and set.
	ScanAWSEnvVars          bool
	ScanTerraformEnvVars    bool
	EnvVarsToSet            map[string]string
	EnvVarsToScan           []string
	EnvVarsWithPrefixToScan []string
	IsScanEnvVarsFromDotEnv bool
	IsScanEnvVarsFromPrefix bool
	DotEnvFile              string
}

type Instance

type Instance struct {
	InitOptions *InitOptions
	JobName     string
	JobId       string
}

func (*Instance) BuildMountDir

func (i *Instance) BuildMountDir(client *dagger.Client, mountDir string) (*dagger.Directory,
	error)

func (*Instance) BuildRootDir

func (i *Instance) BuildRootDir(client *dagger.Client) (*dagger.Directory, error)

BuildRootDir 8. Build root directory.

func (*Instance) BuildTargetDir

func (i *Instance) BuildTargetDir(client *dagger.Client, targetDir string) (*dagger.Directory,
	error)

func (*Instance) BuildWorkDir

func (i *Instance) BuildWorkDir(client *dagger.Client, workDir string) (*dagger.Directory, error)

func (*Instance) InitContainer

func (i *Instance) InitContainer(c *dagger.Client, imageURL string) (*dagger.Container, error)

InitContainer 3. Get the container.

func (*Instance) InitContainerImage

func (i *Instance) InitContainerImage() (string, error)

InitContainerImage 2. Get the container image.

func (*Instance) InitDagger

func (i *Instance) InitDagger() (*dagger.Client, error)

InitDagger 1. Init the job, initialising the Dagger client.

func (*Instance) ScanAllEnvVars added in v0.2.2

func (i *Instance) ScanAllEnvVars() (map[string]string, error)

func (*Instance) ScanEnvVarsAWSKeys

func (i *Instance) ScanEnvVarsAWSKeys(scanAWSVars bool) (map[string]string, error)

ScanEnvVarsAWSKeys 4. Scan (if applicable) AWS keys environment variables.

func (*Instance) ScanEnvVarsCustom

func (i *Instance) ScanEnvVarsCustom(scanCustomVars []string) (map[string]string, error)

ScanEnvVarsCustom 6. Scan (if applicable) custom environment variables.

func (*Instance) ScanEnvVarsFromDotEnvFile added in v0.2.2

func (i *Instance) ScanEnvVarsFromDotEnvFile(dotEnvFile string) (map[string]string, error)

func (*Instance) ScanEnvVarsFromPrefix added in v0.2.8

func (i *Instance) ScanEnvVarsFromPrefix(prefixes []string) (map[string]string, error)

func (*Instance) ScanEnvVarsTerraform

func (i *Instance) ScanEnvVarsTerraform(scanAWSVars bool) (map[string]string, error)

ScanEnvVarsTerraform 5. Scan (if applicable) Terraform environment variables.

func (*Instance) ValidatedEnvVarsPassed

func (i *Instance) ValidatedEnvVarsPassed(envVarsToSet map[string]string) (map[string]string, error)

ValidatedEnvVarsPassed 7. Validate environment variables to be set.

type Job

type Job struct {
	// Identifiers.
	Id    string
	Name  string
	Stack string

	// PipelineCfg client.
	PipelineCfg *pipeline.Config
	Client      *dagger.Client

	// Dagger directories
	RootDir   *dagger.Directory // Normally should be the same as the workDir
	WorkDir   *dagger.Directory
	MountDir  *dagger.Directory
	TargetDir *dagger.Directory

	RootDirPath   string
	WorkDirPath   string
	MountDirPath  string
	TargetDirPath string

	// Container configuration.
	ContainerImageURL string
	ContainerDefault  *dagger.Container

	// Scanned Environment variables to resolve, and set.
	EnvVarsAWSScanned        map[string]string
	EnvVarsTerraformScanned  map[string]string
	EnvVarsCustomScanned     map[string]string
	EnvVarsAllScanned        map[string]string
	EnvVarsToSet             map[string]string
	EnvVarsFromDotEnvFile    map[string]string
	EnvVarsFromPrefixScanned map[string]string

	Ctx context.Context
}

func NewJob

func NewJob(p *pipeline.Config, new InitOptions) (*Job, error)

type Runner

type Runner interface {
	InitDagger() (*dagger.Client, error)
	InitContainerImage() (string, error)
	InitContainer(c *dagger.Client, imageURL string) (*dagger.Container, error)
	ScanEnvVarsAWSKeys(scanAWSVars bool) (map[string]string, error)
	ScanEnvVarsTerraform(scanTerraformVars bool) (map[string]string, error)
	ScanEnvVarsCustom(scanCustomVars []string) (map[string]string, error)
	ScanAllEnvVars() (map[string]string, error)
	ScanEnvVarsFromDotEnvFile(dotEnvFile string) (map[string]string, error)
	ScanEnvVarsFromPrefix(prefixes []string) (map[string]string, error)
	ValidatedEnvVarsPassed(envVarsToSet map[string]string) (map[string]string, error)
	BuildRootDir(client *dagger.Client) (*dagger.Directory, error)
	BuildWorkDir(client *dagger.Client, workDir string) (*dagger.Directory, error)
	BuildMountDir(client *dagger.Client, mountDir string) (*dagger.Directory, error)
	BuildTargetDir(client *dagger.Client, targetDir string) (*dagger.Directory, error)
}

Jump to

Keyboard shortcuts

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