crud

package
v2.1.17+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2018 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FAILED = "FAILED"
)

Variables

View Source
var (
	FifteenMinutes               = 15 * time.Minute
	TwoHours                     = 120 * time.Minute
	ZeroTime       time.Duration = 0

	DefaultTimeout = &schema.ResourceTimeout{
		Create: &FifteenMinutes,
		Update: &FifteenMinutes,
		Delete: &FifteenMinutes,
	}
)

Functions

func CreateDBSystemResource added in v1.0.15

func CreateDBSystemResource(d *schema.ResourceData, sync ResourceCreator) (e error)

func CreateResource

func CreateResource(d *schema.ResourceData, sync ResourceCreator) (e error)

func DeleteResource

func DeleteResource(d *schema.ResourceData, sync ResourceDeleter) (e error)

DeleteResource requests a Delete(). If the resource deletes statefully (not immediately), poll State to ensure: () -> Pending -> Deleted. Finally, sets the ResourceData state to empty.

func EqualIgnoreCaseSuppressDiff

func EqualIgnoreCaseSuppressDiff(key string, old string, new string, d *schema.ResourceData) bool

func FieldDeprecated

func FieldDeprecated(deprecatedFieldName string) string

func FieldDeprecatedAndOverridenByAnother

func FieldDeprecatedAndOverridenByAnother(deprecatedFieldName string, newFieldName string) string

func FieldDeprecatedForAnother

func FieldDeprecatedForAnother(deprecatedFieldName string, newFieldName string) string

func FilterMissingResourceError added in v1.0.8

func FilterMissingResourceError(sync ResourceVoider, err *error)

func GenerateDataSourceID

func GenerateDataSourceID() string

GenerateDataSourceID generates an ID for the data source based on the current time stamp.

func LoadBalancerResourceGet added in v1.0.11

func LoadBalancerResourceGet(client *oci_load_balancer.LoadBalancerClient, d *schema.ResourceData, wr *oci_load_balancer.WorkRequest, retryPolicy *oci_common.RetryPolicy) (id string, stillWorking bool, err error)

func LoadBalancerResourceID added in v1.0.11

func LoadBalancerResourceID(res interface{}, workReq *oci_load_balancer.WorkRequest) (id *string, workReqSucceeded bool)

func LoadBalancerWaitForWorkRequest added in v1.0.13

func LoadBalancerWaitForWorkRequest(client *oci_load_balancer.LoadBalancerClient, d *schema.ResourceData, wr *oci_load_balancer.WorkRequest, retryPolicy *oci_common.RetryPolicy) error

func NormalizeBoolString

func NormalizeBoolString(v string) (string, error)

NormalizeBoolString parses a string value into a bool value, and if successful, formats it back into a string & throws an error otherwise. This allows for normalizing the different formats of valid bool strings (e.g. "1", "false", "TRUE", "F", etc.) to a uniform string representation of a boolean value ("true" & "false").

func ReadResource

func ReadResource(sync ResourceReader) (e error)

func SetToStrings

func SetToStrings(volumeIdsSet *schema.Set) []string

SetToString encodes an *schema.Set into an []string honoring the structure for the schema

func StringsToSet

func StringsToSet(ss []string) *schema.Set

stringsToSet encodes an []string into a *schema.Set in the appropriate structure for the schema

func UpdateResource

func UpdateResource(d *schema.ResourceData, sync ResourceUpdater) (e error)

func WaitForResourceCondition

func WaitForResourceCondition(s ResourceFetcher, resourceChangedFunc func() bool, timeout time.Duration) error

WaitForResourceCondition polls on a resource, waiting for it to reach a specified condition. This is done with exponential backoff. The terminating condition is specified as a boolean function; and this will return a timeout error if the specified condition isn't reached within the specified timeout period.

Types

type BaseCrud

type BaseCrud struct {
	D     *schema.ResourceData
	Mutex *sync.Mutex
}

func (*BaseCrud) State added in v1.0.3

func (s *BaseCrud) State() string

Default implementation pulls state off of the schema

func (*BaseCrud) VoidState

func (s *BaseCrud) VoidState()

type ExtraWaitPostCreateDelete added in v1.0.11

type ExtraWaitPostCreateDelete interface {
	ExtraWaitPostCreateDelete() time.Duration
}

Some resources in the oracle API are removed asynchronously, so even after they claim to be gone, other dependencies haven't been notified of that fact. This facility allows us to add an artificial delay for resources that need a little time to let the oracle API backend catch up with reality.

type ResourceCreator

type ResourceCreator interface {
	ResourceDataWriter
	// ID identifies the resource, or a work request to create the resource.
	ID() string
	Create() error
}

ResourceCreator may create a BareMetal resource and populate into ResourceData state by using CreateResource()

type ResourceDataWriter

type ResourceDataWriter interface {
	ResourceVoider
	// SetData populates ResourceData state from current
	// BareMetal resource
	SetData()
}

ResourceDataWriter populates ResourceData state from the current BareMetal resource

type ResourceDeleter

type ResourceDeleter interface {
	ResourceVoider
	// ID identifies the resource, or a work request to create the resource.
	ID() string
	Delete() error
}

Deletes a BareMetal entity

type ResourceFetcher

type ResourceFetcher interface {
	// Get should update the s.Resource, and is used by crud.ReadResource() to populate s.D
	// Get() may expect s.D.Id() to be set, but not s.Resource, or anything else in s.D
	Get() error
}

Gets the current BareMetal Resource

type ResourceReader

type ResourceReader interface {
	ResourceFetcher
	ResourceDataWriter
}

ResourceReader get BareMetal Resource and updated ResourceData

type ResourceUpdater

type ResourceUpdater interface {
	ResourceDataWriter
	Update() error
}

Updates a BareMetal entity to match ResourceData

type ResourceVoider

type ResourceVoider interface {
	// VoidState sets ResourceData ID to "". To be called when
	// the resource is gone.
	VoidState()
}

ResourceVoider may set its ResourceData state to empty.

type StatefulResource

type StatefulResource interface {
	ResourceReader
	State() string
	// contains filtered or unexported methods
}

type StatefullyCreatedResource

type StatefullyCreatedResource interface {
	StatefulResource
	CreatedPending() []string
	CreatedTarget() []string
}

type StatefullyDeletedResource

type StatefullyDeletedResource interface {
	StatefulResource
	DeletedPending() []string
	DeletedTarget() []string
}

type StatefullyUpdatedResource added in v1.0.13

type StatefullyUpdatedResource interface {
	StatefulResource
	UpdatedPending() []string
	UpdatedTarget() []string
}

type SynchronizedResource

type SynchronizedResource interface {
	GetMutex() *sync.Mutex
}

This provides a mechanism for synchronizing CRUD operations from different resources that may concurrently modify the same resource. Implementing these interfaces will cause the Create/Update/Delete operations to wait on the lock before starting those operations.

Jump to

Keyboard shortcuts

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