resource

package
v0.16.3 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2018 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AssetSig          = "c44067f5952c0a294b673a41bacd8c17" // a randomly assigned type hash for assets.
	AssetHashProperty = "hash"                             // the dynamic property for an asset's hash.
	AssetTextProperty = "text"                             // the dynamic property for an asset's text.
	AssetPathProperty = "path"                             // the dynamic property for an asset's path.
	AssetURIProperty  = "uri"                              // the dynamic property for an asset's URI.
)
View Source
const (
	ArchiveSig            = "0def7320c3a5731c473e5ecbe6d01bc7" // a randomly assigned archive type signature.
	ArchiveHashProperty   = "hash"                             // the dynamic property for an archive's hash.
	ArchiveAssetsProperty = "assets"                           // the dynamic property for an archive's assets.
	ArchivePathProperty   = "path"                             // the dynamic property for an archive's path.
	ArchiveURIProperty    = "uri"                              // the dynamic property for an archive's URI.
)
View Source
const (
	NotArchive     = iota // not an archive.
	TarArchive            // a POSIX tar archive.
	TarGZIPArchive        // a POSIX tar archive that has been subsequently compressed using GZip.
	ZIPArchive            // a multi-file ZIP archive.
)
View Source
const (
	URNPrefix        = "urn:" + URNNamespaceID + ":" // the standard URN prefix
	URNNamespaceID   = "pulumi"                      // the URN namespace
	URNNameDelimiter = "::"                          // the delimiter between URN name elements
	URNTypeDelimiter = "$"                           // the delimiter between URN type elements
)
View Source
const RootStackType tokens.Type = "pulumi:pulumi:Stack"

RootStackType is the type name that will be used for the root component in the Pulumi resource tree.

View Source
const SigKey = PropertyKey("4dabf18193072939515e22adb298388d")

SigKey is sometimes used to encode type identity inside of a map. This is required when flattening into ordinary maps, like we do when performing serialization, to ensure recoverability of type identities later on.

Variables

View Source
var ArchiveExts = map[string]ArchiveFormat{
	".tar":    TarArchive,
	".tgz":    TarGZIPArchive,
	".tar.gz": TarGZIPArchive,
	".zip":    ZIPArchive,
}

ArchiveExts maps from a file extension and its associated archive and/or compression format.

Functions

func HasSig

func HasSig(obj PropertyMap, match string) bool

HasSig checks to see if the given property map contains the specific signature match.

func IDStrings

func IDStrings(ids []ID) []string

IDStrings turns an array of resource IDs into an array of strings.

func IsReqError

func IsReqError(err error) bool

func NewErrors

func NewErrors(errs []error) error

NewErrors creates a new error list pertaining to a resource. Note that it just turns around and defers to the same mapping infrastructure used for serialization and deserialization, but it presents a nicer interface.

func NewPropertyError

func NewPropertyError(typ string, property string, err error) error

NewPropertyError creates a new error pertaining to a resource's property. Note that it just turns around and defers to the same mapping infrastructure used for serialization and deserialization, but it presents a nicer interface.

func NewUniqueHex

func NewUniqueHex(prefix string, randlen, maxlen int) (string, error)

NewUniqueHex generates a new "random" hex string for use by resource providers. It will take the optional prefix and append randlen random characters (defaulting to 8 if not > 0). The result must not exceed maxlen total characterss (if > 0). Note that capping to maxlen necessarily increases the risk of collisions.

Types

type Archive

type Archive struct {
	Sig    string                 `json:"4dabf18193072939515e22adb298388d" yaml:"4dabf18193072939515e22adb298388d"` // the unique asset signature (see properties.go).
	Hash   string                 `json:"hash,omitempty" yaml:"hash,omitempty"`                                     // the SHA256 hash of the archive contents.
	Assets map[string]interface{} `json:"assets,omitempty" yaml:"assets,omitempty"`                                 // a collection of other assets/archives.
	Path   string                 `json:"path,omitempty" yaml:"path,omitempty"`                                     // a file on the current filesystem.
	URI    string                 `json:"uri,omitempty" yaml:"uri,omitempty"`                                       // a remote URI (file://, http://, https://, etc).
}

