utils

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CosResourceID is IBM COS service id, can be retrieved using ibmcloud cli
	// ibmcloud catalog service cloud-object-storage.
	CosResourceID = "dff97f5c-bc5e-4455-b470-411c3edbe49c"

	// PowerVSResourceID is Power VS power-iaas service id, can be retrieved using ibmcloud cli
	// ibmcloud catalog service power-iaas.
	PowerVSResourceID = "abd259f0-9990-11e8-acc8-b9f54a8f1661"

	// PowerVSResourcePlanID is Power VS power-iaas plan id, can be retrieved using ibmcloud cli
	// ibmcloud catalog service power-iaas.
	PowerVSResourcePlanID = "f165dd34-3a40-423b-9d95-e90a23f724dd"
)
View Source
const (
	DeletePromptMessage = "Deleting all the above %s and the action is irreversible. Do you really want to continue?"
)
View Source
const (
	ServiceTypeCloudObjectStorage = "cloud-object-storage"
)

Variables

View Source
var CosResourcePlanIDs = map[string]string{
	"onerate":  "1e4e33e4-cfa6-4f12-9016-be594a6d5f87",
	"lite":     "2fdf0c08-2d32-4f46-84b5-32e0c92fffd8",
	"standard": "744bfc56-d12c-4866-88d5-dac9139e0e5d",
}

Functions

func AskConfirmation

func AskConfirmation(message string) bool

func Contains

func Contains(s []string, e string) bool

func EnsurePrerequisitesAreSet added in v0.1.18

func EnsurePrerequisitesAreSet(apiKey, workspaceID, workspaceName string) error

Ensure that either the workspaceID or the workspaceName is set, along with the API Key.

func FormatMemory

func FormatMemory(memory *float64) string

func FormatProcessor

func FormatProcessor(proc *float64) string

func GenerateRandomString added in v0.1.3

func GenerateRandomString(length int) string

Generate random string of given length

func GenerateSpec added in v0.1.3

func GenerateSpec(numTargetsPerSource int) pkg.Spec

Generate Specifications

func GunzipIt added in v0.1.9

func GunzipIt(src, dest string) error

GunzipIt the source file to target

func GzipIt added in v0.1.9

func GzipIt(src, dest string) error

GzipIt compresses the source file to dest

func IsGzip added in v0.1.9

func IsGzip(source string) (bool, error)

IsGzip returns if file is in gzip format

func PollUntil added in v0.1.15

func PollUntil(pollInterval, timeOut <-chan time.Time, condition func() (bool, error)) error

PollUntil validates if a certain condition is met at defined poll intervals. If a timeout is reached, an associated error is returned to the caller. condition contains the use-case specific code that returns true when a certain condition is achieved.

func ReadUserInput

func ReadUserInput(message string) string

func RetrieveValFromMap added in v0.1.16

func RetrieveValFromMap[K comparable, V any](m map[K]V, key K) V

func RunCMD

func RunCMD(cmd string, args ...string) (int, string, string)

func SanitizeExtractPath added in v0.1.9

func SanitizeExtractPath(filePath string, destination string) error

func SelectItem

func SelectItem(msg string, instances []string) (string, error)

func SpinnerPollUntil added in v0.1.19

func SpinnerPollUntil(pollInterval, timeOut <-chan time.Time, condition func() (string, bool, error)) error

SpinnerPollUntil validates if a certain condition is met at defined poll intervals. until the condition is met, a loading spinner is displayed If a timeout is reached, an associated error is returned to the caller. condition contains the use-case specific code that returns true when a certain condition is achieved.

func Untar added in v0.1.9

func Untar(tarball, target, filename string) error

Extract specific file from the tar file

Types

type Table

type Table struct {
	*tablewriter.Table
	// contains filtered or unexported fields
}

func NewTable

func NewTable() *Table

func (*Table) Render

func (t *Table) Render(rows interface{}, exclude []string)

func (*Table) SetHeader

func (t *Table) SetHeader(keys []string)

Jump to

Keyboard shortcuts

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