crud

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: May 1, 2017 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FiveMinutes    time.Duration = 5 * time.Minute
	TwoHours       time.Duration = 120 * time.Minute
	DefaultTimeout               = &schema.ResourceTimeout{
		Create: &FiveMinutes,
		Update: &FiveMinutes,
		Delete: &FiveMinutes,
	}
)

Functions

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 FilterMissingResourceError added in v1.0.8

func FilterMissingResourceError(sync ResourceVoider, err *error)

func ReadResource

func ReadResource(sync ResourceReader) (e error)

func UpdateResource

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

Types

type BaseCrud

type BaseCrud struct {
	D      *schema.ResourceData
	Client client.BareMetalClient
}

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 ExtraWaitPostDelete added in v1.0.2

type ExtraWaitPostDelete interface {
	ExtraWaitPostDelete() 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 IdentitySync

type IdentitySync struct{}

func (*IdentitySync) CreatedPending

func (s *IdentitySync) CreatedPending() []string

func (*IdentitySync) CreatedTarget

func (s *IdentitySync) CreatedTarget() []string

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

Jump to

Keyboard shortcuts

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