Documentation ¶
Index ¶
- func ValidateModelObject(input interface{}) error
- type ConsoleLogger
- type DataSource
- type DataSourceWithDeprecationReplacedBy
- type DataSourceWrapper
- type DiagnosticsLogger
- type Logger
- type NullLogger
- type PluginSdkResourceData
- func (p *PluginSdkResourceData) Get(key string) interface{}
- func (p *PluginSdkResourceData) GetChange(key string) (interface{}, interface{})
- func (p *PluginSdkResourceData) GetFromConfig(key string) interface{}
- func (p *PluginSdkResourceData) GetFromState(key string) interface{}
- func (p *PluginSdkResourceData) GetOk(key string) (interface{}, bool)
- func (p *PluginSdkResourceData) GetOkExists(key string) (interface{}, bool)
- func (p *PluginSdkResourceData) HasChange(key string) bool
- func (p *PluginSdkResourceData) HasChanges(keys ...string) bool
- func (p *PluginSdkResourceData) HasChangesExcept(keys ...string) bool
- func (p *PluginSdkResourceData) Id() string
- func (p *PluginSdkResourceData) Set(key string, value interface{}) error
- func (p *PluginSdkResourceData) SetConnInfo(input map[string]string)
- func (p *PluginSdkResourceData) SetId(id string)
- type Resource
- type ResourceData
- type ResourceFunc
- type ResourceMetaData
- func (rmd ResourceMetaData) Decode(input interface{}) error
- func (rmd ResourceMetaData) DecodeDiff(input interface{}) error
- func (rmd ResourceMetaData) Encode(input interface{}) error
- func (rmd ResourceMetaData) MarkAsGone(idFormatter resourceids.Id) error
- func (rmd ResourceMetaData) ResourceRequiresImport(resourceName string, idFormatter resourceids.Id) error
- func (rmd ResourceMetaData) SetID(formatter resourceids.Id)
- type ResourceRunFunc
- type ResourceWithCustomImporter
- type ResourceWithCustomizeDiff
- type ResourceWithDeprecationAndNoReplacement
- type ResourceWithDeprecationReplacedBy
- type ResourceWithStateMigration
- type ResourceWithUpdate
- type ResourceWrapper
- type StateUpgradeData
- type TypedServiceRegistration
- type TypedServiceRegistrationWithAGitHubLabel
- type UntypedServiceRegistration
- type UntypedServiceRegistrationWithAGitHubLabel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateModelObject ¶
func ValidateModelObject(input interface{}) error
ValidateModelObject validates that the object contains the specified `tfschema` tags required to be used with the Encode and Decode functions
Types ¶
type ConsoleLogger ¶
type ConsoleLogger struct{}
ConsoleLogger provides a Logger implementation which writes the log messages to StdOut - in Terraform's perspective that's proxied via the Plugin SDK
func (ConsoleLogger) Info ¶
func (ConsoleLogger) Info(message string)
Info prints out a message prefixed with `[INFO]` verbatim
func (ConsoleLogger) Infof ¶
func (l ConsoleLogger) Infof(format string, args ...interface{})
Infof prints out a message prefixed with `[INFO]` formatted with the specified arguments
func (ConsoleLogger) Warn ¶
func (l ConsoleLogger) Warn(message string)
Warn prints out a message prefixed with `[WARN]` formatted verbatim
func (ConsoleLogger) Warnf ¶
func (l ConsoleLogger) Warnf(format string, args ...interface{})
Warnf prints out a message prefixed with `[WARN]` formatted with the specified arguments
type DataSource ¶
type DataSource interface { // Read is a ResourceFunc which looks up and sets field values into the Terraform State Read() ResourceFunc // contains filtered or unexported methods }
A Data Source is an object which looks up information about an existing resource and returns this information for use elsewhere
Notably not all Terraform Resources/Azure API's make sense as a Data Source - this information has to be available consistently since these are queried on-demand
type DataSourceWithDeprecationReplacedBy ¶
type DataSourceWithDeprecationReplacedBy interface { DataSource // nolint gocritic // DeprecatedInFavourOfDataSource returns the name of the resource that this has been deprecated in favour of // NOTE: this must return a non-empty string DeprecatedInFavourOfDataSource() string }
DataSourceWithDeprecationReplacedBy is an optional interface
DataSource implementing this interface will be marked as Deprecated and output the DeprecationMessage during Terraform operations.
type DataSourceWrapper ¶
type DataSourceWrapper struct {
// contains filtered or unexported fields
}
DataSourceWrapper is a wrapper for converting a DataSource implementation into the object used by the Terraform Plugin SDK
func NewDataSourceWrapper ¶
func NewDataSourceWrapper(dataSource DataSource) DataSourceWrapper
NewDataSourceWrapper returns a DataSourceWrapper for this Data Source implementation
func (*DataSourceWrapper) DataSource ¶
func (dw *DataSourceWrapper) DataSource() (*schema.Resource, error)
DataSource returns the Terraform Plugin SDK type for this DataSource implementation
type DiagnosticsLogger ¶
type DiagnosticsLogger struct {
// contains filtered or unexported fields
}
func (*DiagnosticsLogger) Info ¶
func (d *DiagnosticsLogger) Info(message string)
func (*DiagnosticsLogger) Infof ¶
func (d *DiagnosticsLogger) Infof(format string, args ...interface{})
func (*DiagnosticsLogger) Warn ¶
func (d *DiagnosticsLogger) Warn(message string)
func (*DiagnosticsLogger) Warnf ¶
func (d *DiagnosticsLogger) Warnf(format string, args ...interface{})
type Logger ¶
type Logger interface { // Info prints out a message prefixed with `[INFO]` verbatim Info(message string) // Infof prints out a message prefixed with `[INFO]` formatted // with the specified arguments Infof(format string, args ...interface{}) // Warn prints out a message prefixed with `[WARN]` formatted verbatim Warn(message string) // Warnf prints out a message prefixed with `[WARN]` formatted // with the specified arguments Warnf(format string, args ...interface{}) }
Logger is an interface for switching out the Logger implementation
type NullLogger ¶
type NullLogger struct{}
NullLogger disregards the log output - and is intended to be used when the contents of the debug logger aren't interesting to reduce console output
func (NullLogger) Info ¶
func (NullLogger) Info(_ string)
Info prints out a message prefixed with `[INFO]` verbatim
func (NullLogger) Infof ¶
func (NullLogger) Infof(_ string, _ ...interface{})
Infof prints out a message prefixed with `[INFO]` formatted with the specified arguments
func (NullLogger) Warn ¶
func (NullLogger) Warn(_ string)
Warn prints out a message prefixed with `[WARN]` formatted verbatim
func (NullLogger) Warnf ¶
func (NullLogger) Warnf(_ string, _ ...interface{})
Warnf prints out a message prefixed with `[WARN]` formatted with the specified arguments
type PluginSdkResourceData ¶
type PluginSdkResourceData struct {
// contains filtered or unexported fields
}
PluginSdkResourceData defines the implementation of ResourceData as pluginsdk ResourceData type.
func NewPluginSdkResourceData ¶
func NewPluginSdkResourceData(d *pluginsdk.ResourceData) *PluginSdkResourceData
func (*PluginSdkResourceData) Get ¶
func (p *PluginSdkResourceData) Get(key string) interface{}
Get returns a value from either the config/state depending on where this is called in Create and Update functions this will return from the config in Read, Exists and Import functions this will return from the state NOTE: this should not be called from Delete functions.
func (*PluginSdkResourceData) GetChange ¶
func (p *PluginSdkResourceData) GetChange(key string) (interface{}, interface{})
func (*PluginSdkResourceData) GetFromConfig ¶
func (p *PluginSdkResourceData) GetFromConfig(key string) interface{}
func (*PluginSdkResourceData) GetFromState ¶
func (p *PluginSdkResourceData) GetFromState(key string) interface{}
func (*PluginSdkResourceData) GetOk ¶
func (p *PluginSdkResourceData) GetOk(key string) (interface{}, bool)
func (*PluginSdkResourceData) GetOkExists ¶
func (p *PluginSdkResourceData) GetOkExists(key string) (interface{}, bool)
func (*PluginSdkResourceData) HasChange ¶
func (p *PluginSdkResourceData) HasChange(key string) bool
func (*PluginSdkResourceData) HasChanges ¶
func (p *PluginSdkResourceData) HasChanges(keys ...string) bool
func (*PluginSdkResourceData) HasChangesExcept ¶
func (p *PluginSdkResourceData) HasChangesExcept(keys ...string) bool
func (*PluginSdkResourceData) Id ¶
func (p *PluginSdkResourceData) Id() string
func (*PluginSdkResourceData) Set ¶
func (p *PluginSdkResourceData) Set(key string, value interface{}) error
func (*PluginSdkResourceData) SetConnInfo ¶
func (p *PluginSdkResourceData) SetConnInfo(input map[string]string)
func (*PluginSdkResourceData) SetId ¶
func (p *PluginSdkResourceData) SetId(id string)
type Resource ¶
type Resource interface { // Create will provision this resource using the information from the Terraform Configuration // NOTE: the shim layer will automatically call the Read function once this has been created // so it's no longer necessary to call this explicitly Create() ResourceFunc // Read retrieves the latest values for this object and saves them into Terraform's State Read() ResourceFunc // Delete will remove an existing resource using the information available in Terraform's State Delete() ResourceFunc // IDValidationFunc returns the SchemaValidateFunc used to validate the ID is valid during // `terraform import` - ensuring users don't inadvertently specify the incorrect Resource ID IDValidationFunc() pluginsdk.SchemaValidateFunc // contains filtered or unexported methods }
A Resource is an object which can be provisioned and managed by Terraform that is, Created, Retrieved, Deleted, Imported (and optionally, Updated, by implementing the 'ResourceWithUpdate' interface)
It's worth calling out that not all Azure API's make sense as Terraform Resources - as a general rule if it supports CR(U)D it could, however.
type ResourceData ¶
type ResourceData interface { // Get returns a value from either the config/state depending on where this is called // in Create and Update functions this will return from the config // in Read, Exists and Import functions this will return from the state // NOTE: this should not be called from Delete functions. Get(key string) interface{} GetOk(key string) (interface{}, bool) GetOkExists(key string) (interface{}, bool) GetChange(key string) (interface{}, interface{}) HasChange(key string) bool HasChanges(keys ...string) bool HasChangesExcept(keys ...string) bool Id() string Set(key string, value interface{}) error SetConnInfo(v map[string]string) SetId(id string) }
type ResourceFunc ¶
type ResourceFunc struct { // Func is the function which should be called for this Resource Func // for example, during Read this is the Read function, during Update this is the Update function Func ResourceRunFunc DiffFunc ResourceRunFunc // Timeout is the default timeout, which can be overridden by users // for this method - in-turn used for the Azure API Timeout time.Duration }
type ResourceMetaData ¶
type ResourceMetaData struct { // Client is a reference to the Azure Providers Client - providing a typed reference to this object Client *clients.Client // Logger provides a logger for debug purposes Logger Logger // ResourceData is a reference to the ResourceData object from Terraform's Plugin SDK // This is used to be able to call operations directly should Encode/Decode be insufficient // for example, to determine if a field has changes ResourceData *schema.ResourceData // ResourceDiff is a reference to the ResourceDiff object from Terraform's Plugin SDK ResourceDiff *schema.ResourceDiff // contains filtered or unexported fields }
func (ResourceMetaData) Decode ¶
func (rmd ResourceMetaData) Decode(input interface{}) error
Decode will decode the Terraform Schema into the specified object NOTE: this object must be passed by value - and must contain `tfschema` struct tags for all fields
Example Usage:
type Person struct { Name string `tfschema:"name" }
var person Person if err := metadata.Decode(&person); err != nil { .. }
func (ResourceMetaData) DecodeDiff ¶
func (rmd ResourceMetaData) DecodeDiff(input interface{}) error
DecodeDiff decodes the Terraform Schema into the specified object in the same manner as Decode, but using the ResourceDiff as a source. Intended for use in CustomizeDiff functions.
func (ResourceMetaData) Encode ¶
func (rmd ResourceMetaData) Encode(input interface{}) error
Encode will encode the specified object into the Terraform State NOTE: this requires that the object passed in is a pointer and all fields contain `tfschema` struct tags
func (ResourceMetaData) MarkAsGone ¶
func (rmd ResourceMetaData) MarkAsGone(idFormatter resourceids.Id) error
MarkAsGone marks this resource as removed in the Remote API, so this is no longer available
func (ResourceMetaData) ResourceRequiresImport ¶
func (rmd ResourceMetaData) ResourceRequiresImport(resourceName string, idFormatter resourceids.Id) error
ResourceRequiresImport returns an error saying that this resource must be imported with instructions on how to do this (namely, using `terraform import`
func (ResourceMetaData) SetID ¶
func (rmd ResourceMetaData) SetID(formatter resourceids.Id)
SetID uses the specified ID Formatter to set the Resource ID
type ResourceRunFunc ¶
type ResourceRunFunc func(ctx context.Context, metadata ResourceMetaData) error
ResourceRunFunc is the function which can be run ctx provides a Context instance with the user-provided timeout metadata is a reference to an object containing the Client, ResourceData and a Logger
type ResourceWithCustomImporter ¶
type ResourceWithCustomImporter interface { Resource // CustomImporter returns a ResourceRunFunc which allows overriding the import CustomImporter() ResourceRunFunc }
type ResourceWithCustomizeDiff ¶
type ResourceWithCustomizeDiff interface { Resource // CustomizeDiff returns a ResourceFunc that runs the Custom Diff logic CustomizeDiff() ResourceFunc }
ResourceWithCustomizeDiff is an optional interface
type ResourceWithDeprecationAndNoReplacement ¶
type ResourceWithDeprecationAndNoReplacement interface { Resource // DeprecationMessage returns the Deprecation message for this resource // NOTE: this must return a non-empty string DeprecationMessage() string }
ResourceWithDeprecationAndNoReplacement is an optional interface
nolint gocritic Resources implementing this interface will be marked as Deprecated and output the DeprecationMessage during Terraform operations.
type ResourceWithDeprecationReplacedBy ¶
type ResourceWithDeprecationReplacedBy interface { Resource // nolint gocritic // DeprecatedInFavourOfResource returns the name of the resource that this has been deprecated in favour of // NOTE: this must return a non-empty string DeprecatedInFavourOfResource() string }
ResourceWithDeprecationReplacedBy is an optional interface
Resources implementing this interface will be marked as Deprecated and output the DeprecationMessage during Terraform operations.
type ResourceWithStateMigration ¶
type ResourceWithStateMigration interface { Resource StateUpgraders() StateUpgradeData }
type ResourceWithUpdate ¶
type ResourceWithUpdate interface { Resource // Update will make changes to this resource using the information from the Terraform Configuration/Plan // NOTE: the shim layer will automatically call the Read function once this has been created // so it's no longer necessary to call this explicitly Update() ResourceFunc }
ResourceWithUpdate is an optional interface
Notably the Arguments for Resources implementing this interface cannot be entirely ForceNew - else this interface implementation is superfluous.
type ResourceWrapper ¶
type ResourceWrapper struct {
// contains filtered or unexported fields
}
ResourceWrapper is a wrapper for converting a Resource implementation into the object used by the Terraform Plugin SDK
func NewResourceWrapper ¶
func NewResourceWrapper(resource Resource) ResourceWrapper
NewResourceWrapper returns a ResourceWrapper for this Resource implementation
type StateUpgradeData ¶
type StateUpgradeData struct { SchemaVersion int Upgraders map[int]pluginsdk.StateUpgrade }
type TypedServiceRegistration ¶
type TypedServiceRegistration interface { // Name is the name of this Service Name() string // DataSources returns a list of Data Sources supported by this Service DataSources() []DataSource // Resources returns a list of Resources supported by this Service Resources() []Resource // WebsiteCategories returns a list of categories which can be used for the sidebar WebsiteCategories() []string }
TypedServiceRegistration is a Service Registration using Types meaning that we can abstract on top of the Plugin SDK and use Native Types where possible
type TypedServiceRegistrationWithAGitHubLabel ¶
type TypedServiceRegistrationWithAGitHubLabel interface { TypedServiceRegistration AssociatedGitHubLabel() string }
TypedServiceRegistrationWithAGitHubLabel is a superset of TypedServiceRegistration allowing a single GitHub Label to be specified that will be automatically applied to any Pull Requests making changes to this package.
NOTE: this is intentionally an optional interface as the Service Package : GitHub Labels aren't always 1:1
type UntypedServiceRegistration ¶
type UntypedServiceRegistration interface { // Name is the name of this Service Name() string // WebsiteCategories returns a list of categories which can be used for the sidebar WebsiteCategories() []string // SupportedDataSources returns the supported Data Sources supported by this Service SupportedDataSources() map[string]*pluginsdk.Resource // SupportedResources returns the supported Resources supported by this Service SupportedResources() map[string]*pluginsdk.Resource }
UntypedServiceRegistration is the interface used for untyped/raw Plugin SDK resources in the future this'll be superseded by the TypedServiceRegistration which allows for stronger Typed resources to be used.
type UntypedServiceRegistrationWithAGitHubLabel ¶
type UntypedServiceRegistrationWithAGitHubLabel interface { UntypedServiceRegistration AssociatedGitHubLabel() string }
UntypedServiceRegistrationWithAGitHubLabel is a superset of UntypedServiceRegistration allowing a single GitHub Label to be specified that will be automatically applied to any Pull Requests making changes to this package.
NOTE: this is intentionally an optional interface as the Service Package : GitHub Labels aren't always 1:1