Archive is a serialized archive reference. It is a union: thus, only one of its fields will be non-nil. Several helper routines exist as members in order to easily interact with archives of different kinds. nolint: lll

func DeserializeArchive

func DeserializeArchive(obj map[string]interface{}) (*Archive, bool, error)

DeserializeArchive checks to see if the map contains an archive, using its signature, and if so deserializes it.

func NewAssetArchive

func NewAssetArchive(assets map[string]interface{}) (*Archive, error)

func NewPathArchive

func NewPathArchive(path string) (*Archive, error)

func NewURIArchive

func NewURIArchive(uri string) (*Archive, error)

func (*Archive) Archive

func (a *Archive) Archive(format ArchiveFormat, w io.Writer) error

Archive produces a single archive stream in the desired format. It prefers to return the archive with as little copying as is feasible, however if the desired format is different from the source, it will need to translate.

func (*Archive) Bytes

func (a *Archive) Bytes(format ArchiveFormat) ([]byte, error)

Bytes fetches the archive contents as a byte slices. This is almost certainly the least efficient way to deal with the underlying streaming capabilities offered by assets and archives, but can be used in a pinch to interact with APIs that demand []bytes.

func (*Archive) EnsureHash

func (a *Archive) EnsureHash() error

EnsureHash computes the SHA256 hash of the archive's contents and stores it on the object.

func (*Archive) Equals

func (a *Archive) Equals(other *Archive) bool

Equals returns true if a is value-equal to other. In this case, value equality is determined only by the hash: even if the contents of two archives come from different sources, they are treated as equal if their hashes match. Similarly, if the contents of two archives come from the same source but the archives have different hashes, the archives are not equal.

func (*Archive) GetAssets

func (a *Archive) GetAssets() (map[string]interface{}, bool)

func (*Archive) GetPath

func (a *Archive) GetPath() (string, bool)

func (*Archive) GetURI

func (a *Archive) GetURI() (string, bool)

func (*Archive) GetURIURL

func (a *Archive) GetURIURL() (*url.URL, bool, error)

GetURIURL returns the underlying URI as a parsed URL, provided it is one. If there was an error parsing the URI, it will be returned as a non-nil error object.

func (*Archive) HasContents

func (a *Archive) HasContents() bool

HasContents indicates whether or not an archive's contents can be read.

func (*Archive) IsAssets

func (a *Archive) IsAssets() bool

func (*Archive) IsPath

func (a *Archive) IsPath() bool

func (*Archive) IsURI

func (a *Archive) IsURI() bool

func (*Archive) Open

func (a *Archive) Open() (ArchiveReader, error)

Open returns an ArchiveReader that can be used to iterate over the named blobs that comprise the archive.

func (*Archive) ReadSourceArchive

func (a *Archive) ReadSourceArchive() (ArchiveFormat, io.ReadCloser, error)

ReadSourceArchive returns a stream to the underlying archive, if there is one.

func (*Archive) Serialize

func (a *Archive) Serialize() map[string]interface{}

Serialize returns a weakly typed map that contains the right signature for serialization purposes.

type ArchiveFormat

type ArchiveFormat int

ArchiveFormat indicates what archive and/or compression format an archive uses.

type ArchiveReader

type ArchiveReader interface {
	// Next returns the name and contents of the next member of the archive. If there are no more members in the
	// archive, this function returns ("", nil, io.EOF). The blob returned by a call to Next() must be read in full
	// before the next call to Next().
	Next() (string, *Blob, error)

	// Close terminates the stream.
	Close() error
}

ArchiveReader presents the contents of an archive as a stream of named blobs.

type ArrayDiff

type ArrayDiff struct {
	Adds    map[int]PropertyValue // elements added in the new.
	Deletes map[int]PropertyValue // elements deleted in the new.
	Sames   map[int]PropertyValue // elements the same in both.
	Updates map[int]ValueDiff     // elements that have changed in the new.
}

