validate

package
v1.71.3 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InvokeDataSourceValidator

func InvokeDataSourceValidator(resourceName, identifier string) schema.SchemaValidateFunc

func InvokeValidator

func InvokeValidator(resourceName, identifier string) schema.SchemaValidateFunc

This is the main validation function. This function will be used in all the provider code.

func IsSecurityGroupAddress

func IsSecurityGroupAddress(s string) bool

func IsSecurityGroupCIDR

func IsSecurityGroupCIDR(s string) bool

func SetValidatorDict

func SetValidatorDict(v ValidatorDict)

func ValidBucketLifecycleTimestamp

func ValidBucketLifecycleTimestamp(v interface{}, k string) (ws []string, errors []error)

func ValidateAllowedEnterpriseNameValue

func ValidateAllowedEnterpriseNameValue() schema.SchemaValidateFunc

func ValidateAllowedIntValues

func ValidateAllowedIntValues(is []int) schema.SchemaValidateFunc

func ValidateAllowedPolicyType added in v1.48.0

func ValidateAllowedPolicyType(policyType []string) schema.SchemaValidateFunc

func ValidateAllowedRangeInt

func ValidateAllowedRangeInt(start, end int) schema.SchemaValidateFunc

func ValidateAllowedStringValues

func ValidateAllowedStringValues(validValues []string) schema.SchemaValidateFunc

func ValidateAuthProtocol

func ValidateAuthProtocol(v interface{}, k string) (ws []string, errors []error)

func ValidateCIDR

func ValidateCIDR(v interface{}, k string) (ws []string, errors []error)

ValidateCIDR...

func ValidateDatacenterOption

func ValidateDatacenterOption(v []interface{}, allowedValues []string) error

func ValidateDayOfWeek

func ValidateDayOfWeek(v interface{}, k string) (ws []string, errors []error)

func ValidateDiffieHellmanGroup

func ValidateDiffieHellmanGroup(v interface{}, k string) (ws []string, errors []error)

func ValidateDomainName

func ValidateDomainName(v interface{}, k string) (ws []string, errors []error)

func ValidateEncyptionProtocol

func ValidateEncyptionProtocol(v interface{}, k string) (ws []string, errors []error)

func ValidateHour

func ValidateHour(start, end int) func(v interface{}, k string) (ws []string, errors []error)

func ValidateIP

func ValidateIP(v interface{}, k string) (ws []string, errors []error)

ValidateIP...

func ValidateIPVersion

func ValidateIPVersion(v interface{}, k string) (ws []string, errors []error)

ValidateIPVersion

func ValidateISName

func ValidateISName(v interface{}, k string) (ws []string, errors []error)

ValidateISName

func ValidateInterval

func ValidateInterval(v interface{}, k string) (ws []string, errors []error)

func ValidateKeyLifeTime

func ValidateKeyLifeTime(v interface{}, k string) (ws []string, errors []error)

func ValidateLBListenerConnectionLimit

func ValidateLBListenerConnectionLimit(v interface{}, k string) (ws []string, errors []error)

func ValidateLBListenerPolicyPriority

func ValidateLBListenerPolicyPriority(v interface{}, k string) (ws []string, errors []error)

func ValidateLBListenerPort

func ValidateLBListenerPort(v interface{}, k string) (ws []string, errors []error)

func ValidateLBTimeout

func ValidateLBTimeout(v interface{}, k string) (ws []string, errors []error)

func ValidateMaxConn

func ValidateMaxConn(v interface{}, k string) (ws []string, errors []error)

func ValidateMaxRetries

func ValidateMaxRetries(v interface{}, k string) (ws []string, errors []error)

func ValidateMinute

func ValidateMinute(start, end int) func(v interface{}, k string) (ws []string, errors []error)

func ValidateNotes

func ValidateNotes(v interface{}, k string) (ws []string, errors []error)

func ValidatePortRange

func ValidatePortRange(start, end int) func(v interface{}, k string) (ws []string, errors []error)

func ValidatePublicBandwidth

func ValidatePublicBandwidth(v interface{}, k string) (ws []string, errors []error)

func ValidateRegexps

func ValidateRegexps(regex string) schema.SchemaValidateFunc

func ValidateRemoteIP

func ValidateRemoteIP(v interface{}, k string) (ws []string, errors []error)

ValidateRemoteIP...

func ValidateRoutePath

func ValidateRoutePath(v interface{}, k string) (ws []string, errors []error)

func ValidateRoutePort

func ValidateRoutePort(v interface{}, k string) (ws []string, errors []error)

func ValidateScheduleType

func ValidateScheduleType(v interface{}, k string) (ws []string, errors []error)

func ValidateSecondaryIPCount

func ValidateSecondaryIPCount(v interface{}, k string) (ws []string, errors []error)

func ValidateSecurityRuleDirection

func ValidateSecurityRuleDirection(v interface{}, k string) (ws []string, errors []error)

func ValidateSecurityRuleEtherType

func ValidateSecurityRuleEtherType(v interface{}, k string) (ws []string, errors []error)

