core

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2023 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Source: https://github.com/goware/prefixer

Singleton module

TODO: Refactor

Index

Constants

View Source
const (
	Start = 0
	End   = 1
	Step  = 2
)
View Source
const ANSI = "" /* 129-byte string literal not displayed */

Variables

View Source
var CONFIG_MAN []byte
View Source
var CONFIG_MD []byte

Functions

func AnyToString added in v0.10.0

func AnyToString(s any) string

func CheckIfError

func CheckIfError(err error)

func CreateManPage

func CreateManPage(desc string, version string, date string, rootCmd *cobra.Command, cmds ...*cobra.Command) error

func DebugPrint

func DebugPrint(data any)

TODO: Don't include this in build

func EvaluateInventory added in v0.12.0

func EvaluateInventory(
	shell string,
	context string,
	input string,
	serverEnvs []string,
	userEnvs []string,
) ([]string, error)

Separate hosts with newline and space/tab

func EvaluateRange added in v0.12.0

func EvaluateRange(input string) ([]string, error)

func Exit added in v0.10.0

func Exit(err error)

func ExpandPath added in v0.15.1

func ExpandPath(p string) (string, error)

func FindFileInParentDirs

func FindFileInParentDirs(path string, files []string) (string, error)

func FormatShell added in v0.10.0

func FormatShell(shell string) string

FormatShell returns the shell program and associated command flag

func GenManPages

func GenManPages(dir string) error

func GetAbsolutePath

func GetAbsolutePath(configDir string, path string, name string) (string, error)

Get the absolute path Need to support following path types:

lala/land
./lala/land
../lala/land
/lala/land
$HOME/lala/land
~/lala/land
~root/lala/land

func GetFirstExistingFile added in v0.14.0

func GetFirstExistingFile(files ...string) string

func Intersection

func Intersection(a []string, b []string) []string

func IsDigit added in v0.12.0

func IsDigit(s string) bool

func ParseHostName added in v0.11.0

func ParseHostName(hostname string, defaultUser string, defaultPort uint16) (string, string, uint16, error)

Parse host, for instance : user@hostname:22

func ParseSSHConfig added in v0.12.0

func ParseSSHConfig(path string) (map[string](Endpoint), error)

Parse reads and parses the file in the given path.

func Ptr

func Ptr[T any](t T) *T

Used when creating pointers to literal. Useful when you want set/unset attributes.

func SplitString added in v0.13.0

func SplitString(s, sep string) []string

func StringInSlice

func StringInSlice(a string, list []string) bool

func StringToBool added in v0.11.0

func StringToBool(s string) bool

func StringsToErrors

func StringsToErrors(str []string) []error

func Strip

func Strip(str string) string

Types

type AlreadySakeDirectory

type AlreadySakeDirectory struct {
	Dir string
}

func (*AlreadySakeDirectory) Error

func (c *AlreadySakeDirectory) Error() string

type BatchMultipleDef added in v0.13.0

type BatchMultipleDef struct {
	Name string
}

func (*BatchMultipleDef) Error added in v0.13.0

func (c *BatchMultipleDef) Error() string

type ConfigEnvFailed

type ConfigEnvFailed struct {
	Name string
	Err  string
}

func (*ConfigEnvFailed) Error

func (c *ConfigEnvFailed) Error() string

type ConfigErr

type ConfigErr struct {
	Msg string
}

func (*ConfigErr) Error

func (f *ConfigErr) Error() string

type ConfigNotFound

type ConfigNotFound struct {
	Names []string
}

func (*ConfigNotFound) Error

func (f *ConfigNotFound) Error() string

type Endpoint added in v0.11.0

type Endpoint struct {
	Name          string
	HostName      string
	Port          string
	User          string
	ProxyJump     string
	ForwardAgent  bool
	RequestTTY    bool
	RemoteCommand string
	SendEnv       []string
	SetEnv        []string
	IdentityFiles []string
}

func ParseReader added in v0.11.0

func ParseReader(r io.Reader, cfg string) ([]*Endpoint, error)

ParseReader reads and parses the given reader.

type ExecError added in v0.10.2

type ExecError struct {
	Err      error
	ExitCode int
}

If there's a misconfiguration somewhere, not associated with server errors

func (*ExecError) Error added in v0.10.2

func (e *ExecError) Error() string

type FileError

type FileError struct {
	Err string
}

func (*FileError) Error

