environment

package
v0.3.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2021 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultWorkspaceDir is the default workspace directory
	DefaultWorkspaceDir = "workspace"
)

Variables

View Source
var (
	// GRPCEnvName represents the environment variable name used to pass the GRPC server information to the transformers
	GRPCEnvName = strings.ToUpper(types.AppNameShort) + "_QA_GRPC_SERVER"
	// ProjectNameEnvName stores the project name
	ProjectNameEnvName = strings.ToUpper(types.AppNameShort) + "_PROJECT_NAME"
	// SourceEnvName stores the source path
	SourceEnvName = strings.ToUpper(types.AppNameShort) + "_SOURCE"
	// OutputEnvName stores the output path
	OutputEnvName = strings.ToUpper(types.AppNameShort) + "_OUTPUT"
	// ContextEnvName stores the context
	ContextEnvName = strings.ToUpper(types.AppNameShort) + "_CONTEXT"
	// CurrOutputEnvName stores the location of output from the previous iteration
	CurrOutputEnvName = strings.ToUpper(types.AppNameShort) + "_CURRENT_OUTPUT"
	// RelTemplatesDirEnvName stores the rel templates directory
	RelTemplatesDirEnvName = strings.ToUpper(types.AppNameShort) + "_RELATIVE_TEMPLATES_DIR"
	// TempPathEnvName stores the temp path
	TempPathEnvName = strings.ToUpper(types.AppNameShort) + "_TEMP"
	// EnvNameEnvName stores the environment name
	EnvNameEnvName = strings.ToUpper(types.AppNameShort) + "_ENV_NAME"
)

Functions

This section is empty.

Types

type EnvInfo

type EnvInfo struct {
	Name          string
	ProjectName   string
	TargetCluster collection.ClusterMetadata

	Isolated bool

	Source                string
	Output                string
	Context               string
	CurrEnvOutputBasePath string
	RelTemplatesDir       string
	TempPath              string
}

EnvInfo stores the envionment generic info

type Environment

type Environment struct {
	EnvInfo
	Env          EnvironmentInstance
	Children     []*Environment
	TempPathsMap map[string]string
	// contains filtered or unexported fields
}

Environment is used to manage EnvironmentInstances

func NewEnvironment

func NewEnvironment(envInfo EnvInfo, grpcQAReceiver net.Addr, c environmenttypes.Container) (env *Environment, err error)

NewEnvironment creates a new environment

func (*Environment) AddChild

func (e *Environment) AddChild(env *Environment)

AddChild adds a child to the environment

func (*Environment) CreateTempRoot

func (e *Environment) CreateTempRoot() string

CreateTempRoot returns the "/" to indicate the temp-root creation. Exposed to be used within path-mapping destination-path template.

func (*Environment) Decode

func (e *Environment) Decode(obj interface{}) interface{}

Decode decodes all paths in the passed obj

func (*Environment) Destroy

func (e *Environment) Destroy() error

Destroy destroys all artifacts specific to the environment

func (*Environment) DownloadAndDecode

func (e *Environment) DownloadAndDecode(obj interface{}, downloadSource bool) interface{}

DownloadAndDecode downloads and decodes the data from the paths in the object

func (*Environment) Encode

func (e *Environment) Encode(obj interface{}) interface{}

Encode encodes all paths in the obj to be relevant to the environment

func (*Environment) Exec

func (e *Environment) Exec(cmd []string) (stdout string, stderr string, exitcode int, err error)

Exec executes an executable within the environment

func (*Environment) GetEnvironmentContext

func (e *Environment) GetEnvironmentContext() string

GetEnvironmentContext returns the context path within the environment

func (*Environment) GetEnvironmentOutput

func (e *Environment) GetEnvironmentOutput() string

GetEnvironmentOutput returns the output path within the environment

func (*Environment) GetEnvironmentSource

func (e *Environment) GetEnvironmentSource() string

GetEnvironmentSource returns the source path within the environment

func (*Environment) GetProjectName

func (e *Environment) GetProjectName() string

GetProjectName returns the project name

