Help us shape the future of Go! Take the 2026 Go Developer Survey

inventory

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package inventory reads a Databricks workspace into a typed, read-only model and classifies every object by who should own it in Terraform.

Index

Constants

This section is empty.

Variables

View Source
var ResourceNames = []string{
	"catalogs", "storage_credentials", "external_locations", "cluster_policies",
	"instance_pools", "warehouses", "secret_scopes", "service_principals",
}

ResourceNames lists the resource groups accepted by the reader.

Functions

func SelectResources

func SelectResources(names []string, shared bool) ([]string, error)

SelectResources validates a selection and returns it in canonical order. Nil selects every available group. Shared scope includes only UC groups.

func ValidateName

func ValidateName(resources []string, name *string) error

ValidateName requires one group and a non-empty name for object selection. Nil selects every visible object in the selected groups.

Types

type Catalog

type Catalog struct {
	Info              catalog.CatalogInfo        `json:"info"`
	Ownership         Ownership                  `json:"ownership"`
	WorkspaceIDs      []int64                    `json:"workspace_ids,omitempty"`
	WorkspaceBindings []catalog.WorkspaceBinding `json:"workspace_bindings,omitempty"`
	GrantsRead        bool                       `json:"grants_read"`
	Grants            []Grant                    `json:"grants"`
	Schemas           []Schema                   `json:"schemas"`
}

Catalog is a managed catalog with its direct grants.

type ClusterPolicy

type ClusterPolicy struct {
	Info        compute.Policy `json:"info"`
	Permissions []Permission   `json:"permissions"`
}

ClusterPolicy is a non-default cluster policy with its direct permissions.

type ExternalLocation

type ExternalLocation struct {
	Info              catalog.ExternalLocationInfo `json:"info"`
	Ownership         Ownership                    `json:"ownership"`
	WorkspaceIDs      []int64                      `json:"workspace_ids,omitempty"`
	WorkspaceBindings []catalog.WorkspaceBinding   `json:"workspace_bindings,omitempty"`
	GrantsRead        bool                         `json:"grants_read"`
	Grants            []Grant                      `json:"grants"`
}

ExternalLocation is a UC external location with its direct grants.

type Grant

type Grant struct {
	Principal  string   `json:"principal"`
	Privileges []string `json:"privileges"`
}

Grant is one direct Unity Catalog privilege assignment.

type Identity

type Identity struct {
	Host        string `json:"host"`
	UserName    string `json:"user_name"`
	AuthType    string `json:"auth_type"`
	WorkspaceID int64  `json:"workspace_id,omitempty"`
	MetastoreID string `json:"metastore_id,omitempty"`
}

Identity is who the client authenticates as and where.

type InstancePool

type InstancePool struct {
	Info        compute.GetInstancePool `json:"info"`
	Permissions []Permission            `json:"permissions"`
}

InstancePool is an instance pool with its direct permissions.

type Inventory

type Inventory struct {
	Host        string   `json:"host"`
	WorkspaceID int64    `json:"workspace_id"`
	MetastoreID string   `json:"metastore_id,omitempty"`
	UserName    string   `json:"user_name"`
	Resources   []string `json:"resources"`
	Name        *string  `json:"name,omitempty"`

	Catalogs           []Catalog           `json:"catalogs"`
	StorageCredentials []StorageCredential `json:"storage_credentials"`
	ExternalLocations  []ExternalLocation  `json:"external_locations"`
	ClusterPolicies    []ClusterPolicy     `json:"cluster_policies"`
	InstancePools      []InstancePool      `json:"instance_pools"`
	Warehouses         []Warehouse         `json:"warehouses"`
	SecretScopes       []SecretScope       `json:"secret_scopes"`
	ServicePrincipals  []ServicePrincipal  `json:"service_principals"`

	Issues  []Issue   `json:"issues"`
	Skipped []Skipped `json:"skipped"`
}

