common

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package common provides functions and types used by several other packages of the CML2 Terraform provider.

Package common provides shared helpers for provider implementation.

Index

Constants

View Source
const (
	// ErrorLabel is the standard diagnostics title used for provider errors.
	ErrorLabel = "CML2 Provider Error"
)

Variables

This section is empty.

Functions

func Converge

func Converge(ctx context.Context, client *client.Client, diags *diag.Diagnostics, id, timeout string)

Converge waits until a lab reports convergence or the timeout is reached.

func ErrorString added in v0.9.0

func ErrorString(err error) string

ErrorString returns err.Error() or an empty string for nil.

func IsBuiltInNodeDefinition added in v0.9.0

func IsBuiltInNodeDefinition(nodeDef NodeDefinition) bool

IsBuiltInNodeDefinition reports whether nodeDef is a built-in definition ID.

func NodeDefIsLibvirtBacked added in v0.9.0

func NodeDefIsLibvirtBacked(nd models.NodeDefinition) bool

NodeDefIsLibvirtBacked reports whether the node definition is VM-backed (libvirt/qemu) based on the libvirt_domain_driver field.

func NodeDefLibvirtDomainDriver added in v0.9.0

func NodeDefLibvirtDomainDriver(nd models.NodeDefinition) string

NodeDefLibvirtDomainDriver returns the libvirt domain driver for a node definition. Empty means "not a libvirt/qemu VM" (e.g. docker-style nodes).

func NodeDefLinuxDriver added in v0.9.0

func NodeDefLinuxDriver(nd models.NodeDefinition) string

NodeDefLinuxDriver returns the simulator driver value (often matches the backend implementation, e.g. qemu for VM-backed nodes).

func Split2 added in v0.9.0

func Split2(s, sep string) []string

Split2 splits s by the first occurrence of sep. If sep is not present or either side is empty, it returns nil.

Types

type NodeDefinition added in v0.9.0

type NodeDefinition = string

NodeDefinition is the internal string identifier used for node types. Examples: "alpine", "iosv", "ioll2-xe", "external_connector".

type ProviderConfig

type ProviderConfig struct {
	// contains filtered or unexported fields
}

ProviderConfig stores initialized API client and provider-level settings.

func DatasourceConfigure

DatasourceConfigure returns provider config for a datasource.

func NewProviderConfig

func NewProviderConfig(data *cmlschema.ProviderModel) *ProviderConfig

NewProviderConfig creates a ProviderConfig from provider schema data.

func ResourceConfigure

ResourceConfigure returns provider config for a resource.

func (*ProviderConfig) Client

func (r *ProviderConfig) Client() *cmlclient.Client

Client returns the configured CML client.

func (*ProviderConfig) Initialize

func (r *ProviderConfig) Initialize(ctx context.Context, diags *diag.Diagnostics) *ProviderConfig

Initialize lazily creates the API client.

func (*ProviderConfig) Lock

func (r *ProviderConfig) Lock()

Lock serializes operations that must not run concurrently.

func (*ProviderConfig) NodeDefinitions added in v0.9.0

func (r *ProviderConfig) NodeDefinitions(ctx context.Context) (models.NodeDefinitionMap, error)

NodeDefinitions returns the controller's node definition map. The result is cached for the lifetime of the provider instance.

func (*ProviderConfig) Unlock

func (r *ProviderConfig) Unlock()

Unlock releases the provider-level lock.

func (*ProviderConfig) UseNamedConfigs

func (r *ProviderConfig) UseNamedConfigs() bool

UseNamedConfigs reports whether named configs are enabled.

Jump to

Keyboard shortcuts

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