util

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2019 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Bold = color.New(color.Bold).SprintFunc()
View Source
var CyanBold = color.New(color.FgCyan).Add(color.Bold).SprintFunc()
View Source
var Faint = color.New(color.Faint).SprintFunc()
View Source
var Green = color.New(color.FgGreen).SprintfFunc()
View Source
var GreenBold = color.New(color.FgGreen).Add(color.Bold).SprintFunc()
View Source
var Red = color.New(color.FgRed).Add(color.Bold).SprintFunc()
View Source
var YellowBold = color.New(color.FgYellow).Add(color.Bold).SprintFunc()

Functions

func AddImageToBalPath

func AddImageToBalPath(cellImage *CellImage) error

AddImageToBalPath extracts the cell image in a temporary location and copies the relevant ballerina files to the ballerina repo directory. This expects the BALLERINA_HOME environment variable to be set in th developer machine.

func CleanOrCreateDir

func CleanOrCreateDir(dirPath string) error

func ConvertStringToTime

func ConvertStringToTime(timeString string) time.Time

func CopyDir

func CopyDir(src string, dst string) error

Dir copies a whole directory recursively

func CopyFile

func CopyFile(src, dst string) error

File copies a single file from src to dst

func CreateDir

func CreateDir(dirPath string) error

func DownloadFile

func DownloadFile(filepath string, url string) (*http.Response, error)

func DownloadFromS3Bucket

func DownloadFromS3Bucket(bucket, item, path string)

func ExecuteCommand

func ExecuteCommand(cmd *exec.Cmd, errorMessage string) error

func ExitWithErrorMessage

func ExitWithErrorMessage(message string, err error)

ExitWithErrorMessage prints an error message and exits the command

func ExtractTarGzFile

func ExtractTarGzFile(extractTo, archive_name string) error

func FileExists

func FileExists(path string) (bool, error)

func FileUploadRequest

func FileUploadRequest(uri string, params map[string]string, paramName, path string, secure bool) (*http.Request, error)

Creates a new file upload http request with optional extra params

func FindInDirectory

func FindInDirectory(directory, suffix string) []string

func GetDuration

func GetDuration(startTime time.Time) string

func GetFileSize

func GetFileSize(path string) (int64, error)

func GetSourceFileName

func GetSourceFileName(filePath string) (string, error)

func GetSubDirectoryNames

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

func PrintSuccessMessage

func PrintSuccessMessage(message string)

PrintSuccessMessage prints the standard command success message

func PrintWhatsNextMessage

func PrintWhatsNextMessage(action string, cmd string)

func RecursiveZip

func RecursiveZip(files []string, folders []string, destinationPath string) error

func RenameFile

func RenameFile(oldName, newName string) error

func ReplaceFile

func ReplaceFile(fileToBeReplaced, fileToReplace string) error

func ReplaceInFile

func ReplaceInFile(srcFile, oldString, newString string, replaceCount int) error

func RequestCredentials

func RequestCredentials() (string, string, error)

RequestCredentials requests the credentials form the user and returns them

func RunMethodExists

func RunMethodExists(sourceFile string) (bool, error)

func Trim

func Trim(stream string) string

func Unzip

func Unzip(zipFolderName string, destinationFolderName string) error

func UserHomeDir

func UserHomeDir() string

func ValidateImageTag

func ValidateImageTag(imageTag string) error

ValidateImageTag validates the image tag (without the registry in it). This checks the version to be in the format of semantic versioning

func ValidateImageTagWithRegistry

func ValidateImageTagWithRegistry(imageTag string) error

ValidateImageTag validates the image tag (with the registry in it). The registry is an option element in this validation. This checks the version to be in the format of semantic versioning

func ZipFiles

func ZipFiles(filename string, files []string) error

Types

type Cell

type Cell struct {
	CellMetaData CellMetaData `json:"metadata"`
	CellStatus   CellStatus   `json:"status"`
}

type CellImage

type CellImage struct {
	Registry     string
	Organization string
	ImageName    string
	ImageVersion string
}

func ParseImageTag

func ParseImageTag(cellImageString string) (parsedCellImage *CellImage, err error)

ParseImageTag parses the given image name string and returns a CellImage struct with the relevant information.

type CellMetaData

type CellMetaData struct {
	CreationTimestamp string `json:"creationTimestamp"`
}

type CellPods

type CellPods struct {
	Items []Pod `json:"items"`
}

type CellStatus

type CellStatus struct {
	Status string `json:"status"`
}

type Gateway

type Gateway struct {
	GatewaySpec GatewaySpec `json:"spec"`
}

type GatewayDefinition

type GatewayDefinition struct {
	Method string `json:"method"`
	Path   string `json:"path"`
}

type GatewayHttpApi

type GatewayHttpApi struct {
	Backend     string              `json:"backend"`
	Context     string              `json:"context"`
	Definitions []GatewayDefinition `json:"definitions"`
}

type GatewaySpec

type GatewaySpec struct {
	HttpApis []GatewayHttpApi `json:"http"`
}

type Gcp

type Gcp struct {
	Compute GcpCompute `json:"compute"`
	Core    GcpCore    `json:"core"`
}

type GcpCompute

type GcpCompute struct {
	Region string `json:"region"`
	Zone   string `json:"zone"`
}

type GcpCore

type GcpCore struct {
	Account string `json:"account"`
	Project string `json:"project"`
}

type Pod

type Pod struct {
	MetaData  PodMetaData `json:"metadata"`
	PodStatus PodStatus   `json:"status"`
}

type PodCondition

type PodCondition struct {
	Type               string `json:"type"`
	Status             string `json:"status"`
	LastTransitionTime string `json:"lastTransitionTime"`
}

type PodMetaData

type PodMetaData struct {
	Name string `json:"name"`
}

type PodStatus

type PodStatus struct {
	Phase      string         `json:"phase"`
	StartTime  string         `json:"startTime"`
	Conditions []PodCondition `json:"conditions"`
}

type Service

type Service struct {
	Items []ServiceItem `json:"items"`
}

type ServiceItem

type ServiceItem struct {
	Metadata ServiceMetaData `json:"metadata"`
	Spec     ServiceSpec     `json:"spec"`
}

type ServiceMetaData

type ServiceMetaData struct {
	Name string `json:"name"`
}

type ServicePort

type ServicePort struct {
	Port int `json:"port"`
}

type ServiceSpec

type ServiceSpec struct {
	Ports []ServicePort `json:"ports"`
}

type Spinner

type Spinner struct {
	// contains filtered or unexported fields
}

func StartNewSpinner

func StartNewSpinner(action string) *Spinner

StartNewSpinner starts a new spinner with the provided message

func (*Spinner) SetNewAction

func (s *Spinner) SetNewAction(action string)

SetNewAction sets the current action of a spinner

func (*Spinner) Stop

func (s *Spinner) Stop(isSuccess bool)

Stop causes the spinner to stop

Jump to

Keyboard shortcuts

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