func (f *FileError) Error() string

type HostPart added in v0.12.0

type HostPart struct {
	TokenType string
	Literal   any
}

type HostRange added in v0.12.0

type HostRange struct {
	Start string
	End   string
	Step  string
}

type HostString added in v0.12.0

type HostString struct {
	Value string
}

type InvalidPercentInput added in v0.12.0

type InvalidPercentInput struct {
	Name string
}

func (*InvalidPercentInput) Error added in v0.12.0

func (c *InvalidPercentInput) Error() string

type InvalidPercentInput2 added in v0.14.0

type InvalidPercentInput2 struct {
	Name string
}

func (*InvalidPercentInput2) Error added in v0.14.0

func (c *InvalidPercentInput2) Error() string

type InventoryEvalFailed added in v0.12.0

type InventoryEvalFailed struct {
	Err string
}

func (*InventoryEvalFailed) Error added in v0.12.0

func (c *InventoryEvalFailed) Error() string

type LimitMultipleDef added in v0.13.0

type LimitMultipleDef struct {
	Name string
}

func (*LimitMultipleDef) Error added in v0.13.0

func (c *LimitMultipleDef) Error() string

type ListFlags

type ListFlags struct {
	Output string
	Theme  string
}

type Loader

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

func GetSpinner

func GetSpinner() *Loader

func (*Loader) Disable

func (s *Loader) Disable()

func (*Loader) Enable

func (s *Loader) Enable()

func (*Loader) Message

func (s *Loader) Message(msg string)

func (*Loader) Start

func (s *Loader) Start(msg string, delay time.Duration)

func (*Loader) Status

func (s *Loader) Status() yacspin.SpinnerStatus

func (*Loader) Stop

func (s *Loader) Stop()

type MultipleFailSet added in v0.13.0

type MultipleFailSet struct {
	Name string
}

func (*MultipleFailSet) Error added in v0.13.0

func (c *MultipleFailSet) Error() string

type NoEditorEnv

type NoEditorEnv struct{}

func (*NoEditorEnv) Error

func (c *NoEditorEnv) Error() string

type NoRemoteServerToAttach

type NoRemoteServerToAttach struct{}

func (*NoRemoteServerToAttach) Error

func (c *NoRemoteServerToAttach) Error() string

type NoTaskRefDefined added in v0.10.0

type NoTaskRefDefined struct {
	Name string
}

func (*NoTaskRefDefined) Error added in v0.10.0

func (c *NoTaskRefDefined) Error() string

type OutputFormatNotFound added in v0.13.0

type OutputFormatNotFound struct {
	Name string
}

func (*OutputFormatNotFound) Error added in v0.13.0

func (c *OutputFormatNotFound) Error() string

type PasswordEvalFailed

type PasswordEvalFailed struct {
	Err string
}

func (*PasswordEvalFailed) Error

func (c *PasswordEvalFailed) Error() string

type Prefixer

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

Prefixer implements io.Reader and io.WriterTo. It reads data from the underlying reader and prepends every line with a given string.

func NewPrefixer

func NewPrefixer(r io.Reader, prefix string) *Prefixer

New creates a new instance of Prefixer.

func (*Prefixer) Read

func (r *Prefixer) Read(p []byte) (n int, err error)

Read implements io.Reader. It reads data into p from the underlying reader and prepends every line with a prefix. It does not block if no data is available yet. It returns the number of bytes read into p.

func (*Prefixer) WriteTo

func (r *Prefixer) WriteTo(w io.Writer) (n int64, err error)

type RangeState added in v0.12.0

type RangeState uint64

func (RangeState) String added in v0.12.0

func (s RangeState) String() string

type RegisterInvalidName added in v0.13.0

type RegisterInvalidName struct {
	Value string
}

func (*RegisterInvalidName) Error added in v0.13.0

func (c *RegisterInvalidName) Error() string

type RunFlags

type RunFlags struct {
	// Flags
	Edit      bool
	DryRun    bool
	Describe  bool
	ListHosts bool
	Silent    bool
	Confirm   bool
	Step      bool
	Verbose   bool

	// Reports
	Report []string

	// Target
	All     bool
	Regex   string
	Servers []string
	Tags    []string
	Cwd     bool
	Invert  bool
	Limit   uint32
	LimitP  uint8
	Target  string
	Order   string

	// Config
	KnownHostsFile string

	// Task
	Theme  string
	TTY    bool
	Attach bool
	Local  bool

	// Server
	IdentityFile string
	User         string
	Password     string

	// Spec
	Spec              string
	AnyErrorsFatal    bool
	MaxFailPercentage uint8
	IgnoreErrors      bool
	IgnoreUnreachable bool
	OmitEmptyRows     bool
	OmitEmptyColumns  bool
	Forks             uint32
	Batch             uint32
	BatchP            uint8
	Output            string
	Print             string
	Strategy          string
}