ArrayDiff holds the results of diffing two arrays of property values.

func (*ArrayDiff) Len

func (diff *ArrayDiff) Len() int

Len computes the length of this array, taking into account adds, deletes, sames, and updates.

type Asset

type Asset struct {
	Sig  string `json:"4dabf18193072939515e22adb298388d" yaml:"4dabf18193072939515e22adb298388d"` // the unique asset signature (see properties.go).
	Hash string `json:"hash,omitempty" yaml:"hash,omitempty"`                                     // the SHA256 hash of the asset contents.
	Text string `json:"text,omitempty" yaml:"text,omitempty"`                                     // a textual asset.
	Path string `json:"path,omitempty" yaml:"path,omitempty"`                                     // a file on the current filesystem.
	URI  string `json:"uri,omitempty" yaml:"uri,omitempty"`                                       // a URI (file://, http://, https://, or custom).
}

Asset is a serialized asset reference. It is a union: thus, only one of its fields will be non-nil. Several helper routines exist as members in order to easily interact with the assets referenced by an instance of this type. nolint: lll

func DeserializeAsset

func DeserializeAsset(obj map[string]interface{}) (*Asset, bool, error)

DeserializeAsset checks to see if the map contains an asset, using its signature, and if so deserializes it.

func MassageIfUserProgramCodeAsset

func MassageIfUserProgramCodeAsset(asset *Asset, debug bool) *Asset

MassageIfUserProgramCodeAsset takes the text for a function and cleans it up a bit to make the user visible diffs less noisy. Specifically:

  1. it tries to condense things by changling multiple blank lines into a single blank line.
  2. it normalizs the sha hashes we emit so that changes to them don't appear in the diff.
  3. it elides the with-capture headers, as changes there are not generally meaningful.