func ValidateSecurityRuleProtocol

func ValidateSecurityRuleProtocol(v interface{}, k string) (ws []string, errors []error)

func ValidateSizePerZone

func ValidateSizePerZone(v interface{}, k string) (ws []string, errors []error)

func ValidateStorageType

func ValidateStorageType(v interface{}, k string) (ws []string, errors []error)

func ValidateStringLength

func ValidateStringLength(v interface{}, k string) (ws []string, errors []error)

func ValidateTimeout

func ValidateTimeout(v interface{}, k string) (ws []string, errors []error)

func ValidateURLPath

func ValidateURLPath(v interface{}, k string) (ws []string, errors []error)

func ValidateUTCFormat added in v1.70.0

func ValidateUTCFormat(v interface{}, k string) (ws []string, errors []error)

func ValidateVLANName

func ValidateVLANName(v interface{}, k string) (ws []string, errors []error)

func ValidateWeight

func ValidateWeight(v interface{}, k string) (ws []string, errors []error)

func ValidateWorkerNum

func ValidateWorkerNum(v interface{}, k string) (ws []string, errors []error)

func Validatekeylife

func Validatekeylife(v interface{}, k string) (ws []string, errors []error)

Types

type FunctionIdentifier

type FunctionIdentifier int

ValidateFunc is honored only when the schema's Type is set to TypeInt, TypeFloat, TypeString, TypeBool, or TypeMap. It is ignored for all other types. enum to list all the validator functions supported by this tool.

const (
	IntBetween FunctionIdentifier = iota
	IntAtLeast
	IntAtMost
	ValidateAllowedStringValue
	StringLenBetween
	ValidateIPorCIDR
	ValidateCIDRAddress
	ValidateAllowedIntValue
	ValidateRegexpLen
	ValidateRegexp
	ValidateNoZeroValues
	ValidateJSONString
	ValidateJSONParam
	ValidateBindedPackageName
	ValidateOverlappingAddress
	ValidateCloudData
)

func (FunctionIdentifier) MarshalText

func (f FunctionIdentifier) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

Without this function, when FunctionalIdentifier is marshaled, it prints 0,1,2.. instead
of printing IntBetween, IntAtLeast, IntAtMost.. in JSON Output

func (FunctionIdentifier) String

func (i FunctionIdentifier) String() string

Use stringer tool to generate this later.

type ResourceValidator

type ResourceValidator struct {
	// This is the resource name - Found in provider.go of IBM Terraform provider.
	// Ex: ibm_compute_monitor, ibm_compute_bare_metal, ibm_compute_dedicated_host, ibm_cis_global_load_balancer etc.,
	ResourceName string

	// Array of validator objects. Each object refers to one parameter in the resource provider.
	Schema []ValidateSchema
}

type ValidateSchema

type ValidateSchema struct {

	//This is the parameter name.
	//Ex: private_subnet in ibm_compute_bare_metal resource
	Identifier string

	// this is similar to schema.ValueType
	Type ValueType

	// The actual validation function that needs to be invoked.
	// Ex: IntBetween, ValidateAllowedIntValues, ValidateAllowedStringValues
	ValidateFunctionIdentifier FunctionIdentifier

	MinValue       string
	MaxValue       string
	AllowedValues  string //Comma separated list of strings.
	Matches        string
	Regexp         string
	MinValueLength int
	MaxValueLength int

	// Is this nullable
	Nullable bool

	Optional       bool
	Required       bool
	Default        interface{}
	ForceNew       bool
	CloudDataType  string
	CloudDataRange []string
}

Schema is used to describe the validation schema.

func (ValidateSchema) GetValue

func (vs ValidateSchema) GetValue(valueConstraint ValueConstraintType) interface{}

utility functions - Move to different package

func (ValidateSchema) Zero

func (vs ValidateSchema) Zero() interface{}

Zero returns the zero value for a type.

type ValidatorDict

type ValidatorDict struct {
	ResourceValidatorDictionary   map[string]*ResourceValidator
	DataSourceValidatorDictionary map[string]*ResourceValidator
}

type ValueConstraintType

type ValueConstraintType int

Type of constraints required for validation

const (
	MinValue ValueConstraintType = iota
	MaxValue
	MinValueLength
	MaxValueLength
	AllowedValues
	MatchesValue
)

func (ValueConstraintType) MarshalText

func (vct ValueConstraintType) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (ValueConstraintType) String

func (i ValueConstraintType) String() string

Use Stringer tool to generate this later.

type ValueType

type ValueType int

ValueType -- Copied from Terraform for now. You can refer to Terraform ValueType directly. ValueType is an enum of the type that can be represented by a schema.

const (
	TypeInvalid ValueType = iota
	TypeBool
	TypeInt
	TypeFloat
	TypeString
)

func (ValueType) MarshalText

func (vt ValueType) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (ValueType) String

func (i ValueType) String() string

Use Stringer tool to generate this later.

Jump to

Keyboard shortcuts

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