utils

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2020 License: MPL-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UpModuleDir = ".upmodules"

	DEFAULT_CONFIG = `` /* 165-byte string literal not displayed */

	DEFAULT_UP_TASK_YML = `` /* 152-byte string literal not displayed */

	Yq_read_hint = `
path format:
1. 'a.b.c'
2. 'a.*.c'
3. 'a.**.c'
4. 'a.(child.subchild==co*).c'
5. 'a.array[0].blah'
6. 'a.array[*].blah'
`
)
View Source
var (
	P   = fmt.Print
	Pln = fmt.Println
	Pf  = fmt.Printf
	Sp  = fmt.Sprint
	Spf = fmt.Sprintf

	FgColorMap map[string]color.Attribute = map[string]color.Attribute{
		"black":     color.FgBlack,
		"red":       color.FgRed,
		"green":     color.FgGreen,
		"yello":     color.FgYellow,
		"blue":      color.FgBlue,
		"magenta":   color.FgMagenta,
		"cyan":      color.FgCyan,
		"white":     color.FgWhite,
		"hiblack":   color.FgHiBlack,
		"hiRed":     color.FgHiRed,
		"higreen":   color.FgHiGreen,
		"hiyello":   color.FgHiYellow,
		"hiblue":    color.FgHiBlue,
		"himagenta": color.FgHiMagenta,
		"hicyan":    color.FgHiCyan,
		"hiwhite":   color.FgHiWhite,
	}

	BgColorMap map[string]color.Attribute = map[string]color.Attribute{
		"black":     color.BgBlack,
		"red":       color.BgRed,
		"green":     color.BgGreen,
		"yello":     color.BgYellow,
		"blue":      color.BgBlue,
		"magenta":   color.BgMagenta,
		"cyan":      color.BgCyan,
		"white":     color.BgWhite,
		"hiblack":   color.BgHiBlack,
		"hiRed":     color.BgHiRed,
		"higreen":   color.BgHiGreen,
		"hiyello":   color.BgHiYellow,
		"hiblue":    color.BgHiBlue,
		"himagenta": color.BgHiMagenta,
		"hicyan":    color.BgHiCyan,
		"hiwhite":   color.BgHiWhite,
	}

	ColorNames = func() []string {
		keys := make([]string, 0, len(FgColorMap))
		for k, _ := range FgColorMap {
			keys = append(keys, k)
		}
		return keys
	}()
)

Functions

func CharIsNum

func CharIsNum(s string) int

func Contains

func Contains(a []string, x string) bool

Contains tells whether a contains x.

func DebugYmlContent

func DebugYmlContent(dir, filename string)

func Dvvvv

func Dvvvv(a ...interface{})

func Dvvvvv

func Dvvvvv(a ...interface{})

func Fail

func Fail(mark string, hint string)

func GetDefaultModuleDir

func GetDefaultModuleDir() string

func GetGitRepoName

func GetGitRepoName(url string) string

func GetHeadRev

func GetHeadRev(repodir string) string

func GetRandomName

func GetRandomName(retry int) string

func GraceExit

func GraceExit(mark string, hint string)

func IndexOf

func IndexOf(a []string, x string) int

func InvalidAndExit

func InvalidAndExit(mark string, hint string)

func LogDesc

func LogDesc(descType string, contextIdx1 int, taskLayerCnt int, name string, desc string)

func LogError

func LogError(mark string, err interface{})

func LogErrorAndContinue

func LogErrorAndContinue(mark string, err interface{}, hint string)

func LogErrorAndExit

func LogErrorAndExit(mark string, err interface{}, hint string)

func LogErrorMsg

func LogErrorMsg(mark string, reason string)

func LogOk

func LogOk(mark string)

func LogWarn

func LogWarn(mark string, reason string)

func PStackTrace

func PStackTrace()

func Pdebug

func Pdebug(a ...interface{})

func PdebugN

func PdebugN(mark int, a ...interface{})

func PdebugStack

func PdebugStack(a ...interface{})

func Pdebugvvvvvvv

func Pdebugvvvvvvv(a ...interface{})

func Pdryrun

func Pdryrun(a ...interface{})

func PfHiColor

func PfHiColor(format string, a ...interface{})

func Pfdryrun

func Pfdryrun(format string, a ...interface{})

func Pferror

func Pferror(format string, a ...interface{})

func Pfv

func Pfv(format string, a ...interface{})

func Pfvv

func Pfvv(format string, a ...interface{})

func Pfvvv

func Pfvvv(format string, a ...interface{})

func Pfvvvv

func Pfvvvv(format string, a ...interface{})

func Pfvvvvv

func Pfvvvvv(format string, a ...interface{})

func Ppfmsg

func Ppfmsg(mark string, a ...interface{})

func Ppmsg

func Ppmsg(a ...interface{})

func PpmsgHintHighPermitted

func PpmsgHintHighPermitted(vlevel string, hint string, a ...interface{})

func Ppmsgvvv

func Ppmsgvvv(a ...interface{})

func Ppmsgvvvhint

func Ppmsgvvvhint(hint string, a ...interface{})

func PpmsgvvvhintHigh

func PpmsgvvvhintHigh(hint string, a ...interface{})

func Ppmsgvvvv

