common

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: Apache-2.0 Imports: 23 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BoolValidate = func(bool string) error {
	if bool != "true" && bool != "false" {
		return errors.InvalidArgumentErrorf("invalid boolean value")
	}
	return nil
}
View Source
var GetInputTemplates = &promptui.PromptTemplates{
	Prompt:  "{{ . }} ",
	Valid:   "{{ . | green }} ",
	Invalid: "{{ . | red }} ",
	Success: "{{ . | bold }} ",
}
View Source
var ValidateAll = func(input string) error {
	return nil
}
View Source
var ValidateEmail = func(input string) error {
	_, err := mail.ParseAddress(input)
	if err != nil {
		return err
	}
	return nil
}
View Source
var ValidateImage = func(input string) error {
	_, err := reference.ParseDockerRef(input)
	if err != nil {
		return err
	}

	return nil
}
View Source
var ValidateInt = func(input string) error {
	_, err := strconv.Atoi(input)
	if err != nil {
		return err
	}
	return nil
}
View Source
var ValidateNonEmpty = func(input string) error {
	if input == "" {
		return errors.InvalidArgumentErrorf("value cannot be empty")
	}
	return nil
}
View Source
var ValidateSystemName = func(input string) error {
	if l := len(input); l < 3 || l > 63 {
		return errors.InvalidArgumentErrorf("must be between 3 and 63 characters long")
	}

	if !regexp.MustCompile(`^[a-z][a-z0-9-]+[a-z0-9]$`).MatchString(input) {
		return errors.InvalidArgumentErrorf("invalid name; can only contain a-z, 0-9 and '-'")
	}

	return nil
}
View Source
var ValidateURL = func(input string) error {
	_, err := url.Parse(input)
	return err
}

Functions

func FormatField

func FormatField(s string) string

func GetDatabase

func GetDatabase(ctx context.Context, identifier string, nc rig.Client) (*database.Database, string, error)

func GetGroup

func GetGroup(ctx context.Context, identifier string, nc rig.Client) (*group.Group, string, error)

func GetPasswordPrompt

func GetPasswordPrompt(label string) (string, error)

func GetStorageProvider

func GetStorageProvider(ctx context.Context, identifier string, nc rig.Client) (*storage.Provider, string, error)

func GetUser

func GetUser(ctx context.Context, identifier string, nc rig.Client) (*user.User, string, error)

func GetUserAndPasswordUpdates

func GetUserAndPasswordUpdates(username, email, phoneNumber, password string) ([]*user.Update, error)

func GetUserIdentifier

func GetUserIdentifier(username, email, phoneNumber string) (*model.UserIdentifier, error)

func GetUserIdentifierUpdates

func GetUserIdentifierUpdates(username, email, phoneNumber string) ([]*user.Update, error)

func ParseUserIdentifier

func ParseUserIdentifier(identifier string) (*model.UserIdentifier, error)

func ParseUserIdentifierUpdate

func ParseUserIdentifierUpdate(identifier string) (*user.Update, error)

func PromptConfirm

func PromptConfirm(label string, def bool) (bool, error)

func PromptGetInput

func PromptGetInput(label string, validate func(input string) error) (string, error)

func PromptGetInputWithDefault

func PromptGetInputWithDefault(label string, validate func(input string) error, def string) (string, error)

func PromptSelect

func PromptSelect(label string, items []string, hideSelected bool) (int, string, error)

func PromptUserIndentifier

func PromptUserIndentifier() (*model.UserIdentifier, error)

func PromptUserIndentifierUpdate

func PromptUserIndentifierUpdate() (*user.Update, error)

func ProtoToPrettyJson

func ProtoToPrettyJson(m protoreflect.ProtoMessage) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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