utils

package
v0.0.0-...-398cef7 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2021 License: GPL-3.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Conf Main (other var from init)
	Conf = Config{
		Env: &EnvVar{
			File:     strings.TrimSpace("/opt/.env"),
			Project:  strings.TrimSpace(os.Getenv("RD_JOB_PROJECT")),
			AppName:  strings.TrimSpace(os.Getenv("RD_OPTION_APP_NAME")),
			EnvName:  strings.TrimSpace(os.Getenv("RD_OPTION_ENV_NAME")),
			GitVer:   strings.TrimSpace(os.Getenv("RD_OPTION_GIT_VERSION")),
			CodeType: strings.TrimSpace(os.Getenv("RD_OPTION_CODE_TYPE")),
		},
		Git:    new(IniGit),
		Kube:   new(IniK8s),
		Path:   new(IniPath),
		Harbor: new(IniHarbor),
		File:   new(FileBuild),
	}
	// ImageName build image
	ImageName string
)

Functions

func CheckIfError

func CheckIfError(err error)

CheckIfError should be used to naively panics if an error is not nil.

func Info

func Info(format string, args ...interface{})

Info should be used to describe the example commands that are about to run.

func Warning

func Warning(format string, args ...interface{})

Warning should be used to display a warning

Types

type Config

type Config struct {
	Env    *EnvVar
	Git    *IniGit
	Kube   *IniK8s
	Path   *IniPath
	Harbor *IniHarbor
	File   *FileBuild
}

Config Main struct

type DockerClient

type DockerClient struct {
	Username string
	Password string
	Address  string
	Auth     string
	Ctx      context.Context
	Cli      *client.Client
}

DockerClient Cli

func NewDockerClient

func NewDockerClient() *DockerClient

NewDockerClient newCli

func (*DockerClient) Build

func (d *DockerClient) Build()

Build such as `docker build`

func (*DockerClient) Compile

func (d *DockerClient) Compile()

Compile such as `mvn clean / yarn install`

type EnvVar

type EnvVar struct {
	File     string // environment file
	Project  string // project name
	AppName  string // application name
	EnvName  string // environment name
	GitVer   string // code version
	CodeType string // code build type
}

EnvVar env struct

type FileBuild

type FileBuild struct {
	GitAddr      string   `file:"GIT_ADDRESS"`  // code addr
	BuilderImage string   `file:"BUILDER"`      // build image
	BuilderOpts  string   `file:"BUILDER_OPTS"` // build opts
	CopyFiles    []string `file:"Dockerfile"`   // `COPY`/`ADD` params
}

FileBuild file struct

type IniGit

type IniGit struct {
	PrivateKey string `ini:"id_rsa"` // code info
}

IniGit git struct

func (*IniGit) Clean

func (g *IniGit) Clean()

Clean clean workspace

func (*IniGit) Clone

func (g *IniGit) Clone()

Clone git clone

func (*IniGit) GetHead

func (g *IniGit) GetHead() (commit, short string)

GetHead git version

type IniHarbor

type IniHarbor struct {
	User string `ini:"user"` // user name
	Pass string `ini:"pass"` // user pass
	Addr string `ini:"addr"` // harbor addr
	Dist string `ini:"dist"` // harbor dist
}

IniHarbor harbor struct

type IniK8s

type IniK8s struct {
	KubeConfig string `ini:"config"` // kube config
}

IniK8s k8s struct

type IniPath

type IniPath struct {
	Runtime string `ini:"runtime"` // runtime dir
	Workdir string `ini:"workdir"` // workspace dir
}

IniPath path struct

type KubeClient

type KubeClient struct {
	NameSpace string
	AppName   string
	ImageName string
	Ctx       context.Context
	Cli       *kubernetes.Clientset
}

KubeClient Cli

func NewKubeClient

func NewKubeClient() *KubeClient

NewKubeClient newCli

func (KubeClient) Update

func (k KubeClient) Update()

Update .

Jump to

Keyboard shortcuts

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