func Ppmsgvvvv(a ...interface{})

func PpmsgvvvvHigh

func PpmsgvvvvHigh(a ...interface{})

func Ppmsgvvvvhint

func Ppmsgvvvvhint(hint string, a ...interface{})

func PpmsgvvvvhintHigh

func PpmsgvvvvhintHigh(hint string, a ...interface{})

func Ppmsgvvvvv

func Ppmsgvvvvv(hint string, a ...interface{})

func Ppmsgvvvvvhint

func Ppmsgvvvvvhint(hint string, a ...interface{})

func PpmsgvvvvvhintHigh

func PpmsgvvvvvhintHigh(hint string, a ...interface{})

func Ppromptvvvvv

func Ppromptvvvvv(valueName, hint string)

func PrintContentWithLineNuber

func PrintContentWithLineNuber(content string) string

func Ptmpdebug

func Ptmpdebug(mark string, a ...interface{})

func Ptrace

func Ptrace(mark, info string)

func Pvv

func Pvv(a ...interface{})

func Pvvv

func Pvvv(a ...interface{})

func Pvvvv

func Pvvvv(a ...interface{})

func Pvvvvv

func Pvvvvv(a ...interface{})

func RandomColorName

func RandomColorName() string

func RemoveCr

func RemoveCr(str string) string

func RemoveIndex

func RemoveIndex(s []string, index int) []string

func RunSimpleCmd

func RunSimpleCmd(dir string, command string) error

func Sleep

func Sleep(mscnt int)

func Spfv

func Spfv(format string, a ...interface{}) string

func Sppmsg

func Sppmsg(a ...interface{}) string

func StrIn

func StrIn(s string, aStrList ...string) int

func SubStepStatus

func SubStepStatus(mark string, statusCode int)

func Trace

func Trace()

func YamlLoader

func YamlLoader(id, path, filename string) *viper.Viper

Types

type CmdOpts

type CmdOpts struct {
	Command string
	Dir     string
	Env     []string
	Stdin   io.Reader
	Stdout  io.Writer
	Stderr  io.Writer
}

type ExecResult

type ExecResult struct {
	Code   int
	Output string
	ErrMsg string
}

func RunCmd

func RunCmd(cmd string, dir string, envs *map[string]string) ExecResult

type Module

type Module struct {
	Repo       string
	Tag        string
	Version    string
	Alias      string
	Dir        string
	Subdir     string
	Iid        string
	PullPolicy string
}

func (*Module) Normalize

func (m *Module) Normalize()

func (*Module) PullRepo

func (m *Module) PullRepo(revMap *ModuleLockMap, uselock bool)

func (*Module) ShowDetails

func (m *Module) ShowDetails()

type ModuleLockMap

type ModuleLockMap map[string]string

func LoadModuleLockRevs

func LoadModuleLockRevs() *ModuleLockMap

type Modules

type Modules []Module

func (Modules) LocateModule

func (ms Modules) LocateModule(modname string) *Module

func (*Modules) PullCascadedModules

func (ms *Modules) PullCascadedModules(clonedMainModList *[]string, clonedSubModList *[]string)

func (*Modules) PullMainModules

func (ms *Modules) PullMainModules() (clonedList []string)

func (*Modules) PullModules

func (ms *Modules) PullModules()

func (*Modules) ReportModules

func (ms *Modules) ReportModules()

type SecureSetting

type SecureSetting struct {
	Type   string
	Key    string
	KeyRef string
}

type UpConfig

type UpConfig struct {
	Version string
	RefDir  string
	//choice of cwd | refdir
	//default to be cwd
	WorkDir    string
	AbsWorkDir string
	TaskFile   string
	Verbose    string
	ModuleName string
	//default: /bin/sh, or the path given: /usr/local/bin/bash, or simply: GOSH
	ShellType           string
	MaxCallLayers       string
	MaxModuelCallLayers string
	//TODO: get rid of pointer as it will result in nil pointer loading issue
	Secure     *SecureSetting
	Modules    Modules
	ModuleLock bool
}
var (
	MainConfig *UpConfig
)

func NewUpConfig

func NewUpConfig(configdir, configymlfile string) *UpConfig

func (*UpConfig) GetWorkdirOld

func (cfg *UpConfig) GetWorkdirOld() (wkdir string)

func (*UpConfig) InitConfig

func (cfg *UpConfig) InitConfig() *UpConfig

func (*UpConfig) SetAbsWorkdir

func (cfg *UpConfig) SetAbsWorkdir()

return abs path this must be called before tasker changing dir

func (*UpConfig) SetModulename

func (cfg *UpConfig) SetModulename(modulename string)

func (*UpConfig) SetRefdir

func (cfg *UpConfig) SetRefdir(refdir string)

func (*UpConfig) SetTaskfile

func (cfg *UpConfig) SetTaskfile(taskfile string)

func (*UpConfig) SetVerbose

func (cfg *UpConfig) SetVerbose(cmdV string)

func (*UpConfig) SetWorkdir

func (cfg *UpConfig) SetWorkdir(workdir string)

func (*UpConfig) ShowCoreConfig

func (cfg *UpConfig) ShowCoreConfig(mark string)

type UpConfigLoader

type UpConfigLoader struct {
	Dir     string
	YmlFile string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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