Documentation
¶
Overview ¶
Package providers contains the logic for managing provider resources (versioning, loading, resource operations).
Index ¶
- Constants
- func GetDeniedDefaultProviderPkg(ref Reference) string
- func GetProviderChecksums(inputs resource.PropertyMap) (map[string][]byte, error)
- func GetProviderDownloadURL(inputs resource.PropertyMap) (string, error)
- func GetProviderName(name tokens.Package, inputs resource.PropertyMap) (tokens.Package, error)
- func GetProviderPackage(typ tokens.Type) tokens.Package
- func GetProviderVersion(inputs resource.PropertyMap) (*semver.Version, error)
- func IsDefaultProvider(urn resource.URN) bool
- func IsDenyDefaultsProvider(ref Reference) bool
- func IsProviderType(typ tokens.Type) bool
- func MakeProviderType(pkg tokens.Package) tokens.Type
- func SetProviderChecksums(inputs resource.PropertyMap, value map[string][]byte)
- func SetProviderName(inputs resource.PropertyMap, name tokens.Package)
- func SetProviderParameterization(inputs resource.PropertyMap, value *ProviderParameterization)
- func SetProviderURL(inputs resource.PropertyMap, value string)
- func SetProviderVersion(inputs resource.PropertyMap, value *semver.Version)
- type ProviderParameterization
- type ProviderRequest
- func (p ProviderRequest) DefaultName() string
- func (p ProviderRequest) Name() tokens.Package
- func (p ProviderRequest) Package() tokens.Package
- func (p ProviderRequest) Parameterization() *ProviderParameterization
- func (p ProviderRequest) PluginChecksums() map[string][]byte
- func (p ProviderRequest) PluginDownloadURL() string
- func (p ProviderRequest) String() string
- func (p ProviderRequest) Version() *semver.Version
- type Reference
- type Registry
- func (r *Registry) Call(context.Context, plugin.CallRequest) (plugin.CallResponse, error)
- func (r *Registry) Check(ctx context.Context, req plugin.CheckRequest) (plugin.CheckResponse, error)
- func (r *Registry) CheckConfig(context.Context, plugin.CheckConfigRequest) (plugin.CheckConfigResponse, error)
- func (r *Registry) Close() error
- func (r *Registry) Configure(context.Context, plugin.ConfigureRequest) (plugin.ConfigureResponse, error)
- func (r *Registry) Construct(context.Context, plugin.ConstructRequest) (plugin.ConstructResponse, error)
- func (r *Registry) Create(ctx context.Context, req plugin.CreateRequest) (plugin.CreateResponse, error)
- func (r *Registry) Delete(_ context.Context, req plugin.DeleteRequest) (plugin.DeleteResponse, error)
- func (r *Registry) Diff(ctx context.Context, req plugin.DiffRequest) (plugin.DiffResponse, error)
- func (r *Registry) DiffConfig(context.Context, plugin.DiffConfigRequest) (plugin.DiffConfigResponse, error)
- func (r *Registry) GetMapping(context.Context, plugin.GetMappingRequest) (plugin.GetMappingResponse, error)
- func (r *Registry) GetMappings(context.Context, plugin.GetMappingsRequest) (plugin.GetMappingsResponse, error)
- func (r *Registry) GetPluginInfo(context.Context) (workspace.PluginInfo, error)
- func (r *Registry) GetProvider(ref Reference) (plugin.Provider, bool)
- func (r *Registry) GetSchema(context.Context, plugin.GetSchemaRequest) (plugin.GetSchemaResponse, error)
- func (r *Registry) Handshake(context.Context, plugin.ProviderHandshakeRequest) (*plugin.ProviderHandshakeResponse, error)
- func (r *Registry) Invoke(context.Context, plugin.InvokeRequest) (plugin.InvokeResponse, error)
- func (r *Registry) Parameterize(context.Context, plugin.ParameterizeRequest) (plugin.ParameterizeResponse, error)
- func (r *Registry) Pkg() tokens.Package
- func (r *Registry) Read(context.Context, plugin.ReadRequest) (plugin.ReadResponse, error)
- func (r *Registry) RegisterAlias(providerURN, alias resource.URN)
- func (r *Registry) Same(ctx context.Context, res *resource.State) error
- func (r *Registry) SignalCancellation(context.Context) error
- func (r *Registry) StreamInvoke(context.Context, plugin.StreamInvokeRequest) (plugin.StreamInvokeResponse, error)
- func (r *Registry) Update(ctx context.Context, req plugin.UpdateRequest) (plugin.UpdateResponse, error)
Constants ¶
const UnconfiguredID = "unconfigured"
UnconfiguredID is a distinguished token used to indicate that a provider doesn't yet have an ID because it hasn't been configured yet. This should never be returned back to SDKs by the engine but is used for internal tracking so we maximally reuse provider instances but only configure them once.
const UnknownID = plugin.UnknownStringValue
UnknownID is a distinguished token used to indicate that a provider's ID is not known (e.g. because we are performing a preview).
Variables ¶
This section is empty.
Functions ¶
func GetDeniedDefaultProviderPkg ¶
Retrieves the package of the denied provider.
For example, if a reference to: "urn:codeinfra:stack::project::codeinfra:providers:aws::default_4_35_0" was denied, then GetDeniedDefaultProviderPkg would return "aws".
Panics if called on a provider that is not a DenyDefaultProvider.
func GetProviderChecksums ¶
func GetProviderChecksums(inputs resource.PropertyMap) (map[string][]byte, error)
GetProviderChecksums fetches a provider plugin checksums from the given property map. If the checksums is not set, this function returns nil.
func GetProviderDownloadURL ¶
func GetProviderDownloadURL(inputs resource.PropertyMap) (string, error)
GetProviderDownloadURL fetches a provider plugin download server URL from the given property map. If the server URL is not set, this function returns "".
func GetProviderName ¶
GetProviderName fetches and parses a provider name from the given property map. If the name property is not present, this function returns the passed in name.
func GetProviderPackage ¶
GetProviderPackage returns the provider package for the given type token.
func GetProviderVersion ¶
func GetProviderVersion(inputs resource.PropertyMap) (*semver.Version, error)
GetProviderVersion fetches and parses a provider version from the given property map. If the version property is not present, this function returns nil.
func IsDefaultProvider ¶
IsDefaultProvider returns true if this URN refers to a default Codeinfra provider.
func IsDenyDefaultsProvider ¶
func IsProviderType ¶
IsProviderType returns true if the supplied type token refers to a Codeinfra provider.
func MakeProviderType ¶
MakeProviderType returns the provider type token for the given package.
func SetProviderChecksums ¶
func SetProviderChecksums(inputs resource.PropertyMap, value map[string][]byte)
SetProviderChecksums sets the provider plugin checksums in the given property map.
func SetProviderName ¶
func SetProviderName(inputs resource.PropertyMap, name tokens.Package)
Sets the provider name in the given property map.
func SetProviderParameterization ¶
func SetProviderParameterization(inputs resource.PropertyMap, value *ProviderParameterization)
Sets the provider parameterization in the given property map, this should be called _after_ SetVersion.
func SetProviderURL ¶
func SetProviderURL(inputs resource.PropertyMap, value string)
SetProviderURL sets the provider plugin download server URL in the given property map.
func SetProviderVersion ¶
func SetProviderVersion(inputs resource.PropertyMap, value *semver.Version)
Sets the provider version in the given property map.
Types ¶
type ProviderParameterization ¶
type ProviderParameterization struct {
// The name of the parametrized package.
Name tokens.Package
// The version of the parametrized package.
Version semver.Version
// The value of the parameter.
Value []byte
}
func GetProviderParameterization ¶
func GetProviderParameterization(name tokens.Package, inputs resource.PropertyMap) (*ProviderParameterization, error)
GetProviderParameterization fetches and parses a provider parameterization from the given property map. If the parameterization property is not present, this function returns nil.
func NewProviderParameterization ¶
func NewProviderParameterization(name tokens.Package, version semver.Version, value []byte, ) *ProviderParameterization
NewProviderParameterization constructs a new provider parameterization.
type ProviderRequest ¶
type ProviderRequest struct {
// contains filtered or unexported fields
}
A ProviderRequest is a tuple of an optional semantic version, download server url, parameter, and a package name. Whenever the engine receives a registration for a resource that doesn't explicitly specify a provider, the engine creates a ProviderRequest for that resource's provider, using the version passed to the engine as part of RegisterResource and the package derived from the resource's token.
The source evaluator (source_eval.go) is responsible for servicing provider requests. It does this by interpreting these provider requests and sending resource registrations to the engine for the providers themselves. These are called "default providers".
ProviderRequest is useful as a hash key. The engine is free to instantiate any number of provider requests, but it is free to cache requests for a provider request that is equal to one that has already been serviced. If you do use ProviderRequest as a hash key, you should call String() to get a usable key for string-based hash maps. ProviderRequests only hash by their package name, version and download URL. The checksums and parameterization are not used in the hash.
func NewProviderRequest ¶
func NewProviderRequest( name tokens.Package, version *semver.Version, pluginDownloadURL string, checksums map[string][]byte, parameterization *ProviderParameterization, ) ProviderRequest
NewProviderRequest constructs a new provider request from an optional version, optional pluginDownloadURL, optional parameter, and package.
func (ProviderRequest) DefaultName ¶
func (p ProviderRequest) DefaultName() string
DefaultName returns a QName that is an appropriate name for a default provider constructed from this provider request. The name is intended to be unique; as such, the name is derived from the version associated with this request.
If a version is not provided, "default" is returned. Otherwise, Name returns a name starting with "default" and followed by a QName-legal representation of the semantic version of the requested provider.
func (ProviderRequest) Name ¶
func (p ProviderRequest) Name() tokens.Package
Name returns the this provider plugin name.
func (ProviderRequest) Package ¶
func (p ProviderRequest) Package() tokens.Package
Package returns this provider request's package.
func (ProviderRequest) Parameterization ¶
func (p ProviderRequest) Parameterization() *ProviderParameterization
Parameterization returns the parameterization of this provider request. May be nil if no parameterization was provided.
func (ProviderRequest) PluginChecksums ¶
func (p ProviderRequest) PluginChecksums() map[string][]byte
PluginChecksums returns this providers checksums. May be nil if no checksums were provided.
func (ProviderRequest) PluginDownloadURL ¶
func (p ProviderRequest) PluginDownloadURL() string
PluginDownloadURL returns this providers server url. May be "" if no pluginDownloadURL was provided.
func (ProviderRequest) String ¶
func (p ProviderRequest) String() string
String returns a string representation of this request. This string is suitable for use as a hash key.
func (ProviderRequest) Version ¶
func (p ProviderRequest) Version() *semver.Version
Version returns this provider request's version. May be nil if no version was provided.
type Reference ¶
type Reference struct {
// contains filtered or unexported fields
}
Reference represents a reference to a particular provider.
func NewDenyDefaultProvider ¶
DenyDefaultProvider represent a default provider that cannot be created.
func NewReference ¶
NewReference creates a new reference for the given URN and ID.
func ParseReference ¶
ParseReference parses the URN and ID from the string representation of a provider reference. If parsing was not possible, this function returns false.
type Registry ¶
type Registry struct {
plugin.NotForwardCompatibleProvider
// contains filtered or unexported fields
}
Registry manages the lifecylce of provider resources and their plugins and handles the resolution of provider references to loaded plugins.
When a registry is created, it is handed the set of old provider resources that it will manage. Each provider resource in this set is loaded and configured as per its recorded inputs and registered under the provider reference that corresponds to its URN and ID, both of which must be known. At this point, the created registry is prepared to be used to manage the lifecycle of these providers as well as any new provider resources requested by invoking the registry's CRUD operations.
In order to fit neatly in to the existing infrastructure for managing resources using Codeinfra, a provider regidstry itself implements the plugin.Provider interface.
func NewRegistry ¶
NewRegistry creates a new provider registry using the given host.
func (*Registry) Call ¶
func (r *Registry) Call(context.Context, plugin.CallRequest) (plugin.CallResponse, error)
func (*Registry) Check ¶
func (r *Registry) Check(ctx context.Context, req plugin.CheckRequest) (plugin.CheckResponse, error)
Check validates the configuration for a particular provider resource.
The particulars of Check are a bit subtle for a few reasons:
- we need to load the provider for the package indicated by the type name portion provider resource's URN in order to check its config
- we need to keep the newly-loaded provider around in case we need to diff its config
- if we are running a preview, we need to configure the provider, as its corresponding CRUD operations will not run (we would normally configure the provider in Create or Update).
func (*Registry) CheckConfig ¶
func (r *Registry) CheckConfig(context.Context, plugin.CheckConfigRequest) (plugin.CheckConfigResponse, error)
CheckConfig validates the configuration for this resource provider.
func (*Registry) Configure ¶
func (r *Registry) Configure(context.Context, plugin.ConfigureRequest) (plugin.ConfigureResponse, error)
func (*Registry) Construct ¶
func (r *Registry) Construct(context.Context, plugin.ConstructRequest) (plugin.ConstructResponse, error)
func (*Registry) Create ¶
func (r *Registry) Create(ctx context.Context, req plugin.CreateRequest) (plugin.CreateResponse, error)
Create configures the provider with the given URN using the indicated configuration, assigns it an ID, and registers it under the assigned (URN, ID).
The provider must have been loaded by a prior call to Check.
func (*Registry) Delete ¶
func (r *Registry) Delete(_ context.Context, req plugin.DeleteRequest) (plugin.DeleteResponse, error)
Delete unregisters and unloads the provider with the given URN and ID. If the provider was never loaded this is a no-op.
func (*Registry) Diff ¶
func (r *Registry) Diff(ctx context.Context, req plugin.DiffRequest) (plugin.DiffResponse, error)
Diff diffs the configuration of the indicated provider. The provider corresponding to the given URN must have previously been loaded by a call to Check.
func (*Registry) DiffConfig ¶
func (r *Registry) DiffConfig(context.Context, plugin.DiffConfigRequest) (plugin.DiffConfigResponse, error)
DiffConfig checks what impacts a hypothetical change to this provider's configuration will have on the provider.
func (*Registry) GetMapping ¶
func (r *Registry) GetMapping(context.Context, plugin.GetMappingRequest) (plugin.GetMappingResponse, error)
func (*Registry) GetMappings ¶
func (r *Registry) GetMappings(context.Context, plugin.GetMappingsRequest) (plugin.GetMappingsResponse, error)
func (*Registry) GetPluginInfo ¶
func (*Registry) GetProvider ¶
GetProvider returns the provider plugin that is currently registered under the given reference, if any.
func (*Registry) GetSchema ¶
func (r *Registry) GetSchema(context.Context, plugin.GetSchemaRequest) (plugin.GetSchemaResponse, error)
GetSchema returns the JSON-serialized schema for the provider.
func (*Registry) Handshake ¶
func (r *Registry) Handshake( context.Context, plugin.ProviderHandshakeRequest, ) (*plugin.ProviderHandshakeResponse, error)
func (*Registry) Invoke ¶
func (r *Registry) Invoke(context.Context, plugin.InvokeRequest) (plugin.InvokeResponse, error)
func (*Registry) Parameterize ¶
func (r *Registry) Parameterize(context.Context, plugin.ParameterizeRequest) (plugin.ParameterizeResponse, error)
func (*Registry) Read ¶
func (r *Registry) Read(context.Context, plugin.ReadRequest) (plugin.ReadResponse, error)
func (*Registry) RegisterAlias ¶
RegisterAliases informs the registry that the new provider object with the given URN is aliased to the given list of URNs.
func (*Registry) Same ¶
Same executes as part of the "Same" step for a provider that has not changed. It configures the provider instance with the given state and fixes up aliases.
func (*Registry) StreamInvoke ¶
func (r *Registry) StreamInvoke(context.Context, plugin.StreamInvokeRequest) (plugin.StreamInvokeResponse, error)
func (*Registry) Update ¶
func (r *Registry) Update(ctx context.Context, req plugin.UpdateRequest) (plugin.UpdateResponse, error)
Update configures the provider with the given URN and ID using the indicated configuration and registers it at the reference indicated by the (URN, ID) pair.
The provider must have been loaded by a prior call to Check.