utils

package
v1.3.0-rc.0...-d217119 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NotExist = errors.New("not exist")

	GlobalErdaDir    = ".erda.d"
	GlobalConfigFile = "config"

	ProjectDiceDir     = ".dice"
	ProjectPipelineDir = ".dice/pipelines"

	ProjectErdaDir = ".erda"

	ProjectErdaConfigDir = ".erda.d"
)
View Source
var InvalidErdaRepo = errors.New("Invalid Erda git repository!")

Functions

func CreateGlobalErdaDir

func CreateGlobalErdaDir() (string, error)

func CreateProjectDiceDir

func CreateProjectDiceDir() (string, error)

func CreateProjectErdaDir

func CreateProjectErdaDir() (string, error)

func DoTaskListWithTimeout

func DoTaskListWithTimeout(timeout time.Duration, rs []TaskRunner) error

func DoTaskWithTimeout

func DoTaskWithTimeout(c TaskRunnerE, timeout time.Duration) error

func FindGlobalConfig

func FindGlobalConfig() (string, error)

func FindGlobalErdaDir

func FindGlobalErdaDir() (string, error)

func FindProjectConfig

func FindProjectConfig() (string, error)

func FindProjectDiceDir

func FindProjectDiceDir() (string, error)

func FindProjectErdaDir

func FindProjectErdaDir() (string, error)

func Format

func Format(data []byte) ([]byte, error)

Format JSON string with default options.

func FormatErrMsg

func FormatErrMsg(name string, str string, withHelp bool) string

func FormatMemOutput

func FormatMemOutput(mem uint64) string

func GetOriginRepo

func GetOriginRepo() string

func GetRepo

func GetRepo(remote string) string

func GetWorkspaceBranch

func GetWorkspaceBranch(dir string) (string, error)

func GetWorkspacePipelines

func GetWorkspacePipelines(dir string) ([]string, error)

func InputAndChoose

func InputAndChoose(prompt, yes, no string) string

func InputNormal

func InputNormal(prompt string) string

func InputPWD

func InputPWD(prompt string) string

func IsDir

func IsDir(path string) bool

func IsWorkspaceDirty

func IsWorkspaceDirty(dir string) (bool, error)

func ListDir

func ListDir(dir string) ([]string, error)

func Marshal

func Marshal(v interface{}) ([]byte, error)

Marshal JSON data with default options.

func PagingAll

func PagingAll(p pagingList, pageSize int) error

func PagingView

func PagingView(p pagingList, choose string, pageSize int, interactive bool) error

func PipeCmds

func PipeCmds(cur, next *exec.Cmd) (string, error)

func ReadYml

func ReadYml(path string) ([]byte, error)

func ShortID

func ShortID(id string) string

shortID for containerID

func Time

func Time(t interface{}) string

func ToTimeSpanString

func ToTimeSpanString(seconds int) string

Types

type ApplicationURLInfo

type ApplicationURLInfo struct {
	ProjectURLInfo
	ApplicationId uint64
}

type Err

type Err struct {
	Code string
	Msg  string
	Ctx  interface{}
}

type Formatter

type Formatter struct {
	// JSON key color. Default is `color.New(color.FgBlue, color.Bold)`.
	KeyColor *color.Color

	// JSON string value color. Default is `color.New(color.FgGreen, color.Bold)`.
	StringColor *color.Color

	// JSON boolean value color. Default is `color.New(color.FgYellow, color.Bold)`.
	BoolColor *color.Color

	// JSON number value color. Default is `color.New(color.FgCyan, color.Bold)`.
	NumberColor *color.Color

	// JSON null value color. Default is `color.New(color.FgBlack, color.Bold)`.
	NullColor *color.Color

	// Max length of JSON string value. When the value is 1 and over, string is truncated to length of the value.
	// Default is 0 (not truncated).
	StringMaxLength int

	// Boolean to disable color. Default is false.
	DisabledColor bool

	// Indent space number. Default is 2.
	Indent int

	// Newline string. To print without new lines set it to empty string. Default is \n.
	Newline string
}

Formatter is a struct to format JSON data. `color` is github.com/fatih/color: https://github.com/fatih/color

func NewFormatter

func NewFormatter() *Formatter

NewFormatter returns a new formatter with following default values.

func (*Formatter) Format

func (f *Formatter) Format(data []byte) ([]byte, error)

Format formats JSON string.

func (*Formatter) Marshal

func (f *Formatter) Marshal(v interface{}) ([]byte, error)

Marshal marshals and formats JSON data.

type GitterURLInfo

type GitterURLInfo struct {
	OrganizationURLInfo
	Project     string
	Application string
}

func GetWorkspaceInfo

func GetWorkspaceInfo(dir, remoteName string) (GitterURLInfo, error)

type OrganizationURLInfo

type OrganizationURLInfo struct {
	Scheme string
	Host   string
	Org    string
}

type Page

type Page struct {
	Total int
	List  json.RawMessage
}

type ProjectURLInfo

type ProjectURLInfo struct {
	OrganizationURLInfo
	ProjectId uint64
}

type Resp

type Resp struct {
	Success bool
	Data    json.RawMessage
	Err     *Err
}

func DoResp

func DoResp(r *httpclient.Request) (Resp, error)

func (*Resp) ParseData

func (resp *Resp) ParseData(o interface{}) error

func (*Resp) ParsePagingListData

func (resp *Resp) ParsePagingListData(o interface{}) error

type TaskRunner

type TaskRunner func() bool

type TaskRunnerE

type TaskRunnerE func() (bool, error)

type URLType

type URLType string
var ApplicatinURL URLType = "ErdaApplicationURL"
var GittarURL URLType = "ErdaGittarURL"
var OrgURL URLType = "ErdaOrganizationURL"
var ProjectURL URLType = "ErdaProjectURL"

func ClassifyURL

func ClassifyURL(path string) (URLType, []string, error)

Jump to

Keyboard shortcuts

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