util

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2019 License: Apache-2.0 Imports: 34 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 BallerinaInstallationDir added in v0.2.1

func BallerinaInstallationDir() string

func CelleryInstallationDir added in v0.2.0

func CelleryInstallationDir() string

func CleanOrCreateDir

func CleanOrCreateDir(dirPath string) error

func ContainsInStringArray added in v0.2.0

func ContainsInStringArray(array []string, item string) bool

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 CreateTempExecutableBalFile added in v0.3.0

func CreateTempExecutableBalFile(file string, action string) (string, error)

func DownloadFile

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

func DownloadFromS3Bucket

func DownloadFromS3Bucket(bucket, item, path string, displayProgressBar bool)

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 FormatBytesToString added in v0.2.0

func FormatBytesToString(size int64) string

func GetCurrentPath added in v0.2.0

func GetCurrentPath() (string, error)

func GetDuration

func GetDuration(startTime time.Time) string

func GetFileSize

func GetFileSize(path string) (int64, error)

func GetS3ObjectSize added in v0.2.0

func GetS3ObjectSize(bucket, item string) int64

func GetSourceFileName

func GetSourceFileName(filePath string) (string, error)

func GetSubDirectoryNames

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

func GetYesOrNoFromUser added in v0.2.0

func GetYesOrNoFromUser(question string, withBackOption bool) (bool, bool, error)

func IsCommandAvailable added in v0.2.1

func IsCommandAvailable(name string) bool

func IsCompleteSetupSelected added in v0.2.0

func IsCompleteSetupSelected() (bool, bool)

func IsLoadBalancerIngressTypeSelected added in v0.2.0

func IsLoadBalancerIngressTypeSelected() (bool, bool)

func MergeKubeConfig added in v0.2.0

func MergeKubeConfig(newConfigFile string) error

func OpenBrowser added in v0.2.0

func OpenBrowser(url string) error

OpenBrowser opens up the provided URL in a browser

func PrintSuccessMessage

func PrintSuccessMessage(message string)

PrintSuccessMessage prints the standard command success message

func PrintWarningMessage added in v0.3.0

func PrintWarningMessage(message string)

func PrintWhatsNextMessage

func PrintWhatsNextMessage(action string, cmd string)

func ReadCellImageYaml added in v0.2.0

func ReadCellImageYaml(cellImage string) []byte

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(credentialType string, usernameOverride string) (string, string, error)

RequestCredentials requests the credentials form the user and returns them

func RunMethodExists

func RunMethodExists(sourceFile string) (bool, error)

RunMethodExists checks if the run method exists in ballerina file

func TestMethodExists added in v0.3.0

func TestMethodExists(sourceFile string) (bool, error)

TestMethodExists checks if the test method exists in ballerina file

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).

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.

func WaitForRuntime added in v0.2.0

func WaitForRuntime(checkKnative, hpaEnabled bool)

func ZipFiles

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

Types

type BLangManager added in v0.2.0

type BLangManager struct{}

func (*BLangManager) GetExecutablePath added in v0.2.0

func (langMgr *BLangManager) GetExecutablePath() (string, error)

func (*BLangManager) Init added in v0.2.0

func (langMgr *BLangManager) Init() error

type Cell

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

type CellAnnotations added in v0.2.0

type CellAnnotations struct {
	Organization string `json:"mesh.cellery.io/cell-image-org"`
	Name         string `json:"mesh.cellery.io/cell-image-name"`
	Version      string `json:"mesh.cellery.io/cell-image-version"`
}

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 CellImageMetaData added in v0.2.0

type CellImageMetaData struct {
	CellImageName
	Labels              map[string]string             `json:"labels"`
	DockerImages        []string                      `json:"dockerImages"`
	BuildTimestamp      int64                         `json:"buildTimestamp"`
	BuildCelleryVersion string                        `json:"buildCelleryVersion"`
	Ingresses           []string                      `json:"ingresses"`
	Components          []string                      `json:"components"`
	Dependencies        map[string]*CellImageMetaData `json:"dependencies"`
	ComponentDep        map[string][]string           `json:"componentDep"`
	Exposed             []string                      `json:"exposed"`
	ZeroScaling         bool                          `json:"zeroScaling"`
	AutoScaling         bool                          `json:"autoScaling"`
}

type CellImageName added in v0.2.0

type CellImageName struct {
	Organization string `json:"org"`
	Name         string `json:"name"`
	Version      string `json:"ver"`
}

type CellMetaData

type CellMetaData struct {
	CreationTimestamp string          `json:"creationTimestamp"`
	Annotations       CellAnnotations `json:"annotations"`
	Name              string          `json:"name"`
}

type CellSpec added in v0.2.0

type CellSpec struct {
	ComponentTemplates []ComponentTemplate `json:"servicesTemplates"`
	GateWayTemplate    Gateway             `json:"gatewayTemplate"`
}

type CellStatus

type CellStatus struct {
	Status       string `json:"status"`
	Gateway      string `json:"gatewayHostname"`
	ServiceCount int    `json:"serviceCount"`
}

type ComponentTemplate added in v0.2.0

type ComponentTemplate struct {
	Metadata ComponentTemplateMetadata `json:"metadata"`
}

type ComponentTemplateMetadata added in v0.2.0

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

type Gateway

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

type GatewayDefinition

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

type GatewayGrpcApi added in v0.2.0

type GatewayGrpcApi struct {
	Backend     string              `json:"backend"`
	Context     string              `json:"context"`
	Definitions []GatewayDefinition `json:"definitions"`
	Global      bool                `json:"global"`
	Vhost       string              `json:"vhost"`
}

type GatewayHttpApi

type GatewayHttpApi struct {
	Backend     string              `json:"backend"`
	Context     string              `json:"context"`
	Definitions []GatewayDefinition `json:"definitions"`
	Global      bool                `json:"global"`
	Vhost       string              `json:"vhost"`
}

type GatewaySpec

type GatewaySpec struct {
	HttpApis []GatewayHttpApi `json:"http"`
	TcpApis  []GatewayTcpApi  `json:"tcp"`
	GrpcApis []GatewayGrpcApi `json:"grpc"`
}

type GatewayTcpApi added in v0.2.0

type GatewayTcpApi struct {
	Backend     string              `json:"backend"`
	Context     string              `json:"context"`
	Definitions []GatewayDefinition `json:"definitions"`
	Global      bool                `json:"global"`
	Vhost       string              `json:"vhost"`
}

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 LangManager added in v0.2.0

type LangManager interface {
	Init() error
	GetExecutablePath() (string, error)
}

type RegistryCredentials added in v0.2.0

type RegistryCredentials struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

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) Pause added in v0.2.0

func (s *Spinner) Pause()

Pause the spinner and clear the line

func (*Spinner) Resume added in v0.2.0

func (s *Spinner) Resume()

Resume the previous action

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