shell

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DryRunVariableName specifies the environment variable used within shell script to detect if we are in dryrun mode
	DryRunVariableName = "DRY_RUN"
	// CurrentStageVariableName is the environment variable containing the current pipeline stage such as source, condition, target
	CurrentStageVariableName = "UPDATECLI_PIPELINE_STAGE"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Environment added in v0.28.0

type Environment struct {
	// Name defines the environment variable name
	Name string `yaml:",omitempty" jsonschema:"required"`
	// Value defines the environment variable value
	Value string `yaml:",omitempty"`
}

Environment is a struct containing information for an environment variable such as its name and its value

func (*Environment) Load added in v0.28.0

func (e *Environment) Load() error

Load updates the environment value based on Updatecli environment variables, if the value is not defined yet

func (Environment) String added in v0.28.0

func (e Environment) String() string

func (Environment) Validate added in v0.28.0

func (e Environment) Validate() error

Validate ensures that required parameter are set

type Environments added in v0.28.0

type Environments []Environment

func (*Environments) Load added in v0.28.0

func (e *Environments) Load() error

Load updates all environment value based on Updatecli environment variables, at the condition that the value is not defined yet

func (Environments) ToStringSlice added in v0.28.0

func (e Environments) ToStringSlice() []string

ToStringSlice return all environment variable key=value as a slice of string

func (Environments) Validate added in v0.28.0

func (e Environments) Validate() error

Validate ensures that we don't have duplicated value for a variable and that the user is not attempting to override the DRY_RUN reserved variable.

type ErrEmptyCommand

type ErrEmptyCommand struct{}

func (*ErrEmptyCommand) Error

func (e *ErrEmptyCommand) Error() string

type ExecutionFailedError

type ExecutionFailedError struct{}

func (*ExecutionFailedError) Error

func (e *ExecutionFailedError) Error() string

type MockCommandExecutor

type MockCommandExecutor struct {
	GotCommand command
	Result     commandResult
	Err        error
}

MockCommandExecutor is a stub implementation of the `commandExecutor` interface to be used in our test suite. It stores the received `command` and returns the preconfigured `result` and `err`.

func (*MockCommandExecutor) ExecuteCommand

func (mce *MockCommandExecutor) ExecuteCommand(cmd command) (commandResult, error)

type Shell

type Shell struct {
	// contains filtered or unexported fields
}

Shell defines a resource of kind "shell"

func New

func New(spec interface{}) (*Shell, error)

New returns a reference to a newly initialized Shell object from a ShellSpec or an error if the provided ShellSpec triggers a validation error.

func (*Shell) Changelog

func (s *Shell) Changelog() string

Changelog returns the changelog for this resource, or an empty string if not supported

func (*Shell) Condition

func (s *Shell) Condition(source string) (bool, error)

Condition tests if the provided command (concatenated with the source) is executed with success

func (*Shell) ConditionFromSCM

func (s *Shell) ConditionFromSCM(source string, scm scm.ScmHandler) (bool, error)

ConditionFromSCM tests if the provided command (concatenated with the source) is executed with success from the SCM root directory

func (*Shell) Source

func (s *Shell) Source(workingDir string) (string, error)

Source returns the stdout of the shell command if its exit code is 0 otherwise an error is returned with the content of stderr

func (*Shell) Target

func (s *Shell) Target(source string, dryRun bool) (bool, error)

func (*Shell) TargetFromSCM

func (s *Shell) TargetFromSCM(source string, scm scm.ScmHandler, dryRun bool) (bool, []string, string, error)

type Spec

type Spec struct {
	// Specifies the shell command
	Command string `yaml:",omitempty" jsonschema:"required"`
	// Environments allows to pass environment variable(s) to the shell script
	Environments Environments `yaml:",omitempty"`
}

Spec defines a specification for a "shell" resource parsed from an updatecli manifest file

Jump to

Keyboard shortcuts

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