Inventory contains the selected resource groups read from one workspace.

func (*Inventory) Complete

func (inv *Inventory) Complete() bool

Complete is true when no read failed. A partial inventory must not become Terraform without an explicit override.

type Issue

type Issue struct {
	Area       string `json:"area"`
	ObjectName string `json:"object_name"`
	Operation  string `json:"operation"`
	Message    string `json:"message"`
	diagnostic.Details
}

Issue is a read or build failure. Any issue makes the export partial.

type Ownership

type Ownership string

Ownership says which Terraform root should manage a Unity Catalog securable.

const (
	// OwnedByWorkspace: ISOLATED and bound to exactly this workspace.
	OwnedByWorkspace Ownership = "workspace"
	// OwnedShared: OPEN, or ISOLATED and bound to zero or many workspaces.
	OwnedShared Ownership = "shared"
	// OwnedBySystem: Databricks-managed; never exported.
	OwnedBySystem Ownership = "system"
	// OwnedUnknown: ownership could not be verified; never exported.
	OwnedUnknown Ownership = "unknown"
)

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 (non-inherited) workspace object permission.

type Reader

type Reader struct {
	Parallelism int
	// Resources limits reads to the selected resource groups. Nil selects all groups.
	Resources []string
	// Name selects one exact name (service principal key) in one resource group.
	Name *string
	// Log receives progress lines. Nil disables progress.
	Log func(format string, args ...any)
	// contains filtered or unexported fields
}

Reader reads one workspace. It never writes to Databricks and never reads secret values.

func New

New returns a Reader that fans each resource group out to 8 concurrent reads. Groups run concurrently; the SDK rate limit paces the total request rate.

func (*Reader) Identify

func (r *Reader) Identify(ctx context.Context) (*Identity, error)

Identify authenticates and resolves the workspace's metastore assignment. The workspace ID does not require a Unity Catalog metastore assignment.

func (*Reader) Read

func (r *Reader) Read(ctx context.Context) (*Inventory, error)

Read inventories the workspace. Authentication failure is fatal; every other failure is recorded as an Issue and reading continues.

type Schema

type Schema struct {
	Info       catalog.SchemaInfo `json:"info"`
	GrantsRead bool               `json:"grants_read"`
	Grants     []Grant            `json:"grants"`
}

Schema is a user schema with its direct grants.

type SecretScope

type SecretScope struct {
	Info     workspace.SecretScope `json:"info"`
	ACLsRead bool                  `json:"acls_read"`
	ACLs     []workspace.AclItem   `json:"acls"`
}

SecretScope is a secret scope with its ACLs. Secret values are never read.

type ServicePrincipal

type ServicePrincipal struct {
	Info         iam.ServicePrincipal `json:"info"`
	DisplayName  string               `json:"display_name"`
	Key          string               `json:"key"`
	Entitlements []string             `json:"entitlements"`
}

ServicePrincipal is a workspace-level service principal.

type Skipped

type Skipped struct {
	Area       string `json:"area"`
	ObjectName string `json:"object_name"`
	Reason     string `json:"reason"`
}

Skipped records an object that was seen and deliberately left out.

type StorageCredential

type StorageCredential struct {
	Info              catalog.StorageCredentialInfo `json:"info"`
	Ownership         Ownership                     `json:"ownership"`
	WorkspaceIDs      []int64                       `json:"workspace_ids,omitempty"`
	WorkspaceBindings []catalog.WorkspaceBinding    `json:"workspace_bindings,omitempty"`
	GrantsRead        bool                          `json:"grants_read"`
	Grants            []Grant                       `json:"grants"`
}

StorageCredential is a UC storage credential with its direct grants.

type Warehouse

type Warehouse struct {
	Info        sql.GetWarehouseResponse `json:"info"`
	Permissions []Permission             `json:"permissions"`
}

Warehouse is a SQL warehouse with its direct permissions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL