resource

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Annotated

type Annotated interface {
	Annotate(Annotator)
}

type Annotator

type Annotator interface {
	// Annotate a a struct field with a text description.
	Describe(i any, description string)

	// Annotate a a struct field with a default value. The default value must be a primitive
	// type in the pulumi type system.
	SetDefault(i any, defaultValue any)
}

type Check

type Check interface {
	Custom

	// Check validates that the given property bag is valid for a resource of the given type and returns the inputs
	// that should be passed to successive calls to Diff, Create, or Update for this resource. As a rule, the provider
	// inputs returned by a call to Check should preserve the original representation of the properties as present in
	// the program inputs. Though this rule is not required for correctness, violations thereof can negatively impact
	// the end-user experience, as the provider inputs are using for detecting and rendering diffs.
	Check(ctx Context, news interface{}, sequenceNumber int) ([]CheckFailure, error)
}

A Custom resource which knows how to validate itself.

type CheckFailure

type CheckFailure struct {
	Property string // the property that failed validation.
	Reason   string // the reason that the property failed validation.
}

type Component

type Component interface {
	pulumi.ComponentResource

	// Construct the Component.
	//
	// When construct is called, it will already have it's input fields assigned to their
	// appropriate values. It should create its child resources, making sure to parent
	// them to itself. It should assign to any value that it outputs.
	//
	// For example:
	// “`go
	// type RandomLogin struct {
	//     pulumi.ResourceState
	//
	//     // Outputs
	//     Username pulumi.StringOutput `pulumi:"username"`
	//     Password pulumi.StringOutput `pulumi:"password"`
	//
	//     // Inputs
	//     PasswordLength pulumi.IntPtrInput `pulumi:"passwordLength"`
	// }
	//
	// func (r *RandomLogin) Construct(name string, ctx *pulumi.Context) error {
	// 	   pet, err := random.NewRandomPet(ctx, name+"-pet", &random.RandomPetArgs{}, pulumi.Parent(r))
	// 	   if err != nil {
	// 	       return err
	// 	   }
	// 	   r.Username = pet.ID().ToStringOutput()
	// 	   var length pulumi.IntInput = pulumi.Int(16)
	// 	   if r.PasswordLength != nil {
	// 	       length = r.PasswordLength.ToIntPtrOutput().Elem()
	// 	   }
	// 	   password, err := random.NewRandomPassword(ctx, name+"-password", &random.RandomPasswordArgs{
	// 	       Length: length,
	// 	   }, pulumi.Parent(r))
	// 	   if err != nil {
	// 	   	   return err
	// 	   }
	// 	   r.Password = password.Result.ToStringOutput()
	// 	   return nil
	// }
	// “`
	//
	// You will observe that there is *no* need to call RegisterComponentResource or
	// RegisterResourceOutputs.
	Construct(name string, ctx *pulumi.Context) error
}

A Component is a component resource which understands how to construct itself.

type Context

type Context interface {
	context.Context

	// MarkComputed marks a resource field as computed during a preview. Marking a field
	// as computed indicates to the engine that the field will be computed during the
	// update but the result is not known during the preview.
	//
	// MarkComputed may only be called on a direct reference to a field of the resource
	// whose method Context was passed to. Calling it on another value panics.
	//
	// For example:
	// “`go
	// func (r *MyResource) Update(ctx resource.Context, _ string, newSalt any, _ []string, preview bool) error {
	//     new := newSalt.(*RandomSalt)
	//     if new.FieldInput != r.FieldInput {
	//         ctx.MarkComputed(&r.ComputedField)        // This is valid
	//         // ctx.MarkComputed(r.ComputedField)      // This is *not* valid
	//         // ctx.markedComputed(&new.ComputedField) // Neither is this
	//         if !preview {
	//             r.ComputedField = expensiveComputation(r.FieldInput)
	//         }
	//     }
	//     return nil
	// }
	// “`
	MarkComputed(field any)

	// Log logs a global message, including errors and warnings.
	Log(severity diag.Severity, msg string, args ...any) error

	// LogStatus logs a global status message, including errors and warnings. Status messages will
	// appear in the `Info` column of the progress display, but not in the final output.
	LogStatus(severity diag.Severity, msg string, args ...any) error
}

type Custom

type Custom interface {
	// Create a Custom resource and return its ID.
	//
	// Resource input properties will be applied to the custom resource before any methods
	// are called. Create should set any output properties it wants to export.
	//
	// The context passed to Create may be canceled. Create should clean up and return as
	// soon as possible.
	//
	// This means that implementing this method correctly requires passing the Resource
	// implementer by reference.
	//
	// Warning: Mutating the receiver asynchronously after Create has returned may lead to
	// invalid behavior.
	Create(ctx Context, name string, preview bool) (ID, error)

	// Delete the Custom resource.
	//
	// Resource properties will be applied to the custom resource before the Delete
	// method is called.
	Delete(ctx Context, id ID) error
}

The base interface for a custom resource.

type Diff

type Diff interface {
	Custom

	// Diff the resource against another resource of the same type. `new` has the same
	// type as the implementer of Diff. Diff should ignore changes to any field specified
	// by `ignoreChanges`.
	Diff(ctx Context, id ID, new interface{}, ignoreChanges []string) (*pulumirpc.DiffResponse, error)
}

A Custom resource which knows how to compare against another instance of itself.

type ID

type ID = string

type Read

type Read interface {
	Custom
	Read(ctx Context, id string) error
}

type SContext

type SContext struct {
	context.Context
	// contains filtered or unexported fields
}

func NewContext

func NewContext(ctx context.Context, host *provider.HostClient,
	urn resource.URN, matcher introspect.FieldMatcher) *SContext

func (*SContext) ComputedKeys

func (c *SContext) ComputedKeys() []string

func (*SContext) Log

func (c *SContext) Log(severity diag.Severity, msg string, args ...any) error

Log logs a global message, including errors and warnings.

func (*SContext) LogStatus

func (c *SContext) LogStatus(severity diag.Severity, msg string, args ...any) error

LogStatus logs a global status message, including errors and warnings. Status messages will appear in the `Info` column of the progress display, but not in the final output.

func (*SContext) MarkComputed

func (c *SContext) MarkComputed(field any)

See the method documentation for Context.MarkComputed.

type Update

type Update interface {
	Custom

	// Update the resource without requiring a replace operation.
	//
	// The resource is its old input and output values. `new` is the same type as the
	// concrete implementer of Update and holds the new inputs.
	Update(ctx Context, id ID, new interface{}, ignoreChanges []string, preview bool) error
}

A Custom resource which knows how to handle changing inputs.

Jump to

Keyboard shortcuts

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