common

package
v0.1.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2020 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultProjectName represents the short app name
	DefaultProjectName string = "myproject"
	// DefaultPlanFile defines default name for plan file
	DefaultPlanFile string = types.AppNameShort + ".plan"
	// TempDirPrefix defines the prefix of the temp directory
	TempDirPrefix string = types.AppNameShort + "-"
	// AssetsDir defines the dir of the assets temp directory
	AssetsDir string = types.AppNameShort + "assets"
	// VolumePrefix defines the prefix to be used for volumes
	VolumePrefix string = "vol"
	// DefaultStorageClassName defines the default storage class to be used
	DefaultStorageClassName string = "default"
	// DefaultDirectoryPermission defines the default permission used when a directory is created
	DefaultDirectoryPermission os.FileMode = 0755
	// DefaultExecutablePermission defines the default permission used when an executable file is created
	DefaultExecutablePermission os.FileMode = 0744
	// DefaultFilePermission defines the default permission used when a non-executable file is created
	DefaultFilePermission os.FileMode = 0644
	// DefaultRegistryURL points to the default registry url that will be used
	DefaultRegistryURL string = "docker.io"
	// ImagePullSecretPrefix is the prefix that will be prepended to pull secret name
	ImagePullSecretPrefix string = "imagepullsecret"
	// QACacheFile defines the location of the QA cache file
	QACacheFile string = types.AppNameShort + "qacache.yaml"
	// DefaultClusterType defines the default cluster type chosen by plan
	DefaultClusterType string = "Kubernetes"
	// IgnoreFilename is the name of the file containing the ignore rules and exceptions
	IgnoreFilename string = "." + types.AppNameShort + "ignore"
	// ExposeSelector tag is used to annotate services that are externally exposed
	ExposeSelector string = types.GroupName + "/service.expose"
	// AnnotationLabelValue represents the value when an annotation is valid
	AnnotationLabelValue string = "true"
)

Variables

View Source
var (
	// DefaultPVCSize stores the default PVC size
	DefaultPVCSize, _ = resource.ParseQuantity("100Mi")
	// IgnoreEnvironment indicates whether to ignore the current environment or not
	IgnoreEnvironment = false
	// TempPath defines where all app data get stored during execution
	TempPath = TempDirPrefix + "temp"
	// AssetsPath defines where all assets get stored during execution
	AssetsPath = filepath.Join(TempPath, AssetsDir)
)

Functions

func CleanAndFindCommonDirectory

func CleanAndFindCommonDirectory(paths []string) string

CleanAndFindCommonDirectory finds the common ancestor directory among a list of absolute paths. Cleans the paths you give it before finding the directory. Also see FindCommonDirectory

func CopyFile

func CopyFile(dst, src string) error

CopyFile copies a file from src to dst. The dst file will be truncated if it exists. Returns an error if it failed to copy all the bytes.

func CreateAssetsData

func CreateAssetsData() (assetsPath string, tempPath string, finalerr error)

CreateAssetsData creates an assets directory and dumps the assets data into it

func FindCommonDirectory

func FindCommonDirectory(paths []string) string

FindCommonDirectory finds the common ancestor directory among a list of cleaned absolute paths. Will not clean the paths you give it before trying to find the directory. Also see CleanAndFindCommonDirectory

func GetClosestMatchingString

func GetClosestMatchingString(options []string, searchstring string) string

GetClosestMatchingString returns the closest matching string for a given search string

func GetFilesByExt

func GetFilesByExt(inputPath string, exts []string) ([]string, error)

GetFilesByExt returns files by extension

func GetFilesByName

func GetFilesByName(inputPath string, names []string) ([]string, error)

GetFilesByName returns files by name

func GetGitRemoteNames

func GetGitRemoteNames(path string) ([]string, error)

GetGitRemoteNames returns a list of remotes if there is a repo and remotes exists.

func GetGitRepoDetails

func GetGitRepoDetails(path, remoteName string) (remoteURLs []string, branch string, repoDir string, finalerr error)

GetGitRepoDetails returns the remote urls for a git repo at path.

func GetGitRepoName

func GetGitRepoName(path string) (repo string, root string)

GetGitRepoName returns the remote repo's name and context

func GetImageNameAndTag

func GetImageNameAndTag(image string) (string, string)

GetImageNameAndTag splits an image full name and returns the image name and tag

func GetSHA256Hash

func GetSHA256Hash(s string) string

GetSHA256Hash returns the SHA256 hash of the string. The hash is 256 bits/32 bytes and encoded as a 64 char hexadecimal string.

func GetStringFromTemplate

func GetStringFromTemplate(tpl string, config interface{}) (string, error)

GetStringFromTemplate returns string for a template

func IsIntPresent

func IsIntPresent(list []int, value int) bool

IsIntPresent checks if a value is present in a slice

func IsStringPresent

func IsStringPresent(list []string, value string) bool

IsStringPresent checks if a value is present in a slice

func MakeFileNameCompliant

func MakeFileNameCompliant(name string) string

MakeFileNameCompliant returns a DNS-1123 standard string Motivated by https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set Also see page 1 "ASSUMPTIONS" heading of https://tools.ietf.org/html/rfc952 Also see page 13 of https://tools.ietf.org/html/rfc1123#page-13

func MakeStringDNSLabelNameCompliant

func MakeStringDNSLabelNameCompliant(s string) string

MakeStringDNSLabelNameCompliant makes the string a valid DNS label name. See https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-label-names 1. contain at most 63 characters 2. contain only lowercase alphanumeric characters or '-' 3. start with an alphanumeric character 4. end with an alphanumeric character

func MakeStringDNSNameCompliant

func MakeStringDNSNameCompliant(s string) string

MakeStringDNSNameCompliant makes the string into a valid DNS name.

func MakeStringDNSSubdomainNameCompliant

func MakeStringDNSSubdomainNameCompliant(s string) string

MakeStringDNSSubdomainNameCompliant makes the string a valid DNS subdomain name. See https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-subdomain-names 1. contain no more than 253 characters 2. contain only lowercase alphanumeric characters, '-' or '.' 3. start with an alphanumeric character 4. end with an alphanumeric character

func MergeIntSlices

func MergeIntSlices(slice1 []int, slice2 []int) []int

MergeIntSlices merges two int slices

func MergeStringMaps

func MergeStringMaps(map1 map[string]string, map2 map[string]string) map[string]string

MergeStringMaps merges two string maps

func MergeStringSlices

func MergeStringSlices(slice1 []string, slice2 []string) []string

MergeStringSlices merges two string slices

func NormalizeForFilename

func NormalizeForFilename(name string) string

NormalizeForFilename normalizes a string to only filename valid characters

func NormalizeForServiceName

func NormalizeForServiceName(svcName string) string

NormalizeForServiceName converts the string to be compatible for service name

func ReadJSON

func ReadJSON(file string, data interface{}) error

ReadJSON reads an json into an object

func ReadYaml

func ReadYaml(file string, data interface{}) error

ReadYaml reads an yaml into an object

func TarAsString

func TarAsString(path string, ignorefiles []string) (string, error)

TarAsString converts a directory into a string

func UnTarString

func UnTarString(tarstring string, path string) (err error)

UnTarString converts a string into a directory

func UniqueStrings

func UniqueStrings(xs []string) []string

UniqueStrings returns a new slice with only the unique strings from the input slice.

func WriteJSON

func WriteJSON(outputPath string, data interface{}) error

WriteJSON writes an json to disk

func WriteTemplateToFile

func WriteTemplateToFile(tpl string, config interface{}, writepath string, filemode os.FileMode) error

WriteTemplateToFile writes a templated string to a file

func WriteYaml

func WriteYaml(outputPath string, data interface{}) error

WriteYaml writes an yaml to disk

func YamlAttrPresent

func YamlAttrPresent(path string, attr string) (bool, interface{})

YamlAttrPresent returns YAML attributes

Types

This section is empty.

Directories

Path Synopsis
This program generates dockerfiles.go.
This program generates dockerfiles.go.

Jump to

Keyboard shortcuts

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