core

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

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

Go to latest
Published: Dec 31, 2023 License: AGPL-3.0, AGPL-3.0-or-later Imports: 30 Imported by: 6

Documentation

Index

Constants

View Source
const (
	// ArtDebug the global flag used to switch on debug / verbose mode
	ArtDebug = "ART_DEBUG"
	// ArtPackageFQDN the env var that defines the name of the artisan package to run
	ArtPackageFQDN = "ART_PACKAGE_FQDN"
	// ArtPackageDomain the domain portion specified in the artisan package name
	ArtPackageDomain = "ART_PACKAGE_DOMAIN"
	// ArtPackageGroup the group portion specified in the artisan package name
	ArtPackageGroup = "ART_PACKAGE_GROUP"
	// ArtPackageName the name portion specified in the artisan package name
	ArtPackageName = "ART_PACKAGE_NAME"
	// ArtPackageTag the tag portion specified in the artisan package name
	ArtPackageTag = "ART_PACKAGE_TAG"
	// ArtFxName the env var that defines the name of the package function to run
	ArtFxName = "ART_FX_NAME"
	// ArtPackageSource the env var that defines the type of source a runner pipeline should use
	ArtPackageSource = "ART_PACKAGE_SOURCE"
	// ArtRegUser the name of the env variable that holds the artisan registry user to authenticate with a remote registry
	// when registry related commands are executed and no specific credentials are provided via command flag
	ArtRegUser = "ART_REG_USER"
	// ArtRegPassword1 the name of the env variable that holds the artisan registry password to authenticate with a remote registry
	// when registry related commands are executed and no specific credentials are provided via command flag
	ArtRegPassword1 = "ART_REG_PWD"
	ArtRegPassword2 = "ART_REG_PASS"
	// ArtDefaultHome the default artisan home
	ArtDefaultHome = ""

	ArtReference = "ART_REF"
	ArtBuildPath = "ART_BUILD_PATH"
	ArtGitCommit = "ART_GIT_COMMIT"
	ArtWorkDir   = "ART_WORK_DIR"
	ArtFromUri   = "ART_FROM_URI"
	ArtOS        = "ART_OS"
	ArtArch      = "ART_ARCH"
	ArtShell     = "ART_SHELL"
	// ArtExeWd the path from where a package was run
	ArtExeWd = "ART_EXE_WD"
)
View Source
const (
	RegDomain = "artr.gdn"
	RegGroup  = "lib"
)
View Source
const AppName = "artisan"

Variables

View Source
var (
	WarningLogger *log.Logger
	InfoLogger    *log.Logger
	ErrorLogger   *log.Logger
	DebugLogger   *log.Logger
)
View Source
var Version = "0.0.0"

Version placeholder variable for the version number displayed on cli this value gets overridden at build time with the correct version in the build file

Functions

func AbsPath

func AbsPath(filePath string) (string, error)

AbsPath return a valid absolute path that exists

func BasicToken

func BasicToken(user string, pwd string) string

BasicToken creates a basic authentication token

func CheckErr

func CheckErr(err error, msg string, a ...interface{})

func CopyFile

func CopyFile(src, dst string) error

CopyFile copy a single file

func Curl

func Curl(uri string, method string, token string, validCodes []int, payload string, file string, maxAttempts int, delaySecs int, timeoutSecs int, headers []string, outputFile string, responseHeaders bool)

func Debug

func Debug(msg string, a ...interface{})

Debug writes a debug message to the console

func Encode

func Encode(value string) string

Encode strings to be used in tekton pipelines names

func EnsureRegistryPath

func EnsureRegistryPath(path string) error

EnsureRegistryPath check the local registry directory exists and if not creates it

func Extract

func Extract(content, prefix, suffix string, n int) []string

Extract up to a maximum of "n" occurrences of a string that has a "prefix" and a "suffix" in "content" prefix and suffix can be golang regex, for example using suffix = "$" means match up to the end of the line

func FilenameWithoutExtension

func FilenameWithoutExtension(fn string) string

func FilesPath

func FilesPath(path string) string

func FindFiles

func FindFiles(root, extPattern string) ([]string, error)

FindFiles return a list of file names matching the specified regular expression pattern recursively checking all subfolders in the specified root

func Get

func Get(url, user, pwd string) (*http.Response, error)

Get make a GET HTTP request to the specified URL

func HandleCtrlC

func HandleCtrlC(err error)

func HasFunction

func HasFunction(value string) (bool, string)

func HasShell

func HasShell(value string) (bool, string, string)

func HomeDir

func HomeDir() string

HomeDir gets the user home directory

func InDebugMode

func InDebugMode() bool

func Infof

func Infof(msg string, a ...interface{})

func IsJSON

func IsJSON(s string) bool

func IsPackageName

func IsPackageName(val interface{}) error

IsPackageName requires the value conforms to an Artisan package name

