ibm

package
v0.0.0-...-ae4be4e Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2021 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//ResourceControllerURL ...
	ResourceControllerURL = "resource_controller_url"
	//ResourceName ...
	ResourceName = "resource_name"
	//ResourceCRN ...
	ResourceCRN = "resource_crn"
	//ResourceStatus ...
	ResourceStatus = "resource_status"
	//ResourceGroupName ...
	ResourceGroupName = "resource_group_name"
	//RelatedCRN ...
	RelatedCRN = "related_crn"
)
View Source
const RetryAPIDelay = 5 * time.Second

RetryDelay

Variables

This section is empty.

Functions

func GetNext

func GetNext(next interface{}) string

GetNext ...

func HashInt

func HashInt(v interface{}) int

HashInt ...

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 Provider

func Provider() *schema.Provider

Provider returns a *schema.Provider.

Types

type ClientSession

type ClientSession interface {
	BluemixUserDetails() (*UserConfig, error)
	ResourceManagementAPIv2() (managementv2.ResourceManagementAPIv2, error)
}

ClientSession ...

type Config

type Config struct {
	//BluemixAPIKey is the Bluemix api key
	BluemixAPIKey string
	//Bluemix region
	Region string
	//Resource group id
	ResourceGroup string
	//Bluemix API timeout
	BluemixTimeout time.Duration

	//Retry Count for API calls
	//Unexposed in the schema at this point as they are used only during session creation for a few calls
	//When sdk implements it we an expose them for expected behaviour
	//https://github.com/softlayer/softlayer-go/issues/41
	RetryCount int
	//Constant Retry Delay for API calls
	RetryDelay time.Duration
}

Config stores user provider input

func (*Config) ClientSession

func (c *Config) ClientSession() (interface{}, error)

ClientSession configures and returns a fully initialized ClientSession

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
	ValidateAllowedStringValue
	StringLenBetween
	ValidateRegexpLen
	ValidateRegexp
)

func (FunctionIdentifier) String

func (i FunctionIdentifier) String() string

Use stringer tool to generate this later.

type Map

type Map map[string]string

Map is a wrapper around map[string]string that provides some helpers above it that assume the map is in the format that flatmap expects (the result of Flatten).

All modifying functions such as Delete are done in-place unless otherwise noted.

func Flatten

func Flatten(thing map[string]interface{}) Map

Flatten takes a structure and turns into a flat map[string]string.

Within the "thing" parameter, only primitive values are allowed. Structs are not supported. Therefore, it can only be slices, maps, primitives, and any combination of those together.

See the tests for examples of what inputs are turned into.

func (Map) Contains

func (m Map) Contains(key string) bool

Contains returns true if the map contains the given key.

func (Map) Delete

func (m Map) Delete(prefix string)

Delete deletes a key out of the map with the given prefix.

func (Map) Keys

func (m Map) Keys() []string

Keys returns all of the top-level keys in this map

func (Map) Merge

func (m Map) Merge(m2 Map)

Merge merges the contents of the other Map into this one.

This merge is smarter than a simple map iteration because it will fully replace arrays and other complex structures that are present in this map with the other map's. For example, if this map has a 3 element "foo" list, and m2 has a 2 element "foo" list, then the result will be that m has a 2 element "foo" list.

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 Session

type Session struct {
	// BluemixSession is the the Bluemix session used to connect to the Bluemix API
	BluemixSession *bxsession.Session
}

Session stores the information required for communication with the SoftLayer and Bluemix API

type UserConfig

type UserConfig struct {
	// contains filtered or unexported fields
}

UserConfig ...

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, validateAllowedIntValue, validateAllowedStringValue
	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
}

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
}

func Validator

func Validator() ValidatorDict

Validator return validator

type ValueConstraintType

type ValueConstraintType int

Type of constraints required for validation

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

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