helper

package
v1.30.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2023 License: MPL-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RootPassMinimumCharacters = 11
	RootPassMaximumCharacters = 128
)
View Source
const DefaultLinodeURL = "https://api.linode.com"

DefaultLinodeURL is the Linode APIv4 URL to use.

View Source
const (
	LinodeObjectsEndpoint = "https://%s.linodeobjects.com"
)

Variables

View Source
var ValidDatabaseTypes = []string{"mongodb", "postgresql", "mysql"}

Functions

func BuildObjectStorageObjectID

func BuildObjectStorageObjectID(d *schema.ResourceData) string

func CompareIPv6Ranges added in v1.27.2

func CompareIPv6Ranges(i, v string) (bool, error)

func CreateDatabaseEngineSlug added in v1.28.0

func CreateDatabaseEngineSlug(engine, version string) string

func CreateRandomRootPassword added in v1.29.3

func CreateRandomRootPassword() (string, error)

func DomainSecondsDiffSuppressor

func DomainSecondsDiffSuppressor() schema.SchemaDiffSuppressFunc

func ExpandDayOfWeek added in v1.28.0

func ExpandDayOfWeek(day string) (linodego.DatabaseDayOfWeek, error)

func ExpandIntList

func ExpandIntList(list []interface{}) []int

func ExpandIntSet

func ExpandIntSet(set *schema.Set) []int

func ExpandMaintenanceWindow added in v1.28.0

func ExpandMaintenanceWindow(window map[string]interface{}) (linodego.DatabaseMaintenanceWindow, error)

func ExpandStringList

func ExpandStringList(list []interface{}) []string

func ExpandStringSet

func ExpandStringSet(set *schema.Set) []string

func FilterTypeBool added in v1.25.2

func FilterTypeBool(value string) (interface{}, error)

func FilterTypeInt added in v1.25.2

func FilterTypeInt(value string) (interface{}, error)

func FilterTypeString added in v1.25.2

func FilterTypeString(value string) (interface{}, error)

func FlattenDayOfWeek added in v1.28.0

func FlattenDayOfWeek(day linodego.DatabaseDayOfWeek) string

func FlattenMaintenanceWindow added in v1.28.0

func FlattenMaintenanceWindow(window linodego.MySQLDatabaseMaintenanceWindow) map[string]interface{}

func FlattenToInterfaceSlice added in v1.28.0

func FlattenToInterfaceSlice[T any](list []T) []interface{}

func GetCurrentBootedConfig added in v1.29.0

func GetCurrentBootedConfig(ctx context.Context, client *linodego.Client, instID int) (int, error)

GetCurrentBootedConfig gets the config a linode instance is current booted to

func GetDeadlineSeconds added in v1.29.0

func GetDeadlineSeconds(ctx context.Context, d *schema.ResourceData) int

GetDeadlineSeconds gets the seconds remaining until deadline is met.

func GetLatestEvent added in v1.25.0

func GetLatestEvent(ctx context.Context, client *linodego.Client,
	entityID int, entityType linodego.EntityType, action linodego.EventAction,
) (*linodego.Event, error)

GetLatestEvent returns the latest Linode event with the given arguments.

func IsInstanceInBootedState added in v1.29.0

func IsInstanceInBootedState(status linodego.InstanceStatus) bool

IsInstanceInBootedState checks whether an instance is in a booted or booting state

func ListResultToInterface added in v1.28.0

func ListResultToInterface[T any](list []T, err error) ([]interface{}, error)

func RebootInstance

func RebootInstance(ctx context.Context, d *schema.ResourceData, entityID int,
	meta interface{}, bootConfig int,
) diag.Diagnostics

set bootConfig = 0 if using existing boot config

func ResolveValidDBEngine added in v1.28.0

func ResolveValidDBEngine(
	ctx context.Context, client linodego.Client, engine string,
) (*linodego.DatabaseEngine, error)

func S3ConnFromResourceData

func S3ConnFromResourceData(d *schema.ResourceData) *s3.S3

S3ConnFromResourceData builds an S3 client from the linode_object_storage_object resource's access_key, secret_key, and cluster fields.

func TypedSliceToAny added in v1.29.3

func TypedSliceToAny[T any](obj []T) []any

func ValidateIPv6Range added in v1.27.2

func ValidateIPv6Range(i string) error

func WaitForDatabaseUpdated added in v1.28.0

func WaitForDatabaseUpdated(ctx context.Context, client linodego.Client, dbID int,
	dbType linodego.DatabaseEngineType, minStart *time.Time, timeoutSeconds int,
) error

Types

type Config