func IsPath

func IsPath(val interface{}) error

IsPath requires the value conforms to a path

func IsURI

func IsURI(val interface{}) error

IsURI requires the value conforms to a URI

func LangExists

func LangExists(path string)

func LangPath

func LangPath(path string) string

func MergeEnvironmentVars

func MergeEnvironmentVars(args []string, env conf.Configuration, interactive bool) ([]string, conf.Configuration)

MergeEnvironmentVars merges environment variables in the arguments returns the merged command list and the updated environment variables map if interactive mode is used

func NewTempDir

func NewTempDir(artHome string) (string, error)

NewTempDir will create a temp folder with a random name and return the path

func QualifyRuntime

func QualifyRuntime(runtime string) string

defaults to quay.io/artisan root if not specified

func RaiseErr

func RaiseErr(msg string, a ...interface{})

func RandomName

func RandomName(number int) string

RandomName generates a random name

func RandomPwd

func RandomPwd(length int, addSymbols bool) string

RandomPwd creates a new password of the specified length with or without symbols

func RandomString

func RandomString(n int) string

RandomString gets a random string of specified length

func RegUserPwd

func RegUserPwd(creds string) (user, pwd string)

RegUserPwd returns username and password from a username:password formatted string if the passed-in creds string is empty then it checks if the artisan registry env variables have been set and if so, use their values as creds note: this function should be used any time remote artisan registry operations are required

func RegistryPath

func RegistryPath(path string) string

RegistryPath gets the root path of the local registry

func RemoveElement

func RemoveElement(a []string, value string) []string

RemoveElement remove an element in a slice

func RunPath

func RunPath(path string) string

RunPath temporary path for running package functions

func RunPathExists

func RunPathExists(path string)

func Tar

func Tar(files []TarFile, buf io.Writer, preserveDirStruct bool, artHome string) error

func TmpExists

func TmpExists(path string)

func TmpPath

func TmpPath(path string) string

TmpPath temporary path for file operations

func ToAbs

func ToAbs(path string) string

ToAbs converts the path to absolute path

func ToAbsPath

func ToAbsPath(flowPath string) string

func ToElapsedLabel

func ToElapsedLabel(rfc850time string) string

ToElapsedLabel returns the elapsed time until now in human friendly format

func ToJsonBytes

func ToJsonBytes(s interface{}) []byte

ToJsonBytes convert the passed in parameter to a Json Byte Array

func ToYamlBytes

func ToYamlBytes(s interface{}) ([]byte, error)

ToYamlBytes convert the passed in parameter to a Yaml Byte Array

func TrimNewline

func TrimNewline(s string) string

func Untar

func Untar(tarballReader io.Reader, outputPath string) error

func UserPwd

func UserPwd(creds string) (user, pwd string)

UserPwd returns username and password from a username:password formatted string if the passed-in creds string is empty then it returns empty values note: if the credentials are for an artisan registry then the function RegUserPwd should be used instead

func Wait

func Wait(uri, filter, token string, maxAttempts int)

func WorkDir

func WorkDir() string

Types

type Log

type Log struct {
	M map[string]Table `json:"log"`
	// contains filtered or unexported fields
}

func NewLog

func NewLog(artHome string) (*Log, error)

func (*Log) Add

func (l *Log) Add(table string, values []string) error

func (*Log) AddFile

func (l *Log) AddFile(table string, file string) error

func (*Log) Clear

func (l *Log) Clear() error

func (*Log) New

func (l *Log) New(table string, header []string) error

func (*Log) Print

func (l *Log) Print() error

type PackageName

type PackageName struct {
	Domain string
	Group  string
	Name   string
	Tag    string
}

PackageName defines the name of a package following the format: domain/group/name:tag

func ParseName

func ParseName(packageName string) (*PackageName, error)

func ValidateNames

func ValidateNames(packages []string) ([]PackageName, error)

ValidateNames get a list of qualified package names from their string representation

func (*PackageName) FullyQualifiedGroup

func (a *PackageName) FullyQualifiedGroup() string

func (*PackageName) FullyQualifiedName

func (a *PackageName) FullyQualifiedName() string

func (*PackageName) FullyQualifiedNameTag

func (a *PackageName) FullyQualifiedNameTag() string

func (*PackageName) IsInTheSameRepositoryAs

func (a *PackageName) IsInTheSameRepositoryAs(name *PackageName) bool

func (*PackageName) NormalString

func (a *PackageName) NormalString() string

func (*PackageName) Repository

func (a *PackageName) Repository() string

func (*PackageName) String

func (a *PackageName) String() string

type Table

type Table struct {
	Header []string   `json:"h"`
	Rows   [][]string `json:"r"`
}

type TarFile

type TarFile struct {
	Path  string
	Bytes []byte
	Name  string
}

Jump to

Keyboard shortcuts

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