configuration

package
v0.0.0-...-6dcb528 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapVerbosity

func MapVerbosity(verbosity string) int

func UnMapVerbosity

func UnMapVerbosity(verbosity int) string

Types

type Action

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

func (*Action) Conditions

func (a *Action) Conditions() []*Condition

func (*Action) IsFailureAllowed

func (a *Action) IsFailureAllowed() bool

func (*Action) Label

func (a *Action) Label() string

func (*Action) Options

func (a *Action) Options() *Options

func (*Action) Run

func (a *Action) Run() string

func (*Action) WorkingDir

func (a *Action) WorkingDir() string

type ActionSettings

type ActionSettings struct {
	AllowFailure bool
	WorkingDir   string
	Label        string
}

func NewDefaultActionSettings

func NewDefaultActionSettings() *ActionSettings

type AppSettings

type AppSettings struct {
	AllowFailure     bool
	AnsiColors       bool
	Custom           map[string]string
	FailOnFirstError bool
	GitDirectory     string
	Includes         []string
	IncludeLevel     int
	RunPath          string
	RunAsync         bool
	Verbosity        string
}

func NewDefaultAppSettings

func NewDefaultAppSettings() *AppSettings

type Condition

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

func NewCondition

func NewCondition(cmd string, o *Options, c []*Condition) *Condition

func (*Condition) Conditions

func (c *Condition) Conditions() []*Condition

func (*Condition) Options

func (c *Condition) Options() *Options

func (*Condition) Run

func (c *Condition) Run() string

type ConfigFactory

type ConfigFactory interface {
	// CreateConfig creates a CaptainHook configuration
	CreateConfig(path string, cliSettings *NullableAppSettings) (*Configuration, error)
}

type Configuration

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

func NewConfiguration

func NewConfiguration(path string, fileExists bool) *Configuration

func (*Configuration) AnsiColors

func (c *Configuration) AnsiColors() bool

func (*Configuration) CustomSettings

func (c *Configuration) CustomSettings() map[string]string

func (*Configuration) FailOnFirstError

func (c *Configuration) FailOnFirstError() bool

func (*Configuration) GitDirectory

func (c *Configuration) GitDirectory() string

func (*Configuration) HookConfig

func (c *Configuration) HookConfig(hook string) *Hook

func (*Configuration) Includes

func (c *Configuration) Includes() []string

func (*Configuration) IsFailureAllowed

func (c *Configuration) IsFailureAllowed() bool

func (*Configuration) IsHookEnabled

func (c *Configuration) IsHookEnabled(hook string) bool

func (*Configuration) IsLoadedFromFile

func (c *Configuration) IsLoadedFromFile() bool

func (*Configuration) MaxIncludeLevel

func (c *Configuration) MaxIncludeLevel() int

func (*Configuration) Path

func (c *Configuration) Path() string

func (*Configuration) RunAsync

func (c *Configuration) RunAsync() bool

func (*Configuration) RunPath

func (c *Configuration) RunPath() string

func (*Configuration) Verbosity

func (c *Configuration) Verbosity() int

type Hook

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

func NewHook

func NewHook(name string, isEnabled bool) *Hook

func (*Hook) AddAction

func (h *Hook) AddAction(action *Action)

func (*Hook) Disable

func (h *Hook) Disable()

func (*Hook) Enable

func (h *Hook) Enable()

func (*Hook) GetActions

func (h *Hook) GetActions() []*Action

func (*Hook) IsEnabled

func (h *Hook) IsEnabled() bool

func (*Hook) Name

func (h *Hook) Name() string

type JsonAction

type JsonAction struct {
	Run        string                  `json:"run,omitempty"`
	Conditions []*JsonCondition        `json:"conditions,omitempty"`
	Options    *map[string]interface{} `json:"options,omitempty"`
	Settings   *JsonActionSettings     `json:"config,omitempty"`
}

type JsonActionSettings

type JsonActionSettings struct {
	Label        *string `json:"label,omitempty"`
	AllowFailure *bool   `json:"allow-failure,omitempty"`
	RunAsync     *bool   `json:"run-async,omitempty"`
	WorkingDir   *string `json:"working-dir,omitempty"`
}

type JsonAppSettings

type JsonAppSettings struct {
	AllowFailure     *bool              `json:"allow-failure,omitempty"`
	AnsiColors       *bool              `json:"ansi-colors,omitempty"`
	Custom           *map[string]string `json:"custom,omitempty"`
	FailOnFirstError *bool              `json:"fail-on-first-error,omitempty"`
	GitDirectory     *string            `json:"git-directory,omitempty"`
	Includes         *[]string          `json:"includes,omitempty"`
	IncludeLevel     *int               `json:"includes-level,omitempty"`
	RunPath          *string            `json:"run-path,omitempty"`
	RunAsync         *bool              `json:"run-async,omitempty"`
	Verbosity        *string            `json:"verbosity,omitempty"`
}

