Documentation ¶
Index ¶
- Variables
- func AccountData[T any](read func(context.Context, *T, *databricks.AccountClient) error) *schema.Resource
- func AccountDataWithParams[T, P any](read func(context.Context, P, *databricks.AccountClient) (*T, error)) *schema.Resource
- func AddContextToAllResources(p *schema.Provider, prefix string)
- func DataResource(sc any, read func(context.Context, any, *DatabricksClient) error) *schema.Resourcedeprecated
- func DataToReflectValue(d *schema.ResourceData, r *schema.Resource, rv reflect.Value) error
- func DataToStructPointer(d *schema.ResourceData, scm map[string]*schema.Schema, result any)
- func DiffToStructPointer(d attributeGetter, scm map[string]*schema.Schema, result any)
- func EqualFoldDiffSuppress(k, old, new string, d *schema.ResourceData) bool
- func GetTerraformVersionFromContext(ctx context.Context) string
- func IsExporter(ctx context.Context) bool
- func IsRequestEmpty(v any) (bool, error)
- func MustCompileKeyRE(name string) *regexp.Regexp
- func MustSchemaPath(s map[string]*schema.Schema, path ...string) *schema.Schema
- func NoCustomize(m map[string]*schema.Schema) map[string]*schema.Schema
- func OwnerRollbackError(err error, rollbackErr error, oldOwner string, newOwner string) error
- func SchemaPath(s map[string]*schema.Schema, path ...string) (*schema.Schema, error)
- func SetDefault(v *schema.Schema, value any)
- func SetReadOnly(v *schema.Schema)
- func SetRequired(v *schema.Schema)
- func SetSuppressDiff(v *schema.Schema)
- func StringIsUUID(s string) bool
- func StructToData(result any, s map[string]*schema.Schema, d *schema.ResourceData) error
- func StructToSchema(v any, customize func(map[string]*schema.Schema) map[string]*schema.Schema) map[string]*schema.Schema
- func Version() string
- func WorkspaceData[T any](read func(context.Context, *T, *databricks.WorkspaceClient) error) *schema.Resource
- func WorkspaceDataWithParams[T, P any](read func(context.Context, P, *databricks.WorkspaceClient) (*T, error)) *schema.Resource
- type ApiVersion
- type BindResource
- type CommandExecutor
- type CommandMock
- type CommandResults
- type DatabricksClient
- func (c *DatabricksClient) AccountClient() (*databricks.AccountClient, error)
- func (c *DatabricksClient) AccountOrWorkspaceRequest(accCallback func(*databricks.AccountClient) error, ...) error
- func (c *DatabricksClient) ClientForHost(ctx context.Context, url string) (*DatabricksClient, error)
- func (c *DatabricksClient) CommandExecutor(ctx context.Context) CommandExecutor
- func (c *DatabricksClient) Delete(ctx context.Context, path string, request any) error
- func (c *DatabricksClient) DeleteWithResponse(ctx context.Context, path string, request any, response any) error
- func (c *DatabricksClient) FormatURL(strs ...string) string
- func (c *DatabricksClient) Get(ctx context.Context, path string, request any, response any) error
- func (aa *DatabricksClient) GetAzureJwtProperty(key string) (any, error)
- func (c *DatabricksClient) IsAws() bool
- func (c *DatabricksClient) IsAzure() bool
- func (c *DatabricksClient) IsGcp() bool
- func (c *DatabricksClient) Patch(ctx context.Context, path string, request any) error
- func (c *DatabricksClient) PatchWithResponse(ctx context.Context, path string, request any, response any) error
- func (c *DatabricksClient) Post(ctx context.Context, path string, request any, response any) error
- func (c *DatabricksClient) Put(ctx context.Context, path string, request any) error
- func (c *DatabricksClient) Scim(ctx context.Context, method, path string, request any, response any) error
- func (c *DatabricksClient) SetAccountId(accountId string) error
- func (c *DatabricksClient) WithCommandExecutor(cef func(context.Context, *DatabricksClient) CommandExecutor)
- func (c *DatabricksClient) WithCommandMock(mock CommandMock)
- func (c *DatabricksClient) WorkspaceClient() (*databricks.WorkspaceClient, error)
- type Pair
- type Resource
Constants ¶
This section is empty.
Variables ¶
var ( // ResourceName is resource name without databricks_ prefix ResourceName contextKey = 1 // Provider is the current instance of provider Provider contextKey = 2 // Current is the current name of integration test Current contextKey = 3 // If current resource is data IsData contextKey = 4 // apiVersion Api contextKey = 5 )
var NoAuth string = "default auth: cannot configure default credentials, " +
"please check https://docs.databricks.com/en/dev-tools/auth.html#databricks-client-unified-authentication " +
"to configure credentials for your preferred authentication method"
Functions ¶
func AccountData ¶ added in v1.21.0
func AccountData[T any](read func(context.Context, *T, *databricks.AccountClient) error) *schema.Resource
AccountData is a generic way to define account data resources in Terraform provider.
Example usage:
type metastoresData struct { Ids map[string]string `json:"ids,omitempty" tf:"computed"` } return common.AccountData(func(ctx context.Context, d *metastoresData, acc *databricks.AccountClient) error { metastores, err := acc.Metastores.List(ctx) ... })
func AccountDataWithParams ¶ added in v1.34.0
func AccountDataWithParams[T, P any](read func(context.Context, P, *databricks.AccountClient) (*T, error)) *schema.Resource
AccountDataWithParams defines a data source that can be used to read data from the workspace API. It differs from AccountData in that it allows extra attributes to be provided as a separate argument, so the original type used to define the resource can also be used to define the data source.
The first type parameter is the type of the resource. This can be a type directly from the SDK, or a custom type defined in the provider that embeds the SDK type.
The second type parameter is the type of the extra attributes that should be provided to the data source. These are the attributes that the user can specify in the data source configuration, but are not part of the resource type. If there are no extra attributes, this should be `struct{}`. If there are any fields with the same JSON name as fields in the resource type, these fields will override the values from the resource type.
The single argument is a function that will be called to read the data from the workspace API, returning the requested resource. The function should return an error if the data cannot be read or the resource cannot be found.
Example usage:
type MwsWorkspace struct { ... } type MwsWorkspaceDataParams struct { Id string `json:"id" tf:"computed,optional"` Name string `json:"name" tf:"computed,optional"` } AccountDataWithParams( func(ctx context.Context, data MwsWorkspaceDataParams, a *databricks.AccountClient) (*MwsWorkspace, error) { // User-provided attributes are present in the `data` parameter. // The resource should be populated in the `workspace` parameter. ... })
func AddContextToAllResources ¶
AddContextToAllResources ...
func DataResource
deprecated
func DataToReflectValue ¶
DataToReflectValue reads reflect value from data
func DataToStructPointer ¶
DataToStructPointer reads resource data with given schema onto result pointer. Panics.
func DiffToStructPointer ¶
DiffToStructPointer reads resource diff with given schema onto result pointer. Panics.
func EqualFoldDiffSuppress ¶ added in v1.14.3
func EqualFoldDiffSuppress(k, old, new string, d *schema.ResourceData) bool
func GetTerraformVersionFromContext ¶ added in v1.34.0
func IsExporter ¶ added in v1.34.0
func IsRequestEmpty ¶ added in v1.32.0
func MustCompileKeyRE ¶
func MustSchemaPath ¶
func NoCustomize ¶ added in v1.29.0
func OwnerRollbackError ¶ added in v1.33.0
func SchemaPath ¶
SchemaPath helps to navigate
func SetDefault ¶ added in v1.34.0
SetDefault sets the default value for a schema.
func SetReadOnly ¶ added in v1.34.0
SetReadOnly sets the schema to be read-only (i.e. computed, non-optional). This should be used for fields that are not user-configurable but are returned by the platform.
func SetRequired ¶ added in v1.34.0
SetRequired sets the schema to be required.
func SetSuppressDiff ¶ added in v1.34.0
SetSuppressDiff adds diff suppression to a schema. This is necessary for non-computed fields for which the platform returns a value, but the user has not configured any value. For example: the REST API returns `{"tags": {}}` for a resource with no tags.
func StringIsUUID ¶ added in v1.28.0
func StructToData ¶
StructToData reads result using schema onto resource data
func StructToSchema ¶
func StructToSchema(v any, customize func(map[string]*schema.Schema) map[string]*schema.Schema) map[string]*schema.Schema
StructToSchema makes schema from a struct type & applies customizations from callback given
func WorkspaceData ¶ added in v1.10.1
func WorkspaceData[T any](read func(context.Context, *T, *databricks.WorkspaceClient) error) *schema.Resource
WorkspaceData is a generic way to define workspace data resources in Terraform provider.
Example usage:
type catalogsData struct { Ids []string `json:"ids,omitempty" tf:"computed,slice_set"` } return common.WorkspaceData(func(ctx context.Context, data *catalogsData, w *databricks.WorkspaceClient) error { catalogs, err := w.Catalogs.ListAll(ctx) ... })
func WorkspaceDataWithParams ¶ added in v1.34.0
func WorkspaceDataWithParams[T, P any](read func(context.Context, P, *databricks.WorkspaceClient) (*T, error)) *schema.Resource
WorkspaceDataWithParams defines a data source that can be used to read data from the workspace API. It differs from WorkspaceData in that it separates the definition of the computed fields (the resource type) from the definition of the user-supplied parameters.
The first type parameter is the type of the resource. This can be a type directly from the SDK, or a custom type defined in the provider that embeds the SDK type.
The second type parameter is the type representing parameters that a user may provide to the data source. These are the attributes that the user can specify in the data source configuration, but are not part of the resource type. If there are no extra attributes, this should be `struct{}`. If there are any fields with the same JSON name as fields in the resource type, these fields will override the values from the resource type.
The single argument is a function that will be called to read the data from the workspace API, returning the value of the resource type. The function should return an error if the data cannot be read or the resource cannot be found.
Example usage:
type SqlWarehouse struct { ... } type SqlWarehouseDataParams struct { Id string `json:"id" tf:"computed,optional"` Name string `json:"name" tf:"computed,optional"` } WorkspaceDataWithParams( func(ctx context.Context, data SqlWarehouseDataParams, w *databricks.WorkspaceClient) (*SqlWarehouse, error) { // User-provided attributes are present in the `data` parameter. // The resource should be returned. ... })
Types ¶
type ApiVersion ¶
type ApiVersion string
const ( API_1_2 ApiVersion = "1.2" API_2_0 ApiVersion = "2.0" API_2_1 ApiVersion = "2.1" )
type BindResource ¶
type BindResource struct { ReadContext func(ctx context.Context, left, right string, c *DatabricksClient) error CreateContext func(ctx context.Context, left, right string, c *DatabricksClient) error DeleteContext func(ctx context.Context, left, right string, c *DatabricksClient) error }
BindResource defines resource with simplified functions
type CommandExecutor ¶
type CommandExecutor interface {
Execute(clusterID, language, commandStr string) CommandResults
}
CommandExecutor creates a spark context and executes a command and then closes context
type CommandMock ¶
type CommandMock func(commandStr string) CommandResults
CommandMock mocks the execution of command
type CommandResults ¶
type CommandResults struct { ResultType string `json:"resultType,omitempty"` Summary string `json:"summary,omitempty"` Cause string `json:"cause,omitempty"` Data any `json:"data,omitempty"` Schema any `json:"schema,omitempty"` Truncated bool `json:"truncated,omitempty"` IsJSONSchema bool `json:"isJsonSchema,omitempty"` // contains filtered or unexported fields }
CommandResults captures results of a command
func (*CommandResults) Error ¶
func (cr *CommandResults) Error() string
Error returns error in a bit more friendly way
func (*CommandResults) Failed ¶
func (cr *CommandResults) Failed() bool
Failed tells if command execution failed
func (*CommandResults) Scan ¶
func (cr *CommandResults) Scan(dest ...any) bool
Scan scans for results
func (*CommandResults) Text ¶
func (cr *CommandResults) Text() string
Text returns plain text results
type DatabricksClient ¶
type DatabricksClient struct { *client.DatabricksClient // contains filtered or unexported fields }
DatabricksClient holds properties needed for authentication and HTTP client setup fields with `name` struct tags become Terraform provider attributes. `env` struct tag can hold one or more coma-separated env variable names to find value, if not specified directly. `auth` struct tag describes the type of conflicting authentication used.
func CommonEnvironmentClient ¶
func CommonEnvironmentClient() *DatabricksClient
func (*DatabricksClient) AccountClient ¶ added in v1.21.0
func (c *DatabricksClient) AccountClient() (*databricks.AccountClient, error)
func (*DatabricksClient) AccountOrWorkspaceRequest ¶ added in v1.24.0
func (c *DatabricksClient) AccountOrWorkspaceRequest(accCallback func(*databricks.AccountClient) error, wsCallback func(*databricks.WorkspaceClient) error) error
func (*DatabricksClient) ClientForHost ¶
func (c *DatabricksClient) ClientForHost(ctx context.Context, url string) (*DatabricksClient, error)
ClientForHost creates a new DatabricksClient instance with the same auth parameters, but for the given host. Authentication has to be reinitialized, as Google OIDC has different authorizers, depending if it's workspace or Accounts API we're talking to.
func (*DatabricksClient) CommandExecutor ¶
func (c *DatabricksClient) CommandExecutor(ctx context.Context) CommandExecutor
CommandExecutor service
func (*DatabricksClient) DeleteWithResponse ¶ added in v1.30.0
func (c *DatabricksClient) DeleteWithResponse(ctx context.Context, path string, request any, response any) error
Delete on path. Deserializes the response into the response parameter.
func (*DatabricksClient) FormatURL ¶
func (c *DatabricksClient) FormatURL(strs ...string) string
FormatURL creates URL from the client Host and additional strings
func (*DatabricksClient) GetAzureJwtProperty ¶
func (aa *DatabricksClient) GetAzureJwtProperty(key string) (any, error)
func (*DatabricksClient) IsAws ¶
func (c *DatabricksClient) IsAws() bool
IsAws returns true if client is configured for AWS
func (*DatabricksClient) IsAzure ¶
func (c *DatabricksClient) IsAzure() bool
IsAzure returns true if client is configured for Azure Databricks - either by using AAD auth or with host+token combination
func (*DatabricksClient) IsGcp ¶
func (c *DatabricksClient) IsGcp() bool
IsGcp returns true if client is configured for GCP
func (*DatabricksClient) PatchWithResponse ¶ added in v1.30.0
func (c *DatabricksClient) PatchWithResponse(ctx context.Context, path string, request any, response any) error
Patch on path. Deserializes the response into the response parameter.
func (*DatabricksClient) Scim ¶
func (c *DatabricksClient) Scim(ctx context.Context, method, path string, request any, response any) error
Scim sets SCIM headers
func (*DatabricksClient) SetAccountId ¶ added in v1.32.0
func (c *DatabricksClient) SetAccountId(accountId string) error
func (*DatabricksClient) WithCommandExecutor ¶
func (c *DatabricksClient) WithCommandExecutor(cef func(context.Context, *DatabricksClient) CommandExecutor)
WithCommandExecutor sets command executor implementation to use
func (*DatabricksClient) WithCommandMock ¶
func (c *DatabricksClient) WithCommandMock(mock CommandMock)
WithCommandMock mocks all command executions for this client
func (*DatabricksClient) WorkspaceClient ¶ added in v1.10.0
func (c *DatabricksClient) WorkspaceClient() (*databricks.WorkspaceClient, error)
type Pair ¶
type Pair struct {
// contains filtered or unexported fields
}
Pair defines an ID pair
func NewPairSeparatedID ¶
NewPairSeparatedID creates new ID pair with a custom separator
func (*Pair) BindResource ¶
func (p *Pair) BindResource(pr BindResource) *schema.Resource
BindResource creates resource that relies on binding ID pair with simple schema & importer
type Resource ¶
type Resource struct { Create func(ctx context.Context, d *schema.ResourceData, c *DatabricksClient) error Read func(ctx context.Context, d *schema.ResourceData, c *DatabricksClient) error Update func(ctx context.Context, d *schema.ResourceData, c *DatabricksClient) error Delete func(ctx context.Context, d *schema.ResourceData, c *DatabricksClient) error CustomizeDiff func(ctx context.Context, d *schema.ResourceDiff) error StateUpgraders []schema.StateUpgrader Schema map[string]*schema.Schema SchemaVersion int Timeouts *schema.ResourceTimeout }
Resource aims to simplify things like error & deleted entities handling
func (Resource) ToResource ¶
ToResource converts to Terraform resource definition