Documentation ¶
Index ¶
- Constants
- Variables
- type EnvInfo
- type EnvPathType
- type Environment
- func (e *Environment) AddChild(env *Environment)
- func (e *Environment) CreateTempRoot() string
- func (e *Environment) Decode(obj interface{}) interface{}
- func (e *Environment) Destroy() error
- func (e *Environment) DownloadAndDecode(obj interface{}, downloadSource bool) interface{}
- func (e *Environment) Encode(obj interface{}) interface{}
- func (e *Environment) Exec(cmd environmenttypes.Command) (stdout string, stderr string, exitcode int, err error)
- func (e *Environment) GetEnvironmentContext() string
- func (e *Environment) GetEnvironmentOutput() string
- func (e *Environment) GetEnvironmentSource() string
- func (e *Environment) GetProjectName() string
- func (e *Environment) IsPathValid(path string) bool
- func (e *Environment) OutputRel(destPath string) (string, error)
- func (e *Environment) PathType(destPath string) (EnvPathType, error)
- func (e *Environment) ProcessPathMappings(pathMappings []transformertypes.PathMapping) []transformertypes.PathMapping
- func (e *Environment) Rel(destPath string) (string, error)
- func (e *Environment) Reset() error
- func (e *Environment) SourceRel(destPath string) (string, error)
- type EnvironmentInstance
- type EnvironmentNotActiveError
- type Local
- func (e *Local) Destroy() error
- func (e *Local) Download(path string) (string, error)
- func (e *Local) Exec(cmd environmenttypes.Command) (stdout string, stderr string, exitcode int, err error)
- func (e *Local) GetContext() string
- func (e *Local) GetSource() string
- func (e *Local) Reset() error
- func (e *Local) Stat(name string) (fs.FileInfo, error)
- func (e *Local) Upload(outpath string) (envpath string, err error)
- type PeerContainer
- func (e *PeerContainer) Destroy() error
- func (e *PeerContainer) Download(path string) (string, error)
- func (e *PeerContainer) Exec(cmd environmenttypes.Command) (stdout string, stderr string, exitcode int, err error)
- func (e *PeerContainer) GetContext() string
- func (e *PeerContainer) GetSource() string
- func (e *PeerContainer) Reset() error
- func (e *PeerContainer) Stat(name string) (fs.FileInfo, error)
- func (e *PeerContainer) Upload(outpath string) (envpath string, err error)
Constants ¶
const (
// DefaultWorkspaceDir is the default workspace directory
DefaultWorkspaceDir = "workspace"
)
Variables ¶
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 Isolated bool Source string Output string Context string CurrEnvOutputBasePath string RelTemplatesDir string TempPath string }
EnvInfo stores the envionment generic info
type EnvPathType ¶
type EnvPathType string
EnvPathType stores possible path types
const ( // SourcePathType represents source path type SourcePathType EnvPathType = "Source" // OutputPathType represents output path type OutputPathType EnvPathType = "Output" )
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 environmenttypes.Command) (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) IsPathValid ¶
func (e *Environment) IsPathValid(path string) bool
IsPathValid returns if the project path is valid or not
func (*Environment) OutputRel ¶
func (e *Environment) OutputRel(destPath string) (string, error)
OutputRel makes the path relative. Exposed to be used within path-mapping destination-path template.
func (*Environment) PathType ¶
func (e *Environment) PathType(destPath string) (EnvPathType, error)
PathType makes the path 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
type EnvironmentInstance ¶
type EnvironmentInstance interface { Reset() error Stat(name string) (fs.FileInfo, error) Download(envpath string) (outpath string, err error) Upload(outpath string) (envpath string, err error) Exec(cmd environmenttypes.Command) (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) 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 ¶
GetContext returns the context of Local
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