func (*Environment) OutputRel

func (e *Environment) OutputRel(destPath string) (string, error)

OutputRel makes the path output-dir relative. Exposed to be used within path-mapping destination-path template.

func (*Environment) ProcessPathMappings

func (e *Environment) ProcessPathMappings(pathMappings []transformertypes.PathMapping) []transformertypes.PathMapping

ProcessPathMappings post processes the paths in the path mappings

func (*Environment) Reset

func (e *Environment) Reset() error

Reset resets an environment

func (*Environment) SourceRel

func (e *Environment) SourceRel(destPath string) (string, error)

SourceRel makes the path base-dir relative. Exposed to be used within path-mapping destination-path template.

type EnvironmentInstance

type EnvironmentInstance interface {
	Reset() error
	Download(envpath string) (outpath string, err error)
	Upload(outpath string) (envpath string, err error)
	Exec(cmd []string) (stdout string, stderr string, exitcode int, err error)
	Destroy() error

	GetSource() string
	GetContext() string
}

EnvironmentInstance represents a actual instance of an environment which the Environment manages

func NewLocal

func NewLocal(envInfo EnvInfo, grpcQAReceiver net.Addr) (ei EnvironmentInstance, err error)

NewLocal creates a new Local environment

func NewPeerContainer

func NewPeerContainer(envInfo EnvInfo, grpcQAReceiver net.Addr, c environmenttypes.Container) (ei EnvironmentInstance, err error)

NewPeerContainer creates an instance of peer container based environment

type EnvironmentNotActiveError

type EnvironmentNotActiveError struct {
}

EnvironmentNotActiveError represents the error when an environment is not active and a function is called on it

func (*EnvironmentNotActiveError) Error

func (e *EnvironmentNotActiveError) Error() string

Error implements the Error interface

type Local

type Local struct {
	EnvInfo

	WorkspaceSource  string
	WorkspaceContext string

	GRPCQAReceiver net.Addr
}

Local manages a local machine environment

func (*Local) Destroy

func (e *Local) Destroy() error

Destroy destroys all artifacts specific to the environment

func (*Local) Download

func (e *Local) Download(path string) (string, error)

Download downloads the path to outside the environment

func (*Local) Exec

func (e *Local) Exec(cmd environmenttypes.Command) (stdout string, stderr string, exitcode int, err error)

Exec executes an executable within the environment

func (*Local) GetContext

func (e *Local) GetContext() string

GetContext returns the context of Local

func (*Local) GetSource

func (e *Local) GetSource() string

GetSource returns the source of Local

func (*Local) Reset

func (e *Local) Reset() error

Reset resets the environment to fresh state

func (*Local) Upload

func (e *Local) Upload(outpath string) (envpath string, err error)

Upload uploads the path from outside the environment into it

type PeerContainer

type PeerContainer struct {
	EnvInfo

	WorkspaceSource  string
	WorkspaceContext string

	GRPCQAReceiver net.Addr

	ImageName     string
	ImageWithData string
	CID           string // A started instance of ImageWithData
}

PeerContainer is supports spawning peer containers to run the environment

func (*PeerContainer) Destroy

func (e *PeerContainer) Destroy() error

Destroy destroys the container instance

func (*PeerContainer) Download

func (e *PeerContainer) Download(path string) (string, error)

Download downloads the path to outside the environment

func (*PeerContainer) Exec

func (e *PeerContainer) Exec(cmd environmenttypes.Command) (stdout string, stderr string, exitcode int, err error)

Exec executes a command in the container

func (*PeerContainer) GetContext

func (e *PeerContainer) GetContext() string

GetContext returns the context within the PeerContainer environment

func (*PeerContainer) GetSource

func (e *PeerContainer) GetSource() string

GetSource returns the source path within the PeerContainer environment

func (*PeerContainer) Reset

func (e *PeerContainer) Reset() error

Reset resets the PeerContainer environment

func (*PeerContainer) Upload

func (e *PeerContainer) Upload(outpath string) (envpath string, err error)

Upload uploads the path from outside the environment into it

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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