ext

package
v0.0.0-...-ddafa38 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ShellTypeBash         ShellType      = "sh"
	ShellTypePowershell   ShellType      = "pwsh"
	ScriptTypeUnknown     ShellType      = ""
	ScriptLocationInline  ScriptLocation = "inline"
	ScriptLocationPath    ScriptLocation = "path"
	ScriptLocationUnknown ScriptLocation = ""
	// Executes pre hooks
	HookTypePre HookType = "pre"
	// Execute post hooks
	HookTypePost        HookType         = "post"
	HookTypeNone        HookType         = ""
	HookPlatformWindows HookPlatformType = "windows"
	HookPlatformPosix   HookPlatformType = "posix"
)

Variables

View Source
var (
	ErrScriptTypeUnknown error = errors.New(
		"unable to determine script type. Ensure 'Shell' parameter is set in configuration options",
	)
	ErrRunRequired           error = errors.New("run is always required")
	ErrUnsupportedScriptType error = errors.New("script type is not valid. Only '.sh' and '.ps1' are supported")
)
View Source
var (
	ErrInvalidEvent = errors.New("invalid event name for the current type")
)

Functions

This section is empty.

Types

type Event

type Event string

type EventDispatcher

type EventDispatcher[T any] struct {
	// contains filtered or unexported fields
}

func NewEventDispatcher

func NewEventDispatcher[T any](validEventNames ...Event) *EventDispatcher[T]

func (*EventDispatcher[T]) AddHandler

func (ed *EventDispatcher[T]) AddHandler(name Event, handler EventHandlerFn[T]) error

Adds an event handler for the specified event name

func (*EventDispatcher[T]) Invoke

func (ed *EventDispatcher[T]) Invoke(ctx context.Context, name Event, eventArgs T, action InvokeFn) error

Invokes an action and raises an event before and after the action

func (*EventDispatcher[T]) RaiseEvent

func (ed *EventDispatcher[T]) RaiseEvent(ctx context.Context, name Event, eventArgs T) error

Raises the specified event and calls any registered event handlers

func (*EventDispatcher[T]) RemoveHandler

func (ed *EventDispatcher[T]) RemoveHandler(name Event, handler EventHandlerFn[T]) error

Removes the event handler for the specified event name

type EventHandlerFn

type EventHandlerFn[T any] func(ctx context.Context, args T) error

type HookConfig

type HookConfig struct {

	// Internal name of the hook running for a given command
	Name string `yaml:",omitempty"`
	// The type of script hook (bash or powershell)
	Shell ShellType `yaml:"shell,omitempty"`
	// The inline script to execute or path to existing file
	Run string `yaml:"run,omitempty"`
	// When set to true will not halt command execution even when a script error occurs.
	ContinueOnError bool `yaml:"continueOnError,omitempty"`
	// When set to true will bind the stdin, stdout & stderr to the running console
	Interactive bool `yaml:"interactive,omitempty"`
	// When running on windows use this override config
	Windows *HookConfig `yaml:"windows,omitempty"`
	// When running on linux/macos use this override config
	Posix *HookConfig `yaml:"posix,omitempty"`
	// contains filtered or unexported fields
}

Azd hook configuration

type HookFilterPredicateFn

type HookFilterPredicateFn func(scriptName string, hookConfig *HookConfig) bool

type HookPlatformType

type HookPlatformType string

type HookType

type HookType string

The type of hooks. Supported values are 'pre' and 'post'

func InferHookType

func InferHookType(name string) (HookType, string)

type HooksManager

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

Hooks enable support to invoke integration scripts before & after commands Scripts can be invoked at the project or service level or

func NewHooksManager

func NewHooksManager(
	cwd string,
) *HooksManager

NewHooks creates a new instance of CommandHooks When `cwd` is empty defaults to current shell working directory

func (*HooksManager) GetAll

func (h *HooksManager) GetAll(hooks map[string][]*HookConfig) ([]*HookConfig, error)

Gets an array of all hook configurations Will return an error if any configuration errors are found

func (*HooksManager) GetByParams

func (h *HooksManager) GetByParams(
	hooks map[string][]*HookConfig,
	prefix HookType,
	commands ...string,
) ([]*HookConfig, error)

Gets an array of hook configurations matching the specified hook type and commands Will return an error if any configuration errors are found

type HooksRunner

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

Hooks enable support to invoke integration scripts before & after commands Scripts can be invoked at the project or service level or

func NewHooksRunner

func NewHooksRunner(
	hooksManager *HooksManager,
	commandRunner exec.CommandRunner,
	envManager environment.Manager,
	console input.Console,
	cwd string,
	hooks map[string][]*HookConfig,
	env *environment.Environment,
) *HooksRunner

NewHooks creates a new instance of CommandHooks When `cwd` is empty defaults to current shell working directory

func (*HooksRunner) GetScript

func (h *HooksRunner) GetScript(hookConfig *HookConfig) (tools.Script, error)

Gets the script to execute based on the hook configuration values For inline scripts this will also create a temporary script file to execute

func (*HooksRunner) Invoke

func (h *HooksRunner) Invoke(ctx context.Context, commands []string, actionFn InvokeFn) error

Invokes an action run runs any registered pre or post script hooks for the specified command.

func (*HooksRunner) RunHooks

func (h *HooksRunner) RunHooks(
	ctx context.Context,
	hookType HookType,
	options *tools.ExecOptions,
	commands ...string,
) error

Invokes any registered script hooks for the specified hook type and command.

type InvokeFn

type InvokeFn func() error

Generic action function that may return an error

type ScriptLocation

type ScriptLocation string

type ShellType

type ShellType string

Jump to

Keyboard shortcuts

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