datasource

package
v2.41.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTooManyResults = &TooManyResultsError{}

Functions

func AddOptionalFieldsToSchema

func AddOptionalFieldsToSchema(schema map[string]*schema.Schema, keys ...string)

AddOptionalFieldsToSchema

code imported from Google's terraform provider. source: https://github.com/hashicorp/terraform-provider-google/blob/main/google/tpgresource/datasource_helpers.go

func FindExact added in v2.39.0

func FindExact[T any](slice []T, finder func(T) bool, searchName string) (T, error)

FindExact finds the first element in 'slice' matching the condition defined by 'finder'. It returns the first matching element and an error if either no match is found or multiple matches are found.

func FixDatasourceSchemaFlags

func FixDatasourceSchemaFlags(schema map[string]*schema.Schema, required bool, keys ...string)

FixDatasourceSchemaFlags is a convenience func that toggles the Computed, Optional + Required flags on a schema element. This is useful when the schema has been generated (using `datasourceSchemaFromResourceSchema` above for example) and therefore the attribute flags were not set appropriately when first added to the schema definition. Currently only supports top-level schema elements.

code imported from Google's terraform provider. source: https://github.com/hashicorp/terraform-provider-google/blob/main/google/tpgresource/datasource_helpers.go

func NewRegionalID

func NewRegionalID(idI interface{}, fallBackRegion scw.Region) string

func NewZonedID

func NewZonedID(idI interface{}, fallBackZone scw.Zone) string

func SchemaFromResourceSchema

func SchemaFromResourceSchema(rs map[string]*schema.Schema) map[string]*schema.Schema

SchemaFromResourceSchema is a recursive func that converts an existing Resource schema to a Datasource schema. All schema elements are copied, but certain attributes are ignored or changed: - all attributes have Computed = true - all attributes have ForceNew, Required = false - Validation funcs and attributes (e.g. MaxItems) are not copied

code imported from Google's terraform provider. source: https://github.com/hashicorp/terraform-provider-google/blob/main/google/tpgresource/datasource_helpers.go

func SingularDataSourceFindError added in v2.39.0

func SingularDataSourceFindError(resourceType string, err error) error

SingularDataSourceFindError returns a standard error message for a singular data source's non-nil resource find error.

Types

type TooManyResultsError added in v2.39.0

type TooManyResultsError struct {
	Count       int
	LastRequest interface{}
}

func (*TooManyResultsError) As added in v2.39.0

func (e *TooManyResultsError) As(target interface{}) bool

func (*TooManyResultsError) Error added in v2.39.0

func (e *TooManyResultsError) Error() string

func (*TooManyResultsError) Is added in v2.39.0

func (e *TooManyResultsError) Is(err error) bool

Jump to

Keyboard shortcuts

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