utils

package
v0.0.0-...-9c8d8c7 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2023 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VersionPath       = "version.yml"
	InstallConfigPath = "install.yml"
	UpgradeConfigPath = "upgrade.yml"
)

Variables

View Source
var C7nFunc = template.FuncMap{
	"randomToken":        randomToken,
	"getImageRepo":       getImageRepo,
	"randomLowCaseToken": randomLowCaseToken,
	"generateAlphaNum":   generateAlphaNum,
}

Functions

func AcceptUserInput

func AcceptUserInput(input Input) (string, error)

func AcceptUserPassword

func AcceptUserPassword(input Input) (string, error)

func AskAgreeTerms

func AskAgreeTerms()

func CheckDomain

func CheckDomain(domain string) bool

func CheckErr

func CheckErr(err error)

func CheckErrAndExit

func CheckErrAndExit(err error, exitCode int)

func CheckErrAndSendMetrics

func CheckErrAndSendMetrics(err error)

func CheckFatal

func CheckFatal(err error)

func CheckMatch

func CheckMatch(value string, input Input) bool

func CheckSchema

func CheckSchema(schema string) bool

func CheckVersion

func CheckVersion(versionRaw, constraint string) (bool, error)

func ConditionSkip

func ConditionSkip() bool

func DirectoryCheck

func DirectoryCheck(dirName string)

func GenerateRunnerToken

func GenerateRunnerToken(length int) string

func GetInstallDefinition

func GetInstallDefinition(file string, version string) (rd []byte, err error)

func GetReleaseTag

func GetReleaseTag(repo, app, version string) (targetVersion string, err error)

func GetRemoteResource

func GetRemoteResource(resourceUrl string) (data []byte, err error)

func GetResource

func GetResource(resource string) (data []byte, err error)

获取本地文件或者网络文件

func GetResourceFile

func GetResourceFile(isRemote bool, version, filepath string) (rd []byte)

func GetVersion

func GetVersion(branch string) string

获取最新的

func HomeDir

func HomeDir() string

HomeDir returns the home directory for the current user

func IsFileExist

func IsFileExist(fileName string) (error, bool)

func PrettyPrint

func PrettyPrint(data interface{})

print the contents of the obj

func RandomString

func RandomString(length ...int) string

func RandomToken

func RandomToken(length int) string

func Vals

func Vals(values []string, fileValues string) (map[string]interface{}, error)

vals merges values from files specified via -f/--values and directly via --set or --set-string or --set-file, marshaling them to YAML

func VersionOrdinal

func VersionOrdinal(version string) string

Types

type Cluster

type Cluster struct {
	Server       string
	User         *User  `yaml:"-"`
	SelectedUser string `yaml:"user"`
}

type Config

type Config struct {
	Version         string
	Terms           Terms
	Clusters        []*NamedCluster
	SelectedCluster string `yaml:"current-cluster"`
	Users           []*NamedUser
	OpsMail         string `yaml:"opsMail"`
}

func GetConfig

func GetConfig() (*Config, error)

func (*Config) CurrentCluster

func (c *Config) CurrentCluster() *Cluster

func (*Config) CurrentServer

func (c *Config) CurrentServer() string

func (*Config) CurrentUser

func (c *Config) CurrentUser() *User

func (*Config) FindNamedClusterByServer

func (c *Config) FindNamedClusterByServer(serverUrl string) *NamedCluster

func (*Config) Write

func (c *Config) Write() error

type Input

type Input struct {
	Enabled  bool
	Regex    string
	Tip      string
	Password bool
	Include  []KV
	Exclude  []KV
	Twice    bool
}

type KV

type KV struct {
	Name  string
	Value string
}

type NamedCluster

type NamedCluster struct {
	Name    string   `yaml:"name"`
	Cluster *Cluster `yaml:"cluster"`
}

type NamedUser

type NamedUser struct {
	Name string `yaml:"name"`
	User *User  `yaml:"user"`
}

type Terms

type Terms struct {
	Accepted bool
}

type User

type User struct {
	Mail       string
	Token      string
	Name       string
	ValidUntil int64
}

Jump to

Keyboard shortcuts

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