type ServerBastionMultipleDef added in v0.15.0

type ServerBastionMultipleDef struct {
	Name string
}

func (*ServerBastionMultipleDef) Error added in v0.15.0

func (c *ServerBastionMultipleDef) Error() string

type ServerFlags

type ServerFlags struct {
	Tags       []string
	Headers    []string
	Edit       bool
	Regex      string
	Invert     bool
	AllHeaders bool
}

type ServerMultipleDef added in v0.12.0

type ServerMultipleDef struct {
	Name string
}

func (*ServerMultipleDef) Error added in v0.12.0

func (c *ServerMultipleDef) Error() string

type ServerNotFound

type ServerNotFound struct {
	Name []string
}

func (*ServerNotFound) Error

func (c *ServerNotFound) Error() string

type SetRunFlags

type SetRunFlags struct {
	Silent            bool
	Describe          bool
	ListHosts         bool
	Attach            bool
	All               bool
	Invert            bool
	OmitEmptyRows     bool
	OmitEmptyColumns  bool
	Local             bool
	TTY               bool
	AnyErrorsFatal    bool
	IgnoreErrors      bool
	IgnoreUnreachable bool
	Order             bool
	Report            bool
	Forks             bool
	Batch             bool
	BatchP            bool
	Servers           bool
	Tags              bool
	Regex             bool
	Limit             bool
	LimitP            bool
	Verbose           bool
	Confirm           bool
	Step              bool
	MaxFailPercentage bool
}

type SpecFlags added in v0.12.0

type SpecFlags struct {
	Headers []string
	Edit    bool
}

type SpecNotFound

type SpecNotFound struct {
	Name string
}

func (*SpecNotFound) Error

func (c *SpecNotFound) Error() string

type SpecsNotFound added in v0.12.0

type SpecsNotFound struct {
	Specs []string
}

func (*SpecsNotFound) Error added in v0.12.0

func (c *SpecsNotFound) Error() string

type TagFlags

type TagFlags struct {
	Headers []string
}

type TagNotFound

type TagNotFound struct {
	Tags []string
}

func (*TagNotFound) Error

func (c *TagNotFound) Error() string

type TargetFlags added in v0.12.0

type TargetFlags struct {
	Headers []string
	Edit    bool
}

type TargetNotFound

type TargetNotFound struct {
	Name string
}

func (*TargetNotFound) Error

func (c *TargetNotFound) Error() string

type TargetsNotFound added in v0.12.0

type TargetsNotFound struct {
	Targets []string
}

func (*TargetsNotFound) Error added in v0.12.0

func (c *TargetsNotFound) Error() string

type TaskFlags

type TaskFlags struct {
	Headers    []string
	Edit       bool
	AllHeaders bool
}

type TaskMultipleDef

type TaskMultipleDef struct {
	Name string
}

func (*TaskMultipleDef) Error

func (c *TaskMultipleDef) Error() string

type TaskNotFound

type TaskNotFound struct {
	IDs []string
}

func (*TaskNotFound) Error

func (c *TaskNotFound) Error() string

type TaskRefMultipleDef added in v0.10.0

type TaskRefMultipleDef struct {
	Name string
}

func (*TaskRefMultipleDef) Error added in v0.10.0

func (c *TaskRefMultipleDef) Error() string

type TemplateParseError added in v0.10.0

type TemplateParseError struct {
	Msg string
}

If there's a misconfiguration with golang templates (prefix/header for instance in text.go)

func (*TemplateParseError) Error added in v0.10.0

func (f *TemplateParseError) Error() string

type ThemeNotFound

type ThemeNotFound struct {
	Name string
}

func (*ThemeNotFound) Error

func (c *ThemeNotFound) Error() string

type ZeroNotAllowed added in v0.14.0

type ZeroNotAllowed struct {
	Name string
}

func (*ZeroNotAllowed) Error added in v0.14.0

func (c *ZeroNotAllowed) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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