Documentation
¶
Overview ¶
Package contract turns an inventory into the datatf Terraform module contract: tfvars values, import blocks, and the export report.
Index ¶
- func Header(scope Scope, host string) []string
- func ImportsHeader(host string) []string
- func RenderImports(imports []Import, rootModule string, header []string) []byte
- func RenderVariable(v Variable, header []string) ([]byte, error)
- func RenderVariables(variables []Variable, header []string) ([]byte, error)
- type Access
- type AzureManagedIdentity
- type CatalogSettings
- type ClusterPolicySettings
- type Exclusion
- type Export
- type ExternalLocationSettings
- type Import
- type InstancePoolSettings
- type KeyvaultMetadata
- type Permission
- type PrincipalSettings
- type Report
- type ResourceModule
- type Scope
- type SecretScopeSettings
- type StorageCredentialSettings
- type Tfvars
- type Variable
- type WarehouseSettings
- type WorkspaceBindingSettings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ImportsHeader ¶
ImportsHeader returns the banner for imports.tf.
func RenderImports ¶
RenderImports renders Terraform import blocks. rootModule is the name of the composition module instance in the target root ("workspace" yields module.workspace.module.catalog["x"]...); empty addresses the per-resource modules directly.
func RenderVariable ¶
RenderVariable renders one tfvars block as formatted HCL. Values pass through JSON so the same shape feeds export.json, which keeps the two outputs in lockstep.
Types ¶
type AzureManagedIdentity ¶
type CatalogSettings ¶
type ClusterPolicySettings ¶
type ClusterPolicySettings struct {
Description string `json:"description,omitempty"`
Definition any `json:"definition,omitempty"`
PolicyFamilyID string `json:"policy_family_id,omitempty"`
PolicyFamilyDefinitionOverrides any `json:"policy_family_definition_overrides,omitempty"`
MaxClustersPerUser int64 `json:"max_clusters_per_user,omitempty"`
Libraries []any `json:"libraries"`
Permissions []Permission `json:"permissions"`
}
type Exclusion ¶
type Exclusion struct {
Area string `json:"area"`
Name string `json:"name"`
Ownership string `json:"ownership"`
}
Exclusion is a UC securable that was read successfully but belongs to the other scope.
type Export ¶
type Export struct {
Scope Scope `json:"scope"`
Tfvars *Tfvars `json:"tfvars"`
Imports []Import `json:"imports"`
Excluded []Exclusion `json:"excluded"`
}
Export is the complete result of one export.
type ExternalLocationSettings ¶
type ExternalLocationSettings struct {
URL string `json:"url"`
CredentialName string `json:"credential_name"`
IsolationMode string `json:"isolation_mode"`
Owner string `json:"owner"`
Comment string `json:"comment,omitempty"`
ReadOnly bool `json:"read_only"`
Fallback bool `json:"fallback"`
EnableFileEvents bool `json:"enable_file_events"`
}
type Import ¶
type Import struct {
Module string `json:"module"`
Key string `json:"key"`
Resource string `json:"resource"`
// Index is nil, an int (count-gated "[0]"), or a string (for_each key).
Index any `json:"index,omitempty"`
ID string `json:"id"`
}
Import is one Terraform import block addressed inside the composition module.
type InstancePoolSettings ¶
type InstancePoolSettings struct {
NodeTypeID string `json:"node_type_id"`
MinIdleInstances int `json:"min_idle_instances"`
MaxCapacity int `json:"max_capacity,omitempty"`
IdleInstanceAutoterminationMinutes int `json:"idle_instance_autotermination_minutes"`
EnableElasticDisk bool `json:"enable_elastic_disk"`
PreloadedSparkVersions []string `json:"preloaded_spark_versions"`
CustomTags map[string]string `json:"custom_tags,omitempty"`
AzureAttributes any `json:"azure_attributes,omitempty"`
Permissions []Permission `json:"permissions"`
}
type KeyvaultMetadata ¶
type Permission ¶
type Permission struct {
PermissionLevel string `json:"permission_level"`
GroupName string `json:"group_name,omitempty"`
UserName string `json:"user_name,omitempty"`
ServicePrincipalName string `json:"service_principal_name,omitempty"`
}
Permission is one direct permission on a workspace object. Exactly one principal field is set.
type PrincipalSettings ¶
type PrincipalSettings struct {
// DisplayName is set only when the map key had to be disambiguated.
DisplayName string `json:"display_name,omitempty"`
AllowClusterCreate bool `json:"allow_cluster_create"`
AllowInstancePoolCreate bool `json:"allow_instance_pool_create"`
DatabricksSQLAccess bool `json:"databricks_sql_access"`
WorkspaceAccess bool `json:"workspace_access"`
// WorkspaceConsume is mutually exclusive with the two access flags in the
// provider, so it is only present when granted.
WorkspaceConsume *bool `json:"workspace_consume,omitempty"`
}
type Report ¶
type Report struct {
Status string `json:"status"`
ExportedAt time.Time `json:"exported_at"`
Tool string `json:"tool"`
Host string `json:"host"`
UserName string `json:"user_name"`
WorkspaceID int64 `json:"workspace_id"`
MetastoreID string `json:"metastore_id,omitempty"`
Scope Scope `json:"scope,omitempty"`
Resources []string `json:"resources"`
Name *string `json:"name,omitempty"`
Counts map[string]int `json:"counts"`
Imports int `json:"imports"`
Issues []inventory.Issue `json:"issues"`
Skipped []inventory.Skipped `json:"skipped"`
Excluded []Exclusion `json:"excluded"`
Limitations map[string]string `json:"limitations"`
}
Report is export-report.json. Status "partial" means at least one read or build step failed and the Terraform output is incomplete.
type ResourceModule ¶
ResourceModule contains the selected inputs for one Registry resource module.
func ResourceModules ¶
func ResourceModules(t *Tfvars) ([]ResourceModule, error)
ResourceModules adapts the same selection used by Build to individual module inputs.
type SecretScopeSettings ¶
type SecretScopeSettings struct {
// ACLs is principal -> permission. Nil when the ACLs could not be read.
ACLs map[string]string `json:"acls,omitempty"`
KeyvaultMetadata *KeyvaultMetadata `json:"keyvault_metadata,omitempty"`
}
type StorageCredentialSettings ¶
type StorageCredentialSettings struct {
IsolationMode string `json:"isolation_mode"`
Owner string `json:"owner"`
Comment string `json:"comment,omitempty"`
ReadOnly bool `json:"read_only"`
AzureManagedIdentity *AzureManagedIdentity `json:"azure_managed_identity,omitempty"`
}
type Tfvars ¶
type Tfvars struct {
Catalogs map[string]CatalogSettings `json:"catalogs"`
CatalogAccess map[string]Access `json:"catalog_access"`
Schemas map[string][]string `json:"schemas"`
SchemaAccess map[string]map[string]Access `json:"schema_access"`
SchemaStorageRoots map[string]map[string]string `json:"schema_storage_roots"`
SchemaComments map[string]map[string]string `json:"schema_comments"`
StorageCredentials map[string]StorageCredentialSettings `json:"storage_credentials"`
StorageCredentialAccess map[string]Access `json:"storage_credential_access"`
ExternalLocations map[string]ExternalLocationSettings `json:"external_locations"`
ExternalLocationAccess map[string]Access `json:"external_location_access"`
WorkspaceBindings map[string]WorkspaceBindingSettings `json:"workspace_bindings"`
ClusterPolicies map[string]ClusterPolicySettings `json:"cluster_policies,omitempty"`
InstancePools map[string]InstancePoolSettings `json:"instance_pools,omitempty"`
Warehouses map[string]WarehouseSettings `json:"warehouses,omitempty"`
SecretScopes map[string]SecretScopeSettings `json:"secret_scopes,omitempty"`
ServicePrincipals map[string]PrincipalSettings `json:"service_principals,omitempty"`
}
Tfvars is every module input the exporter can populate. Workspace-native maps are nil for the shared scope and are not emitted.
type WarehouseSettings ¶
type WarehouseSettings struct {
ClusterSize string `json:"cluster_size"`
MinNumClusters int `json:"min_num_clusters"`
MaxNumClusters int `json:"max_num_clusters"`
AutoStopMins int `json:"auto_stop_mins"`
WarehouseType string `json:"warehouse_type"`
EnablePhoton bool `json:"enable_photon"`
EnableServerlessCompute bool `json:"enable_serverless_compute"`
SpotInstancePolicy string `json:"spot_instance_policy,omitempty"`
Tags map[string]string `json:"tags,omitempty"`
Permissions []Permission `json:"permissions"`
}