TODO(https://github.com/pulumi/pulumi/issues/592) this is baking in a lot of knowledge about pulumi serialized functions. We should try to move to an alternative mode that isn't so brittle. Options include:

  1. Have a documented delimeter format that plan.go will look for. Have the function serializer emit those delimeters around code that should be ignored.
  2. Have our resource generation code supply not just the resource, but the "user presentable" resource that cuts out a lot of cruft. We could then just diff that content here.

func NewPathAsset

func NewPathAsset(path string) (*Asset, error)

NewPathAsset produces a new asset and its corresponding SHA256 hash from the given filesystem path.

func NewTextAsset

func NewTextAsset(text string) (*Asset, error)

NewTextAsset produces a new asset and its corresponding SHA256 hash from the given text.

func NewURIAsset

func NewURIAsset(uri string) (*Asset, error)

NewURIAsset produces a new asset and its corresponding SHA256 hash from the given network URI.

func (*Asset) Bytes

func (a *Asset) Bytes() ([]byte, error)

Bytes returns the contents of the asset as a byte slice.

func (*Asset) EnsureHash

func (a *Asset) EnsureHash() error

EnsureHash computes the SHA256 hash of the asset's contents and stores it on the object.

func (*Asset) Equals

func (a *Asset) Equals(other *Asset) bool

Equals returns true if a is value-equal to other. In this case, value equality is determined only by the hash: even if the contents of two assets come from different sources, they are treated as equal if their hashes match. Similarly, if the contents of two assets come from the same source but the assets have different hashes, the assets are not equal.

func (*Asset) GetPath

func (a *Asset) GetPath() (string, bool)

func (*Asset) GetText

func (a *Asset) GetText() (string, bool)

func (*Asset) GetURI

func (a *Asset) GetURI() (string, bool)

func (*Asset) GetURIURL

func (a *Asset) GetURIURL() (*url.URL, bool, error)

GetURIURL returns the underlying URI as a parsed URL, provided it is one. If there was an error parsing the URI, it will be returned as a non-nil error object.

func (*Asset) HasContents

func (a *Asset) HasContents() bool

HasContents indicates whether or not an asset's contents can be read.

func (*Asset) IsPath

func (a *Asset) IsPath() bool

func (*Asset) IsText

func (a *Asset) IsText() bool

func (*Asset) IsURI

func (a *Asset) IsURI() bool

func (*Asset) IsUserProgramCode

func (a *Asset) IsUserProgramCode() bool

IsUserProgramCode checks to see if this is the special asset containing the users's code

func (*Asset) Read

func (a *Asset) Read() (*Blob, error)

Read begins reading an asset.

func (*Asset) Serialize

func (a *Asset) Serialize() map[string]interface{}

Serialize returns a weakly typed map that contains the right signature for serialization purposes.

type Blob

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

Blob is a blob that implements ReadCloser and offers Len functionality.

func NewByteBlob

func NewByteBlob(data []byte) *Blob

NewByteBlob creates a new byte blob.

func NewFileBlob

func NewFileBlob(f *os.File) (*Blob, error)

NewFileBlob creates a new asset blob whose size is known thanks to stat.

func NewReadCloserBlob

func NewReadCloserBlob(r io.ReadCloser) (*Blob, error)

NewReadCloserBlob turn any old ReadCloser into an Blob, usually by making a copy.

func (*Blob) Close

func (blob *Blob) Close() error

func (*Blob) Read

func (blob *Blob) Read(p []byte) (int, error)

func (*Blob) Size

func (blob *Blob) Size() int64

type Computed

type Computed struct {
	Element PropertyValue // the eventual value (type) of the computed property.
}

Computed represents the absence of a property value, because it will be computed at some point in the future. It contains a property value which represents the underlying expected type of the eventual property value.

type Goal

type Goal struct {
	Type         tokens.Type  // the type of resource.
	Name         tokens.QName // the name for the resource's URN.
	Custom       bool         // true if this resource is custom, managed by a plugin.
	Properties   PropertyMap  // the resource's property state.
	Parent       URN          // an optional parent URN for this resource.
	Protect      bool         // true to protect this resource from deletion.
	Dependencies []URN        // dependencies of this resource object.
	Provider     string       // the provider to use for this resource.
	InitErrors   []string     // errors encountered as we attempted to initialize the resource.
}

Goal is a desired state for a resource object. Normally it represents a subset of the resource's state expressed by a program, however if Output is true, it represents a more complete, post-deployment view of the state.

func NewGoal

func NewGoal(t tokens.Type, name tokens.QName, custom bool, props PropertyMap,
	parent URN, protect bool, dependencies []URN, provider string, initErrors []string) *Goal

NewGoal allocates a new resource goal state.

type ID

type ID string

ID is a unique resource identifier; it is managed by the provider and is mostly opaque.

func MaybeID

func MaybeID(s *string) *ID

MaybeID turns an optional string into an optional resource ID.

func NewUniqueHexID

func NewUniqueHexID(prefix string, randlen, maxlen int) (ID, error)

NewUniqueHexID generates a new "random" hex string for use by resource providers. It will take the optional prefix and append randlen random characters (defaulting to 8 if not > 0). The result must not exceed maxlen total characterss (if > 0). Note that capping to maxlen necessarily increases the risk of collisions.

func (ID) String

func (id ID) String() string

String converts a resource ID into a string.

func (*ID) StringPtr

func (id *ID) StringPtr() *string

StringPtr converts an optional ID into an optional string.

type ObjectDiff

type ObjectDiff struct {
	Adds    PropertyMap               // properties in this map are created in the new.
	Deletes PropertyMap               // properties in this map are deleted from the new.
	Sames   PropertyMap               // properties in this map are the same.
	Updates map[PropertyKey]ValueDiff // properties in this map are changed in the new.
}

ObjectDiff holds the results of diffing two object property maps.

func (*ObjectDiff) Added

func (diff *ObjectDiff) Added(k PropertyKey) bool

Added returns true if the property 'k' has been added in the new property set.

func (*ObjectDiff) Changed

func (diff *ObjectDiff) Changed(k PropertyKey) bool

Changed returns true if the property 'k' is known to be different between old and new.

func (*ObjectDiff) Deleted

func (diff *ObjectDiff) Deleted(k PropertyKey) bool

Deleted returns true if the property 'k' has been deleted from the new property set.

func (*ObjectDiff) Keys

func (diff *ObjectDiff) Keys() []PropertyKey

Keys returns a stable snapshot of all keys known to this object, across adds, deletes, sames, and updates.

func (*ObjectDiff) Same

func (diff *ObjectDiff) Same(k PropertyKey) bool

Same returns true if the property 'k' is *not* known to be different; note that this isn't the same as looking up in the Sames map, because it is possible the key is simply missing altogether (as is the case for nulls).

func (*ObjectDiff) Updated

func (diff *ObjectDiff) Updated(k PropertyKey) bool

Updated returns true if the property 'k' has been changed between new and old property sets.

type Operation added in v0.15.0

type Operation struct {
	Resource *State
	Type     OperationType
}

Operation represents an operation that the engine has initiated but has not yet completed. It is essentially just a tuple of a resource and a string identifying the operation.

func NewOperation added in v0.15.0

func NewOperation(state *State, op OperationType) Operation

NewOperation constructs a new Operation from a state and an operation name.

type OperationType added in v0.15.0

type OperationType string

OperationType is the type of operations issued by the engine.

const (
	// OperationTypeCreating is the state of resources that are being created.
	OperationTypeCreating OperationType = "creating"
	// OperationTypeUpdating is the state of resources that are being updated.
	OperationTypeUpdating OperationType = "updating"
	// OperationTypeDeleting is the state of resources that are being deleted.
	OperationTypeDeleting OperationType = "deleting"
	// OperationTypeReading is the state of resources that are being read.
	OperationTypeReading OperationType = "reading"
)

type Output

type Output struct {
	Element PropertyValue // the eventual value (type) of the output property.
}

Output is a property value that will eventually be computed by the resource provider. If an output property is encountered, it means the resource has not yet been created, and so the output value is unavailable. Note that an output property is a special case of computed, but carries additional semantic meaning.

type Property

type Property struct {
	Key   PropertyKey
	Value PropertyValue
}

Property is a pair of key and value.

type PropertyKey

type PropertyKey tokens.Name

PropertyKey is the name of a property.

type PropertyMap

type PropertyMap map[PropertyKey]PropertyValue

PropertyMap is a simple map keyed by property name with "JSON-like" values.

func NewPropertyMap

func NewPropertyMap(s interface{}) PropertyMap

NewPropertyMap turns a struct into a property map, using any JSON tags inside to determine naming.

func NewPropertyMapFromMap

func NewPropertyMapFromMap(m map[string]interface{}) PropertyMap

NewPropertyMapFromMap creates a resource map from a regular weakly typed JSON-like map.

func NewPropertyMapFromMapRepl

func NewPropertyMapFromMapRepl(m map[string]interface{},
	replk func(string) (PropertyKey, bool), replv func(interface{}) (PropertyValue, bool)) PropertyMap

NewPropertyMapFromMapRepl optionally replaces keys/values in an existing map while creating a new resource map.

func NewPropertyMapRepl

func NewPropertyMapRepl(s interface{},
	replk func(string) (PropertyKey, bool), replv func(interface{}) (PropertyValue, bool)) PropertyMap

NewPropertyMapRepl turns a struct into a property map, using any JSON tags inside to determine naming. If non-nil replk or replv function(s) are provided, key and/or value transformations are performed during the mapping.

func (PropertyMap) ContainsUnknowns

func (m PropertyMap) ContainsUnknowns() bool

ContainsUnknowns returns true if the property map contains at least one unknown value.

func (PropertyMap) Copy

func (m PropertyMap) Copy() PropertyMap

Copy makes a shallow copy of the map.

func (PropertyMap) DeepEquals

func (props PropertyMap) DeepEquals(other PropertyMap) bool

DeepEquals returns true if this property map is deeply equal to the other property map; and false otherwise.

func (PropertyMap) Diff

func (props PropertyMap) Diff(other PropertyMap) *ObjectDiff

Diff returns a diffset by comparing the property map to another; it returns nil if there are no diffs.

func (PropertyMap) HasValue

func (m PropertyMap) HasValue(k PropertyKey) bool

HasValue returns true if the slot associated with the given property key contains a real value. It returns false if a value is null or an output property that is awaiting a value to be assigned. That is to say, HasValue indicates a semantically meaningful value is present (even if it's a computed one whose concrete value isn't yet evaluated).

func (PropertyMap) MapRepl

func (m PropertyMap) MapRepl(replk func(string) (string, bool),
	replv func(PropertyValue) (interface{}, bool)) map[string]interface{}

MapRepl returns a mapper-compatible object map, suitable for deserialization into structures. A key and/or value replace function, replk/replv, may be passed that will replace elements using custom logic if appropriate.

func (PropertyMap) Mappable

func (m PropertyMap) Mappable() map[string]interface{}

Mappable returns a mapper-compatible object map, suitable for deserialization into structures.

func (PropertyMap) Merge

func (m PropertyMap) Merge(other PropertyMap) PropertyMap

Merge simply merges in another map atop another, and returns the result.

func (PropertyMap) StableKeys

func (m PropertyMap) StableKeys() []PropertyKey

StableKeys returns all of the map's keys in a stable order.

type PropertySet

type PropertySet map[PropertyKey]bool

PropertySet is a simple set keyed by property name.

type PropertyValue

type PropertyValue struct {
	V interface{}
}

PropertyValue is the value of a property, limited to a select few types (see below).

func MakeComputed

func MakeComputed(v PropertyValue) PropertyValue

func MakeOutput

func MakeOutput(v PropertyValue) PropertyValue

func NewArchiveProperty

func NewArchiveProperty(v *Archive) PropertyValue

func NewArrayProperty

func NewArrayProperty(v []PropertyValue) PropertyValue

func NewAssetProperty

func NewAssetProperty(v *Asset) PropertyValue

func NewBoolProperty

func NewBoolProperty(v bool) PropertyValue

func NewComputedProperty

func NewComputedProperty(v Computed) PropertyValue

func NewNullProperty

func NewNullProperty() PropertyValue

func NewNumberProperty

func NewNumberProperty(v float64) PropertyValue

func NewObjectProperty

func NewObjectProperty(v PropertyMap) PropertyValue

func NewOutputProperty

func NewOutputProperty(v Output) PropertyValue

func NewPropertyValue

func NewPropertyValue(v interface{}) PropertyValue

NewPropertyValue turns a value into a property value, provided it is of a legal "JSON-like" kind.

func NewPropertyValueRepl

func NewPropertyValueRepl(v interface{},
	replk func(string) (PropertyKey, bool), replv func(interface{}) (PropertyValue, bool)) PropertyValue

NewPropertyValueRepl turns a value into a property value, provided it is of a legal "JSON-like" kind. The replacement functions, replk and replv, may be supplied to transform keys and/or values as the mapping takes place.

func NewStringProperty

func NewStringProperty(v string) PropertyValue

func (PropertyValue) ArchiveValue

func (v PropertyValue) ArchiveValue() *Archive

ArchiveValue fetches the underlying archive value (panicking if it isn't an archive).

func (PropertyValue) ArrayValue

func (v PropertyValue) ArrayValue() []PropertyValue

ArrayValue fetches the underlying array value (panicking if it isn't a array).

func (PropertyValue) AssetValue

func (v PropertyValue) AssetValue() *Asset

AssetValue fetches the underlying asset value (panicking if it isn't an asset).

func (PropertyValue) BoolValue

func (v PropertyValue) BoolValue() bool

BoolValue fetches the underlying bool value (panicking if it isn't a bool).

func (PropertyValue) ContainsUnknowns

func (v PropertyValue) ContainsUnknowns() bool

ContainsUnknowns returns true if the property value contains at least one unknown (deeply).

func (PropertyValue) DeepEquals

func (v PropertyValue) DeepEquals(other PropertyValue) bool

DeepEquals returns true if this property map is deeply equal to the other property map; and false otherwise.

func (PropertyValue) Diff

func (v PropertyValue) Diff(other PropertyValue) *ValueDiff

Diff returns a diff by comparing a single property value to another; it returns nil if there are no diffs.

func (PropertyValue) HasValue

func (v PropertyValue) HasValue() bool

HasValue returns true if a value is semantically meaningful.

func (PropertyValue) Input

func (v PropertyValue) Input() Computed

Input fetches the underlying computed value (panicking if it isn't a computed).

func (PropertyValue) IsArchive

func (v PropertyValue) IsArchive() bool

IsArchive returns true if the underlying value is an object.

func (PropertyValue) IsArray

func (v PropertyValue) IsArray() bool

IsArray returns true if the underlying value is an array.

func (PropertyValue) IsAsset

func (v PropertyValue) IsAsset() bool

IsAsset returns true if the underlying value is an object.

func (PropertyValue) IsBool

func (v PropertyValue) IsBool() bool

IsBool returns true if the underlying value is a bool.

func (PropertyValue) IsComputed

func (v PropertyValue) IsComputed() bool

IsComputed returns true if the underlying value is a computed value.

func (PropertyValue) IsNull

func (v PropertyValue) IsNull() bool

IsNull returns true if the underlying value is a null.

func (PropertyValue) IsNumber

func (v PropertyValue) IsNumber() bool

IsNumber returns true if the underlying value is a number.

func (PropertyValue) IsObject

func (v PropertyValue) IsObject() bool

IsObject returns true if the underlying value is an object.

func (PropertyValue) IsOutput

func (v PropertyValue) IsOutput() bool

IsOutput returns true if the underlying value is an output value.

func (PropertyValue) IsString

func (v PropertyValue) IsString() bool

IsString returns true if the underlying value is a string.

func (PropertyValue) MapRepl

func (v PropertyValue) MapRepl(replk func(string) (string, bool),
	replv func(PropertyValue) (interface{}, bool)) interface{}

MapRepl returns a mapper-compatible object map, suitable for deserialization into structures. A key and/or value replace function, replk/replv, may be passed that will replace elements using custom logic if appropriate.

func (PropertyValue) Mappable

func (v PropertyValue) Mappable() interface{}

Mappable returns a mapper-compatible value, suitable for deserialization into structures.

func (PropertyValue) NumberValue

func (v PropertyValue) NumberValue() float64

NumberValue fetches the underlying number value (panicking if it isn't a number).

func (PropertyValue) ObjectValue

func (v PropertyValue) ObjectValue() PropertyMap

ObjectValue fetches the underlying object value (panicking if it isn't a object).

func (PropertyValue) OutputValue

func (v PropertyValue) OutputValue() Output

OutputValue fetches the underlying output value (panicking if it isn't a output).

func (PropertyValue) String

func (v PropertyValue) String() string

String implements the fmt.Stringer interface to add slightly more information to the output.

func (PropertyValue) StringValue

func (v PropertyValue) StringValue() string

StringValue fetches the underlying string value (panicking if it isn't a string).

func (PropertyValue) TypeString

func (v PropertyValue) TypeString() string

TypeString returns a type representation of the property value's holder type.

type ReqError

type ReqError struct {
	K PropertyKey
}

func (*ReqError) Error

func (err *ReqError) Error() string

type State

type State struct {
	Type         tokens.Type // the resource's type.
	URN          URN         // the resource's object urn, a human-friendly, unique name for the resource.
	Custom       bool        // true if the resource is custom, managed by a plugin.
	Delete       bool        // true if this resource is pending deletion due to a replacement.
	ID           ID          // the resource's unique ID, assigned by the resource provider (or blank if none/uncreated).
	Inputs       PropertyMap // the resource's input properties (as specified by the program).
	Outputs      PropertyMap // the resource's complete output state (as returned by the resource provider).
	Parent       URN         // an optional parent URN that this resource belongs to.
	Protect      bool        // true to "protect" this resource (protected resources cannot be deleted).
	External     bool        // true if this resource is "external" to Pulumi and we don't control the lifecycle
	Dependencies []URN       // the resource's dependencies
	InitErrors   []string    // the set of errors encountered in the process of initializing resource.
	Provider     string      // the provider to use for this resource.
}

State is a structure containing state associated with a resource. This resource may have been serialized and deserialized, or snapshotted from a live graph of resource objects. The value's state is not, however, associated with any runtime objects in memory that may be actively involved in ongoing computations.

func NewState

func NewState(t tokens.Type, urn URN, custom bool, del bool, id ID,
	inputs PropertyMap, outputs PropertyMap, parent URN, protect bool,
	external bool, dependencies []URN, initErrors []string, provider string) *State

NewState creates a new resource value from existing resource state information.

func (*State) All

func (s *State) All() PropertyMap

All returns all resource state, including the inputs and outputs, overlaid in that order.

type Status

type Status int

Status is returned when an error has occurred during a resource provider operation. It indicates whether the operation could be rolled back cleanly (OK). If not, it means the resource was left in an indeterminate state.

const (
	StatusOK Status = iota
	StatusPartialFailure
	StatusUnknown
)

type URN

type URN string

URN is a friendly, but unique, URN for a resource, most often auto-assigned by Pulumi. These are used as unique IDs for objects, and help us to perform graph diffing and resolution of resource objects.

In theory, we could support manually assigned URIs in the future. For the time being, however, we have opted to simplify developers' lives by mostly automating the generation of them algorithmically. The one caveat where it isn't truly automatic is that a developer -- or resource provider -- must provide a semi-unique name part.

Each resource URN is of the form:

urn:pulumi:<Stack>::<Project>::<Qualified$Type$Name>::<Name>

wherein each element is the following:

<Stack>                 The stack being deployed into
<Project>               The project being evaluated
<Qualified$Type$Name>   The object type's qualified type token (including the parent type)
<Name>                  The human-friendly name identifier assigned by the developer or provider

In the future, we may add elements to the URN; it is more important that it is unique than it is human-typable.

func DefaultRootStackURN added in v0.16.3

func DefaultRootStackURN(stack tokens.QName, proj tokens.PackageName) URN

DefaultRootStackURN constructs a default root stack URN for the given stack and project.

func NewURN

func NewURN(stack tokens.QName, proj tokens.PackageName, parentType, baseType tokens.Type, name tokens.QName) URN

NewURN creates a unique resource URN for the given resource object.

func (URN) Name

func (urn URN) Name() tokens.QName

Name returns the resource name part of a URN.

func (URN) Project

func (urn URN) Project() tokens.PackageName

Project returns the project name part of a URN.

func (URN) QualifiedType

func (urn URN) QualifiedType() tokens.Type

QualifiedType returns the resource type part of a URN including the parent type

func (URN) Stack

func (urn URN) Stack() tokens.QName

Stack returns the resource stack part of a URN.

func (URN) Type

func (urn URN) Type() tokens.Type

Type returns the resource type part of a URN

func (URN) URNName

func (urn URN) URNName() string

URNName returns the URN name part of a URN (i.e., strips off the prefix).

type ValueDiff

type ValueDiff struct {
	Old    PropertyValue // the old value.
	New    PropertyValue // the new value.
	Array  *ArrayDiff    // the array's detailed diffs (only for arrays).
	Object *ObjectDiff   // the object's detailed diffs (only for objects).
}

ValueDiff holds the results of diffing two property values.

Directories

Path Synopsis
Package edit contains functions suitable for editing a snapshot in-place.
Package edit contains functions suitable for editing a snapshot in-place.
Package stack contains the serialized and configurable state associated with an stack; or, in other words, a deployment target.
Package stack contains the serialized and configurable state associated with an stack; or, in other words, a deployment target.

Jump to

Keyboard shortcuts

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