Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateRandomString(length int, charset string) string
- func GetUUIDPtrToStrPtr(id *uuid.UUID) *string
- func InsertPhoneHomeIntoUserData(documentRoot *yaml.Node, url string) error
- func IsEmptyStrPtr(s *string) bool
- func IsNilOrEmptyStrPtr(s *string) bool
- func ProtobufLabelsFromAPILabels(labels map[string]string) []*cwssaws.Label
- func RemovePhoneHomeFromUserData(documentRoot *yaml.Node, url *string) error
- func ValidateLabels(labels map[string]string) error
- func ValidateNameCharacters(value interface{}) error
- func ValidateNested(target interface{}, fieldRules ...*validation.FieldRules) *validation.FieldRules
Constants ¶
const ( // configuration for phone home SitePhoneHomeName = "phone_home" SitePhoneHomePost = "POST" SitePhoneHomePostAll = "all" SitePhoneHomeUrl = "url" SiteCloudConfig = "#cloud-config" )
Variables ¶
var ( LeadingWhitespaceRegexp = regexp.MustCompile("^\\s+.*") TrailingWhitespaceRegexp = regexp.MustCompile(".*\\s+$") NotAllWhitespaceRegexp = regexp.MustCompile("[^\\s]+") ShaHashRegex = regexp.MustCompile("^[A-Fa-f0-9]+$") DiskImagePathRegex = regexp.MustCompile("^/dev/(:?nvme\\d+n\\d+|sd*)") ValidationErrorExpectStringType = errors.New("expect name field to be string type") ValidationErrorNameHasLeadingWhitespace = errors.New("name field has leading whitespace") ValidationErrorNameHasTrailingWhitespace = errors.New("name field has trailing whitespace") ValidationErrorNameFieldIsEmpty = errors.New("name field is empty") ValidationErrorOnlyWhitespace = errors.New("field consists only of whitespace") // Label restrictions LabelKeyMaxLength = 255 LabelValueMaxLength = 255 LabelCountMax = 10 // Label validation error messages ErrValidationLabelKeyEmpty = errors.New("one or more labels do not have a key specified") ErrValidationLabelKeyLength = fmt.Errorf("label key must contain at least 1 character and a maximum of %v characters", LabelKeyMaxLength) ErrValidationLabelValueLength = fmt.Errorf("label value cannot exceed a maximum of %v characters", LabelValueMaxLength) ErrValidationLabelCount = fmt.Errorf("up to %v key/value pairs can be specified in labels", LabelCountMax) )
var (
CharsetAlphaNumeric = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
)
var TestCommonCloudInit = `` /* 1890-byte string literal not displayed */
var TestCommonInvalidCloudInit = `` /* 1948-byte string literal not displayed */
var TestCommonPhoneHomeCloudInit = `` /* 151-byte string literal not displayed */
var TestCommonPhoneHomeOnlyCloudInit = `#cloud-config
phone_home:
url: http://169.254.169.254:7777/latest/meta-data/phone_home
post: all`
var TestCommonPhoneHomeSegment = `
phone_home:
empty_key_for_validation:
url: http://localhost
post: all`
var TestCommonXMLUserData = `` /* 392-byte string literal not displayed */
Functions ¶
func GenerateRandomString ¶
GenerateRandomString generates a random string of a given length from a specified character set.
func GetUUIDPtrToStrPtr ¶
util.GetUUIDPtrToStrPtr is a utility function to return string pointer from uuid pointer
func IsEmptyStrPtr ¶
IsEmptyStrPtr is a utility function to check if the underlying value of a string pointer is empty
func IsNilOrEmptyStrPtr ¶
IsNilOrEmptyStrPtr is a utility function to check if the string pointer is nil or the underlying value is empty
func ProtobufLabelsFromAPILabels ¶
ProtobufLabelsFromAPILabels converts API labels (map[string]string) to protobuf labels ([]*cwssaws.Label)
func RemovePhoneHomeFromUserData ¶
Walks through the yaml nodes looking for a cloud-init phone-home block If `url` is nil, then any phone-home block found will be removed. If `url` is non-nil, then the phone-home block will only be removed if if the URL matches the value of `url`
func ValidateLabels ¶ added in v1.3.0
ValidateLabels validates optional API label maps (count, keys, values). Returns nil when labels is nil.
func ValidateNameCharacters ¶
func ValidateNameCharacters(value interface{}) error
ValidateNameCharacters is a utility function to lexically validate the name field currently checks for leading or trailing whitespaces could evolve in the future, if there are more constraints
func ValidateNested ¶
func ValidateNested(target interface{}, fieldRules ...*validation.FieldRules) *validation.FieldRules
ValidateNested is a utility function to validate nested struct
Types ¶
This section is empty.