type JsonCondition

type JsonCondition struct {
	Run        string                  `json:"run,omitempty"`
	Options    *map[string]interface{} `json:"options,omitempty"`
	Conditions []*JsonCondition        `json:"conditions,omitempty"`
}

type JsonConfiguration

type JsonConfiguration struct {
	Settings *JsonAppSettings      `json:"config,omitempty"`
	Hooks    *map[string]*JsonHook `json:"hooks,omitempty"`
}

type JsonFactory

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

func NewJsonFactory

func NewJsonFactory() *JsonFactory

func (*JsonFactory) CreateConfig

func (f *JsonFactory) CreateConfig(path string, cliSettings *NullableAppSettings) (*Configuration, error)

CreateConfig creates a default configuration in case the file exists it is loaded

type JsonHook

type JsonHook struct {
	Actions []*JsonAction `json:"actions"`
}

type NullableAppSettings

type NullableAppSettings struct {
	AllowFailure     *bool
	AnsiColors       *bool
	Custom           *map[string]string
	FailOnFirstError *bool
	GitDirectory     *string
	Includes         *[]string
	IncludeLevel     *int
	RunPath          *string
	RunAsync         *bool
	Verbosity        *string
}

NullableAppSettings represents the command argument and options that can be provided or can be skipped

func NewNullableAppSettings

func NewNullableAppSettings() *NullableAppSettings

type Options

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

func NewOptions

func NewOptions(someMap map[string]interface{}) *Options

func (Options) All

func (o Options) All() map[string]interface{}

func (Options) AsBool

func (o Options) AsBool(option string, defaultValue bool) bool

AsBool tries to convert an option value to a bool and return it

func (Options) AsInt

func (o Options) AsInt(option string, defaultValue int) int

AsInt tries to convert an option value to an int and return it

func (Options) AsSliceOfStrings

func (o Options) AsSliceOfStrings(option string) []string

AsSliceOfStrings tries to convert an option value to a slice of strings and return it

func (Options) AsString

func (o Options) AsString(option string, defaultValue string) string

AsString tries to convert an option value to a string and return it

type YamlAction

type YamlAction struct {
	Run        string                  `yaml:"run"`
	Options    *map[string]interface{} `yaml:"options,omitempty"`
	Settings   *YamlActionSettings     `yaml:"config,omitempty"`
	Conditions []YamlCondition         `yaml:"conditions,omitempty"`
}

type YamlActionSettings

type YamlActionSettings struct {
	Label        *string `yaml:"label,omitempty"`
	AllowFailure *bool   `yaml:"failure-allowed,omitempty"`
	RunAsync     *bool   `yaml:"run-async,omitempty"`
	WorkingDir   *string `yaml:"working-directory,omitempty"`
}

type YamlAppSettings

type YamlAppSettings struct {
	AllowFailure     *bool              `yaml:"allow-failure,omitempty"`
	AnsiColors       *bool              `yaml:"ansi-colors,omitempty"`
	Custom           *map[string]string `yaml:"custom,omitempty"`
	FailOnFirstError *bool              `yaml:"fail-on-first-error,omitempty"`
	GitDirectory     *string            `yaml:"git-directory,omitempty"`
	Includes         *[]string          `yaml:"includes,omitempty"`
	IncludeLevel     *int               `yaml:"includes-level,omitempty"`
	RunAsync         *bool              `yaml:"run-async,omitempty"`
	RunPath          *string            `yaml:"run-path,omitempty"`
	Verbosity        *string            `yaml:"verbosity,omitempty"`
}

type YamlCondition

type YamlCondition struct {
	Run        string                  `yaml:"run"`
	Options    *map[string]interface{} `yaml:"options,omitempty"`
	Conditions []YamlCondition         `yaml:"conditions,omitempty"`
}

type YamlConfiguration

type YamlConfiguration struct {
	Settings *YamlAppSettings     `yaml:"config,omitempty"`
	Hooks    *map[string]YamlHook `yaml:"hooks"`
}

type YamlFactory

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

func NewYamlFactory

func NewYamlFactory() *YamlFactory

func (*YamlFactory) CreateConfig

func (f *YamlFactory) CreateConfig(path string, cliSettings *NullableAppSettings) (*Configuration, error)

CreateConfig creates a default configuration in case the file exists it is loaded

type YamlHook

type YamlHook struct {
	Actions []YamlAction `yaml:"actions"`
}

Jump to

Keyboard shortcuts

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