Documentation ¶
Index ¶
- func DefaultCheck[I any](inputs resource.PropertyMap) (I, []p.CheckFailure, error)
- func GetConfig[T any](ctx p.Context) T
- type Annotated
- type Annotator
- type ComponentResource
- type Crawler
- type CustomCheck
- type CustomDelete
- type CustomDiff
- type CustomRead
- type CustomResource
- type CustomUpdate
- type Enum
- type EnumKind
- type EnumValue
- type ExplicitDependencies
- type FieldSelector
- type Fn
- type InferredComponent
- type InferredConfig
- type InferredFunction
- type InferredResource
- type InputField
- type OutputField
- type Provider
- func (prov *Provider) CheckConfig(ctx p.Context, req p.CheckRequest) (p.CheckResponse, error)
- func (prov *Provider) Configure(ctx p.Context, req p.ConfigureRequest) error
- func (prov *Provider) DiffConfig(ctx p.Context, req p.DiffRequest) (p.DiffResponse, error)
- func (prov *Provider) WithComponents(components ...InferredComponent) *Provider
- func (prov *Provider) WithConfig(config InferredConfig) *Provider
- func (prov *Provider) WithDescription(description string) *Provider
- func (prov *Provider) WithDisplayName(name string) *Provider
- func (prov *Provider) WithFunctions(fns ...InferredFunction) *Provider
- func (prov *Provider) WithHomepage(homepage string) *Provider
- func (prov *Provider) WithKeywords(keywords []string) *Provider
- func (prov *Provider) WithLanguageMap(languages map[string]any) *Provider
- func (prov *Provider) WithLicense(license string) *Provider
- func (prov *Provider) WithLogoURL(logoURL string) *Provider
- func (prov *Provider) WithModuleMap(m map[tokens.ModuleName]tokens.ModuleName) *Provider
- func (prov *Provider) WithPublisher(publisher string) *Provider
- func (prov *Provider) WithRepository(repoURL string) *Provider
- func (prov *Provider) WithResources(resources ...InferredResource) *Provider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultCheck ¶
func DefaultCheck[I any](inputs resource.PropertyMap) (I, []p.CheckFailure, error)
Ensure that `inputs` can deserialize cleanly into `I`.
Types ¶
type Annotated ¶
type Annotated interface {
Annotate(Annotator)
}
Annotated is used to describe the fields of an object or a resource. Annotated can be implemented by `CustomResource`s, the input and output types for all resources and invokes, as well as other structs used the above.
type Annotator ¶
type Annotator interface { // Annotate a struct field with a text description. Describe(i any, description string) // Annotate 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, env ...string) }
The methods of Annotator must be called on pointers to fields of their receivers, or on their receiver itself.
func (*s Struct) Annotated(a Annotator) { a.Describe(&s, "A struct") // Legal a.Describe(&s.field1, "A field") // Legal a.Describe(s.field2, "A field") // Not legal, since the pointer is missing. otherS := &Struct{} a.Describe(&otherS.field1, "A field") // Not legal, since describe is not called on its receiver. }
type ComponentResource ¶
type ComponentResource[I any, O pulumi.ComponentResource] interface { // Construct a component resource // // ctx.RegisterResource needs to be called, but ctx.RegisterOutputs does not need to // be called. Construct(ctx *pulumi.Context, name, typ string, inputs I, opts pulumi.ResourceOption) (O, error) }
A component resource.
type CustomCheck ¶
type CustomCheck[I any] interface { // Maybe oldInputs can be of type I Check(ctx p.Context, name string, oldInputs resource.PropertyMap, newInputs resource.PropertyMap) ( I, []p.CheckFailure, error) }
A resource that understands how to check its inputs.
By default, infer handles checks by ensuring that a inputs de-serialize correctly. This is where you can extend that behavior. The returned input is given to subsequent calls to `Create` and `Update`.
Example: TODO - Maybe a resource that has a regex. We could reject invalid regex before the up actually happens.
type CustomDelete ¶
type CustomDelete[O any] interface { // Delete is called before a resource is removed from pulumi state. Delete(ctx p.Context, id string, props O) error }
A resource that knows how to delete itself.
If a resource does not implement Delete, no code will be run on resource deletion.
type CustomDiff ¶
type CustomDiff[I, O any] interface { // Maybe oldInputs can be of type I Diff(ctx p.Context, id string, olds O, news I) (p.DiffResponse, error) }
A resource that understands how to diff itself given a new set of inputs.
By default, infer handles diffs by structural equality among inputs. If CustomUpdate is implemented, changes will result in updates. Otherwise changes will result in replaces.
Example: TODO - Indicate replacements for certain changes but not others.
type CustomRead ¶
type CustomRead[I, O any] interface { // Read accepts a resource id, and a best guess of the input and output state. It returns // a normalized version of each, assuming it can be recovered. Read(ctx p.Context, id string, inputs I, state O) ( canonicalID string, normalizedInputs I, normalizedState O, err error) }
A resource that can recover its state from the provider.
If CustomRead is not implemented, it will default to checking that the inputs and state fit into I and O respectively. If they do, then the values will be returned as is. Otherwise an error will be returned.
Example: TODO - Probably something to do with the file system.
type CustomResource ¶
type CustomResource[I any, O any] interface { Create(ctx p.Context, name string, input I, preview bool) (id string, output O, err error) }
A resource that understands how to create itself. This is the minimum requirement for defining a new custom resource.
This interface should be implemented by the resource controller, with `I` the resource inputs and `O` the full set of resource fields. It is recommended that `O` is a superset of `I`, but it is not strictly required. The fields of `I` and `O` should consist of non-pulumi types i.e. `string` and `int` instead of `pulumi.StringInput` and `pulumi.IntOutput`.
The behavior of a CustomResource resource can be extended by implementing any of the following traits: - CustomCheck - CustomDiff - CustomUpdate - CustomRead - CustomDelete
Example: TODO
type CustomUpdate ¶
type CustomUpdate[I, O any] interface { Update(ctx p.Context, id string, olds O, news I, preview bool) (O, error) }
A resource that can adapt to new inputs with a delete and replace.
There is no default behavior for CustomUpdate.
Here the old state (as returned by Create or Update) as well as the new inputs are passed. Update should return the new state of the resource. If preview is true, then the update is part of `pulumi preview` and no changes should be made.
Example: TODO
type Enum ¶
type Enum[T EnumKind] interface { // A list of all allowed values for the enum. Values() []EnumValue[T] }
An Enum in the Pulumi type system.
type ExplicitDependencies ¶
type ExplicitDependencies[I, O any] interface { // WireDependencies specifies the dependencies between inputs and outputs. WireDependencies(f FieldSelector, args *I, state *O) }
A custom resource with the dataflow between its arguments (`I`) and outputs (`O`) specified. If a CustomResource implements ExplicitDependencies then WireDependencies will be called for each Create and Update call with `args` and `state` holding the values they will have for that call.
type FieldSelector ¶
type FieldSelector interface { // Create an input field. The argument to InputField must be a pointer to a field of // the associated input type I. // // For example: // “`go // func (r *MyResource) WireDependencies(f infer.FieldSelector, args *MyArgs, state *MyState) { // f.InputField(&args.Field) // } // “` InputField(any) InputField // Create an output field. The argument to OutputField must be a pointer to a field of // the associated output type O. // // For example: // “`go // func (r *MyResource) WireDependencies(f infer.FieldSelector, args *MyArgs, state *MyState) { // f.OutputField(&state.Field) // } // “` OutputField(any) OutputField // contains filtered or unexported methods }
An interface to help wire fields together.
type Fn ¶
type Fn[I any, O any] interface { // A function is a mapping from `I` to `O`. Call(ctx p.Context, input I) (output O, err error) }
A Function (also called Invoke) inferred from code. `I` is the function input, and `O` is the function output. Both must be structs.
type InferredComponent ¶
type InferredComponent interface { t.ComponentResource schema.Resource // contains filtered or unexported methods }
A component resource inferred from code. To get an instance of an InferredComponent, call the function Component.
func Component ¶
func Component[R ComponentResource[I, O], I any, O pulumi.ComponentResource]() InferredComponent
Define a component resource from go code. Here `R` is the component resource anchor, `I` describes its inputs and `O` its outputs. To add descriptions to `R`, `I` and `O`, see the `Annotated` trait defined in this module.
type InferredConfig ¶
func Config ¶
func Config[T any]() InferredConfig
Turn an object into a description for the provider configuration.
`T` has the same properties as an input or output type for a custom resource, and is responsive to the same interfaces.
`T` can implement CustomDiff and CustomCheck.
type InferredFunction ¶
type InferredFunction interface { t.Invoke schema.Function // contains filtered or unexported methods }
A function inferred from code. See Function for creating a InferredFunction.
func Function ¶
func Function[F Fn[I, O], I, O any]() InferredFunction
Infer a function from `F`, which maps `I` to `O`.
type InferredResource ¶
type InferredResource interface { t.CustomResource schema.Resource // contains filtered or unexported methods }
A resource inferred by the Resource function.
This interface cannot be implemented directly. Instead consult the Resource function.
func Resource ¶
func Resource[R CustomResource[I, O], I, O any]() InferredResource
Create a new InferredResource, where `R` is the resource controller, `I` is the resources inputs and `O` is the resources outputs.
type InputField ¶
type InputField interface {
// contains filtered or unexported methods
}
A field of the input (args).
type OutputField ¶
type OutputField interface { // Specify that a state (output) field is always secret, regardless of its dependencies. AlwaysSecret() // Specify that a state (output) field is never secret, regardless of its dependencies. NeverSecret() // Specify that a state (output) Field uses data from some args (input) Fields. DependsOn(dependencies ...InputField) // contains filtered or unexported methods }
A field of the output (state).
type Provider ¶
A provider that serves resources inferred from go code.
func NewProvider ¶
func NewProvider() *Provider
Create a new base provider to serve resources inferred from go code.
func (*Provider) CheckConfig ¶
func (prov *Provider) CheckConfig(ctx p.Context, req p.CheckRequest) (p.CheckResponse, error)
func (*Provider) DiffConfig ¶
func (prov *Provider) DiffConfig(ctx p.Context, req p.DiffRequest) (p.DiffResponse, error)
func (*Provider) WithComponents ¶
func (prov *Provider) WithComponents(components ...InferredComponent) *Provider
Add inferred component resources to the provider.
To allow method chaining, WithComponents mutates the instance it was called on and then returns it.
func (*Provider) WithConfig ¶
func (prov *Provider) WithConfig(config InferredConfig) *Provider
Give the provider global state. This will define a provider resource.
func (*Provider) WithDescription ¶ added in v0.6.0
func (*Provider) WithDisplayName ¶ added in v0.6.0
func (*Provider) WithFunctions ¶
func (prov *Provider) WithFunctions(fns ...InferredFunction) *Provider
Add inferred functions (also mentioned as invokes) to the provider.
To allow method chaining, WithFunctions mutates the instance it was called on and then returns it.
func (*Provider) WithHomepage ¶ added in v0.6.0
func (*Provider) WithKeywords ¶ added in v0.6.0
func (*Provider) WithLanguageMap ¶ added in v0.6.0
func (*Provider) WithLicense ¶ added in v0.6.0
func (*Provider) WithLogoURL ¶ added in v0.6.0
func (*Provider) WithModuleMap ¶
func (prov *Provider) WithModuleMap(m map[tokens.ModuleName]tokens.ModuleName) *Provider
WithModuleMap provides a mapping between go modules and pulumi modules.
For example, given a provider `pkg` with defines resources `foo.Foo`, `foo.Bar`, and `fizz.Buzz` the provider will expose resources at `pkg:foo:Foo`, `pkg:foo:Bar` and `pkg:fizz:Buzz`. Adding
`WithModuleMap(map[tokens.ModuleName]tokens.ModuleName{"foo": "bar"})`
will instead result in exposing the same resources at `pkg:bar:Foo`, `pkg:bar:Bar` and `pkg:fizz:Buzz`.
func (*Provider) WithPublisher ¶ added in v0.6.0
func (*Provider) WithRepository ¶ added in v0.6.0
func (*Provider) WithResources ¶
func (prov *Provider) WithResources(resources ...InferredResource) *Provider
Add inferred resources to the provider.
To allow method chaining, WithResources mutates the instance it was called on and then returns it.