common

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Event key in context
	EventKey = "rkEvent"
	// The folder where build result will be moved to
	BuildTarget = "target"
)

Variables

View Source
var (

	// BuildConfig match yaml config of build.yaml
	BuildConfig = &BootConfigForBuild{}
	// TargetPkgName the compiled target name
	TargetPkgName = getPkgName()
	// TargetGitInfo git information while building
	TargetGitInfo = getGitInfo()
)

Functions

func CommandAfter added in v1.2.2

func CommandAfter(ctx *cli.Context) error

func CommandBefore added in v1.2.2

func CommandBefore(ctx *cli.Context) error

func CreateEvent added in v1.0.1

func CreateEvent(op string) rkquery.Event

CreateEvent Create an event with operation name

func Error added in v1.0.1

func Error(err error) error

Error Print error with red color of text

func FileExists added in v1.2.4

func FileExists(filePath string) bool

func Finish

func Finish(event rkquery.Event, err error)

Finish current event

func GetEvent

func GetEvent(ctx *cli.Context) rkquery.Event

GetEvent Retrieve event in context

func GetGoPathBin added in v1.1.1

func GetGoPathBin() string

GetGoPathBin Get $GOPATH/bin path on local machine

func NewActionChain added in v1.0.1

func NewActionChain() *actionChain

NewActionChain Create a new actionChain

func TryReadFile added in v1.2.1

func TryReadFile(filePath string) []byte

func UnmarshalBootConfig added in v1.0.1

func UnmarshalBootConfig(configFilePath string, config interface{}) error

UnmarshalBootConfig Read build.yaml and unmarshal it into config

Types

type BootConfigForBuild added in v1.2.2

type BootConfigForBuild struct {
	Build struct {
		Type     string   `yaml:"type"`
		Main     string   `yaml:"main"`
		GOOS     string   `yaml:"GOOS"`
		GOARCH   string   `yaml:"GOARCH"`
		Args     []string `yaml:"args"`
		Copy     []string `yaml:"copy"`
		Commands struct {
			Before []string `yaml:"before"`
			After  []string `yaml:"after"`
		} `yaml:"commands"`
		Scripts struct {
			Before []string `yaml:"before"`
			After  []string `yaml:"after"`
		} `yaml:"scripts"`
	} `yaml:"build"`
	Docker struct {
		Build struct {
			Registry string   `yaml:"registry"`
			Tag      string   `yaml:"tag"`
			Args     []string `yaml:"args"`
		} `yaml:"build"`
		Run struct {
			Args []string `yaml:"args"`
		} `yaml:"run"`
	} `yaml:"docker"`
}

BootConfigForBuild match yaml config of build.yaml 1: Build.Type: Required, the type of programming language 2: Build.Main: Optional, path of main.go file, default is current working directory 3: Build.GOOS: Optional, specify GOOS, default from current go env 4: Build.GOARCH: Optional, specify GOARCH, default from current go env 5: Build.Args: Optional, specify arguments while run build 6: Build.Copy: Optional, the files and folders need to copy to target folder 7: Build.Commands.Before: Optional, commands needs to run before build 8: Build.Commands.After: Optional, commands needs to run after build 9: Build.Scripts.Before: Optional, scripts needs to run before build 10: Build.Scripts.After: Optional, scripts needs to run after build 11: Docker.Build.Registry: Optional, docker registry while building docker image 12: Docker.Build.Tag: Optional, docker tag while building docker image 13: Docker.Build.Args: Optional, arguments needs to pass while building docker image 14: Docker.Build.Run.Args: Optional, arguments needs to pass to docker while running docker container

type Commit added in v1.2.4

type Commit struct {
	// Id of current commit
	Id string `yaml:"id" json:"id"`
	// Date of current commit
	Date string `yaml:"date" json:"date"`
	// IdAbbr is abbreviation of id of current commit
	IdAbbr string `yaml:"idAbbr" json:"idAbbr"`
	// Sub is subject of current commit
	Sub string `yaml:"sub" json:"sub"`
	// Committer of current commit
	Committer *Committer `yaml:"committer" json:"committer"`
}

Commit of git from local machine

type Committer added in v1.2.4

type Committer struct {
	// Name of committer
	Name string `yaml:"name" json:"name"`
	// Email of committer
	Email string `yaml:"email" json:"email"`
}

Committer info of current commit

type Git added in v1.2.4

type Git struct {
	// Url of git repo
	Url string `yaml:"url" json:"url"`
	// Branch of git repo
	Branch string `yaml:"branch" json:"branch"`
	// Tag of git repo
	Tag string `yaml:"tag" json:"tag"`
	// Commit info of git repo
	Commit *Commit `yaml:"commit" json:"commit"`
}

Git metadata info on local machine

type PkgInfo added in v1.2.4

type PkgInfo struct {
	Name    string
	Version string
}

func GetPkgInfo added in v1.2.4

func GetPkgInfo() *PkgInfo

Jump to

Keyboard shortcuts

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