type Config struct {
	AccessToken string
	APIURL      string
	APIVersion  string
	UAPrefix    string

	ConfigPath    string
	ConfigProfile string

	TerraformVersion string

	SkipInstanceReadyPoll        bool
	SkipInstanceDeletePoll       bool
	DisableInternalCache         bool
	MinRetryDelayMilliseconds    int
	MaxRetryDelayMilliseconds    int
	EventPollMilliseconds        int
	LKEEventPollMilliseconds     int
	LKENodeReadyPollMilliseconds int
}

Config represents the Linode provider configuration.

func (*Config) Client

func (c *Config) Client() (*linodego.Client, error)

Client returns a fully initialized Linode client.

type FilterAttribute added in v1.25.2

type FilterAttribute struct {
	// Whether this field can be filtered on at an API level.
	// If false, this filter will be handled on the client.
	APIFilterable bool

	// Converts the filter string to the correct type.
	TypeFunc FilterTypeFunc
}

FilterAttribute stores various configuration options about a single filterable field.

type FilterConfig added in v1.25.2

type FilterConfig map[string]FilterAttribute

FilterConfig stores a map of FilterAttributes for a resource.

func (FilterConfig) ConstructFilterString added in v1.25.2

func (f FilterConfig) ConstructFilterString(d *schema.ResourceData) (string, error)

ConstructFilterString constructs a Linode filter JSON string from each filter element in the schema

func (FilterConfig) FilterDataSource added in v1.25.2

func (f FilterConfig) FilterDataSource(
	ctx context.Context,
	d *schema.ResourceData,
	meta interface{},
	listFunc FilterListFunc,
	flattenFunc FilterFlattenFunc,
) ([]map[string]interface{}, error)

FilterDataSource should be run from inside the ReadContext function of a data source.

func (FilterConfig) FilterLatest added in v1.25.2

func (f FilterConfig) FilterLatest(d *schema.ResourceData, items []map[string]interface{}) []map[string]interface{}

FilterLatest returns only the latest element in the given slice only if `latest` == true.

func (FilterConfig) FilterLatestVersion added in v1.27.0

func (f FilterConfig) FilterLatestVersion(d *schema.ResourceData,
	items []map[string]interface{},
) ([]map[string]interface{}, error)

FilterLatestVersion returns only the latest element in the given slice only if `latest` == true.

func (FilterConfig) FilterResults added in v1.25.2

func (f FilterConfig) FilterResults(
	d *schema.ResourceData,
	items []interface{},
) ([]map[string]interface{}, error)

FilterResults filters the given results on the client-side filters present in the resource.

func (FilterConfig) FilterSchema added in v1.25.2

func (f FilterConfig) FilterSchema() *schema.Schema

FilterSchema should be referenced in a schema configuration in order to enable filter functionality

func (FilterConfig) GetFilterID added in v1.25.2

func (f FilterConfig) GetFilterID(d *schema.ResourceData) (string, error)

GetFilterID creates a unique ID specific to the current filter data source

func (FilterConfig) GetLatestCreated added in v1.25.2

func (f FilterConfig) GetLatestCreated(data []map[string]interface{}) map[string]interface{}

GetLatestCreated returns only the latest element in the given slice.

func (FilterConfig) GetLatestVersion added in v1.27.0

func (f FilterConfig) GetLatestVersion(data []map[string]interface{}) (map[string]interface{}, error)

GetLatestVersion returns only the latest version string (e.g. `8.0.26`) in the given slice.

func (FilterConfig) GetValidFilters added in v1.25.2

func (f FilterConfig) GetValidFilters(apiOnly bool) []string

GetValidFilters returns a slice of valid filters for the filter config.

func (FilterConfig) OrderBySchema added in v1.25.2

func (f FilterConfig) OrderBySchema() *schema.Schema

OrderBySchema should be referenced in a schema configuration in order to enable filter ordering functionality

func (FilterConfig) OrderSchema added in v1.25.2

func (f FilterConfig) OrderSchema() *schema.Schema

func (FilterConfig) ValidateDiagFunc added in v1.25.2

func (f FilterConfig) ValidateDiagFunc(apiOnly bool) schema.SchemaValidateDiagFunc

ValidateDiagFunc should be plugged into the `filter` field of a filterable data source.

type FilterFlattenFunc added in v1.25.2

type FilterFlattenFunc func(object interface{}) map[string]interface{}

FilterFlattenFunc flattens an object into a map[string]interface{}.

type FilterListFunc added in v1.25.2

type FilterListFunc func(context.Context, *schema.ResourceData,
	*linodego.Client, *linodego.ListOptions) ([]interface{}, error)

FilterListFunc wraps a linodego list function.

type FilterTypeFunc

type FilterTypeFunc func(value string) (interface{}, error)

FilterTypeFunc is a function that takes in a filter name and value, and returns the value converted to the correct filter type.

type ProviderMeta

type ProviderMeta struct {
	Client linodego.Client
	Config *Config
}

Jump to

Keyboard shortcuts

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