Documentation
¶
Index ¶
- Constants
- func BuildPostgresDatabaseURL(config *StateConfig) string
- func CreateTestTarGz(t *testing.T, files map[string][]byte) []byte
- func DescribeState(config *StateConfig) string
- func DownloadRemoteFile(ctx context.Context, filePath string, opts *RemoteDownloadOptions) ([]byte, error)
- func FindEngineConfigFile() (string, error)
- func GetDefaultEngineConfigPath() string
- func GetDefaultStateDir() string
- func IsRemoteFile(filePath string) bool
- func ParseInstancesJSON(data []byte) ([]state.InstanceState, error)
- func SerializeInstancesJSON(instances []state.InstanceState) ([]byte, error)
- func UploadRemoteFile(ctx context.Context, filePath string, data []byte, opts *RemoteUploadOptions) error
- type ContainerStateExporter
- type ContainerStateImporter
- type ContainerStateImporterOption
- type EngineConfig
- type ErrorExplanation
- type ExportError
- type ExportErrorCode
- type ExportInstancesResult
- type ExportParams
- type ExportResult
- type FileEncryptionKeyOptions
- type ImportError
- type ImportErrorCode
- type ImportInstancesResult
- type ImportParams
- type ImportResult
- type ObjectStoreAzureBlobConfig
- type ObjectStoreConfig
- type ObjectStoreGCSConfig
- type ObjectStoreS3Config
- type RemoteDownloadOptions
- type RemoteUploadOptions
- type StateAccessError
- type StateAccessErrorCode
- type StateConfig
- type StateEncryptionAWSKMSConfig
- type StateEncryptionAzureKeyVaultConfig
- type StateEncryptionConfig
- type StateEncryptionGCPKMSConfig
- type StateEncryptionKeyConfig
- type StateExporter
- type StateImporter
Constants ¶
const ( ObjectStoreProviderS3 = "s3" ObjectStoreProviderGCS = "gcs" ObjectStoreProviderAzureBlob = "azureblob" )
The object storage services the objectstore storage engine can keep state in, as set in ObjectStoreConfig.Provider.
const ( StorageEngineMemfile = "memfile" StorageEnginePostgres = "postgres" StorageEngineObjectstore = "objectstore" )
Variables ¶
This section is empty.
Functions ¶
func BuildPostgresDatabaseURL ¶
func BuildPostgresDatabaseURL(config *StateConfig) string
BuildPostgresDatabaseURL constructs a postgres connection URL from config. The user, password and database name are escaped, so a password containing characters such as "@", "/" or "#" connects as it is written.
func CreateTestTarGz ¶
CreateTestTarGz creates a valid tar.gz archive with the given file contents. This is exported for use by tests in other packages.
func DescribeState ¶ added in v0.10.0
func DescribeState(config *StateConfig) string
DescribeState returns a one-line description of where the engine config says state lives and whether it is encrypted at rest, for showing to the person running an import or export. It never includes credentials.
func DownloadRemoteFile ¶
func DownloadRemoteFile(ctx context.Context, filePath string, opts *RemoteDownloadOptions) ([]byte, error)
DownloadRemoteFile downloads a file from a remote storage location. Supports s3://, gcs://, and azureblob:// URL schemes.
func FindEngineConfigFile ¶ added in v0.10.0
FindEngineConfigFile returns the deploy engine config file the deploy engine itself would read: config.json in the default config directory, or else in the directory BLUELINK_DEPLOY_ENGINE_CONFIG_PATH names. It returns an empty path when there is none, in which case the deploy engine runs on its environment variables and defaults alone.
The deploy engine also reads config files in other formats, which this package cannot parse, so finding one of those is an error rather than a reason to fall back to the defaults and use the wrong state. The deploy engine's working directory is searched first too, but it is not searched here: it is rarely the directory the CLI runs in, and another project's config.json there would be taken for the engine's.
func GetDefaultEngineConfigPath ¶
func GetDefaultEngineConfigPath() string
GetDefaultEngineConfigPath returns the default engine config file path.
func GetDefaultStateDir ¶
func GetDefaultStateDir() string
GetDefaultStateDir returns the default state directory based on the OS.
func IsRemoteFile ¶
IsRemoteFile returns true if the file path refers to a remote storage location.
func ParseInstancesJSON ¶
func ParseInstancesJSON(data []byte) ([]state.InstanceState, error)
ParseInstancesJSON parses a JSON array of instances from raw bytes.
func SerializeInstancesJSON ¶
func SerializeInstancesJSON(instances []state.InstanceState) ([]byte, error)
SerializeInstancesJSON serializes instances to a JSON byte array.
func UploadRemoteFile ¶
func UploadRemoteFile(ctx context.Context, filePath string, data []byte, opts *RemoteUploadOptions) error
UploadRemoteFile uploads a file to a remote storage location. Supports s3://, gcs://, and azureblob:// URL schemes.
Types ¶
type ContainerStateExporter ¶
type ContainerStateExporter struct {
// contains filtered or unexported fields
}
ContainerStateExporter implements StateExporter using a state.Container. This works with any backend that implements the state.Container interface.
func NewContainerStateExporter ¶
func NewContainerStateExporter(container state.Container) *ContainerStateExporter
NewContainerStateExporter creates a new exporter that uses the given container.
func (*ContainerStateExporter) ExportInstances ¶
func (e *ContainerStateExporter) ExportInstances( ctx context.Context, instanceFilters []string, ) ([]state.InstanceState, error)
ExportInstances retrieves instances using the container's batch get operation. If instanceFilters is empty, all instances are exported.
An instance nested under another exported instance is exported only there, and an instance the filters name more than once is exported once.
type ContainerStateImporter ¶
type ContainerStateImporter struct {
// contains filtered or unexported fields
}
ContainerStateImporter implements StateImporter using a state.Container. This works with any backend that implements the state.Container interface. It uses the container's SaveBatch method for efficient bulk operations.
func NewContainerStateImporter ¶
func NewContainerStateImporter( container state.Container, opts ...ContainerStateImporterOption, ) *ContainerStateImporter
NewContainerStateImporter creates a new importer that uses the given container.
func (*ContainerStateImporter) ImportInstances ¶
func (i *ContainerStateImporter) ImportInstances(ctx context.Context, instances []state.InstanceState) error
ImportInstances saves the instances and their nested child blueprints, checking each child as an instance in its own right. Nothing is written unless every instance passes the checks: a new instance can't take another's name, an existing one can't be renamed, and an existing one with an operation in progress is refused unless the importer was created WithForce.
Existing instances get a version past both the stored and the imported one, so an objectstore engine holding the old version conflicts rather than writing over the import. Stop a memfile engine while importing; on postgres, only the in-progress check protects against a running engine.
type ContainerStateImporterOption ¶ added in v0.10.0
type ContainerStateImporterOption func(*ContainerStateImporter)
ContainerStateImporterOption configures a ContainerStateImporter.
func WithForce ¶ added in v0.10.0
func WithForce(force bool) ContainerStateImporterOption
WithForce allows importing over instances that have an operation in progress. It exists for a deployment that was lost or abandoned without its status being updated, which would otherwise leave the instance blocked from being imported over.
type EngineConfig ¶
type EngineConfig struct {
State StateConfig `json:"state"`
}
EngineConfig represents the deploy engine configuration file structure. Only the state-related fields are parsed.
func LoadEngineConfig ¶
func LoadEngineConfig(configFilePath string) (*EngineConfig, error)
LoadEngineConfig loads and parses a deploy engine configuration file.
State settings provided through the deploy engine's environment variables (BLUELINK_DEPLOY_ENGINE_STATE_*) take precedence over the file, matching how the deploy engine resolves its own configuration. Secrets such as encryption passphrases and storage credentials are commonly supplied this way.
func LoadEngineConfigFromEnv ¶ added in v0.10.0
func LoadEngineConfigFromEnv() (*EngineConfig, error)
LoadEngineConfigFromEnv builds a deploy engine configuration from the deploy engine's environment variables (BLUELINK_DEPLOY_ENGINE_STATE_*) and defaults alone, for a deploy engine that runs without a config file, as the deploy engine itself can.
type ErrorExplanation ¶ added in v0.10.0
type ErrorExplanation struct {
// Code is the error's code, such as "state_decryption_failed", or empty for an error
// that is not from this package.
Code string
// Summary is a short description of what failed. It can span several lines, such as
// the list of problems that stopped an import.
Summary string
// Hint says what to check or change to fix the error, or is empty.
Hint string
// Cause is the innermost error behind the summary, or is empty when there is none
// or it says nothing the summary does not.
Cause string
}
ErrorExplanation splits an import or export error into the parts a person reads: what failed, what to do about it, and the underlying cause.
func ExplainError ¶ added in v0.10.0
func ExplainError(err error) ErrorExplanation
ExplainError explains an error returned by Import or Export. Errors from this package are split into their summary, hint and innermost cause; any other error is returned whole as the summary.
type ExportError ¶
type ExportError struct {
Code ExportErrorCode
Message string
// Hint says what to check or change to fix the error, if anything.
Hint string
Err error
}
ExportError represents an error that occurred during export.
func (*ExportError) Error ¶
func (e *ExportError) Error() string
func (*ExportError) Unwrap ¶
func (e *ExportError) Unwrap() error
type ExportErrorCode ¶
type ExportErrorCode string
ExportErrorCode represents the type of export error.
const ( // ErrCodeExportFailed indicates a general export failure. ErrCodeExportFailed ExportErrorCode = "export_failed" // ErrCodeInstanceNotFound indicates one or more instances were not found. ErrCodeInstanceNotFound ExportErrorCode = "not_found" // ErrCodeRemoteUploadFailed indicates a remote upload failed. ErrCodeRemoteUploadFailed ExportErrorCode = "remote_upload_failed" // ErrCodeFileEncryptionFailed indicates the output file could not be encrypted // with the provided key. ErrCodeFileEncryptionFailed ExportErrorCode = "file_encryption_failed" )
type ExportInstancesResult ¶
ExportInstancesResult contains the result of an instances export.
func ExecuteInstancesExport ¶
func ExecuteInstancesExport( ctx context.Context, exporter StateExporter, instanceFilters []string, ) (*ExportInstancesResult, error)
ExecuteInstancesExport performs the instances export using the provided exporter.
type ExportParams ¶
type ExportParams struct {
// FilePath is the path to the output file (local or remote URL).
FilePath string
// InstanceFilters is a list of instance IDs or names to export.
// If empty, all instances are exported.
InstanceFilters []string
// EngineConfig contains the deploy engine configuration.
// Used to determine the storage backend (memfile or postgres).
EngineConfig *EngineConfig
// FileSystem is the filesystem to use for local file operations.
FileSystem afero.Fs
// Logger is the logger to use for logging.
Logger core.Logger
// RemoteOptions contains options for uploading to remote storage.
RemoteOptions *RemoteUploadOptions
// Exporter is an optional StateExporter for export.
// If not provided, a default exporter will be created based on EngineConfig.
Exporter StateExporter
// FileEncryption is the key the output file is encrypted with.
// When nil, the file is written as plaintext JSON.
FileEncryption *StateEncryptionKeyConfig
}
ExportParams contains the parameters for an export operation.
type ExportResult ¶
type ExportResult struct {
Success bool `json:"success"`
InstancesCount int `json:"instancesCount,omitempty"`
FilePath string `json:"filePath,omitempty"`
Message string `json:"message"`
// Encrypted is true when the output file was encrypted.
Encrypted bool `json:"encrypted,omitempty"`
// Warnings holds anything the caller should be told about the exported file,
// such as it holding state in plaintext that is encrypted at rest.
Warnings []string `json:"warnings,omitempty"`
}
ExportResult contains the result of an export operation.
func Export ¶
func Export(params ExportParams) (*ExportResult, error)
Export performs a state export operation based on the provided parameters. The output is a JSON array of blueprint instances.
type FileEncryptionKeyOptions ¶ added in v0.10.0
type FileEncryptionKeyOptions struct {
// Key names a key held outside the CLI as "<provider>:<id>", for example
// "awskms:alias/state-export", "gcpkms:projects/p/locations/l/keyRings/r/cryptoKeys/k",
// "azurekeyvault:https://vault.vault.azure.net/keys/name" or "localkey:/path/to/key".
Key string
// PassphraseFile is the path to a file holding the passphrase.
PassphraseFile string
// Passphrase is a passphrase taken from the environment. It is never accepted as a
// command line flag value, which would leave it in shell history and CI logs.
Passphrase string
}
FileEncryptionKeyOptions holds the ways a CLI can name the key an export file is encrypted or decrypted with.
type ImportError ¶
type ImportError struct {
Code ImportErrorCode
Message string
// Hint says what to check or change to fix the error, if anything.
Hint string
Err error
}
ImportError represents an error that occurred during import.
func (*ImportError) Error ¶
func (e *ImportError) Error() string
func (*ImportError) Unwrap ¶
func (e *ImportError) Unwrap() error
type ImportErrorCode ¶
type ImportErrorCode string
ImportErrorCode represents the type of import error.
const ( // ErrCodeInvalidJSON indicates the JSON input is malformed. ErrCodeInvalidJSON ImportErrorCode = "invalid_json" // ErrCodeFileNotFound indicates the input file was not found. ErrCodeFileNotFound ImportErrorCode = "file_not_found" // ErrCodeRemoteAccessFail indicates a remote file could not be accessed. ErrCodeRemoteAccessFail ImportErrorCode = "remote_access_failed" // ErrCodeFileKeyRequired indicates the input file is encrypted and no key was provided. ErrCodeFileKeyRequired ImportErrorCode = "file_key_required" // ErrCodeFileDecryptionFailed indicates the input file could not be decrypted // with the provided key. ErrCodeFileDecryptionFailed ImportErrorCode = "file_decryption_failed" // ErrCodeFileNotEncrypted indicates the input file is plaintext although the import // required an encrypted one. ErrCodeFileNotEncrypted ImportErrorCode = "file_not_encrypted" // ErrCodeInstanceNameConflict indicates a new instance in the input uses a name // another instance already has. ErrCodeInstanceNameConflict ImportErrorCode = "instance_name_conflict" // ErrCodeInstanceNameImmutable indicates the input renames an existing instance. ErrCodeInstanceNameImmutable ImportErrorCode = "instance_name_immutable" // ErrCodeInstanceOperationInProgress indicates the input would overwrite an instance // an engine is still working on. ErrCodeInstanceOperationInProgress ImportErrorCode = "instance_operation_in_progress" // ErrCodeChildBlueprintCycle indicates instances in the input are children of each // other in a cycle, so none of them is a top-level instance to import them under. ErrCodeChildBlueprintCycle ImportErrorCode = "child_blueprint_cycle" // ErrCodeInstanceCopiesDiffer indicates an instance appears more than once in the // input and the copies are not the same. ErrCodeInstanceCopiesDiffer ImportErrorCode = "instance_copies_differ" // ErrCodeChildBlueprintMultipleParents indicates the input lists an instance as a child // blueprint of more than one parent, or under more than one name in one parent. ErrCodeChildBlueprintMultipleParents ImportErrorCode = "child_blueprint_multiple_parents" )
type ImportInstancesResult ¶
type ImportInstancesResult struct {
InstancesCount int
}
ImportInstancesResult contains the result of an instances import.
func ExecuteInstancesImport ¶
func ExecuteInstancesImport( ctx context.Context, importer StateImporter, data []byte, ) (*ImportInstancesResult, error)
ExecuteInstancesImport performs the instances import using the provided importer.
type ImportParams ¶
type ImportParams struct {
// FilePath is the path to the input file (local or remote URL).
FilePath string
// EngineConfig contains the deploy engine configuration.
// Used to determine the storage backend (memfile or postgres).
EngineConfig *EngineConfig
// FileSystem is the filesystem to use for operations.
FileSystem afero.Fs
// Logger is the logger to use for logging.
Logger core.Logger
// FileData contains the raw file data to import.
// If provided, FilePath is ignored for reading (but may be used for logging).
FileData []byte
// RemoteOptions contains options for downloading from remote storage.
RemoteOptions *RemoteDownloadOptions
// Importer is an optional StateImporter for import.
// If not provided, a default importer will be created based on EngineConfig.
Importer StateImporter
// FileEncryption is the key to decrypt the input file with when it is encrypted.
// Encrypted files are detected, so this is only needed for those.
FileEncryption *StateEncryptionKeyConfig
// RequireEncryptedFile refuses an input file that is not encrypted. Set it when a key
// was given for this import in particular, so that a file someone replaced with a
// plaintext one is not imported as if it had been decrypted. A key that applies to
// every import, such as a passphrase in a pipeline's environment, should not set it.
RequireEncryptedFile bool
// Force allows importing over instances that have an operation in progress.
// See WithForce. It does not apply to a custom Importer, which is created with its
// own options.
Force bool
}
ImportParams contains the parameters for an import operation.
type ImportResult ¶
type ImportResult struct {
Success bool `json:"success"`
InstancesCount int `json:"instancesCount,omitempty"`
Message string `json:"message"`
// Encrypted is true when the input file was an encrypted export file.
Encrypted bool `json:"encrypted,omitempty"`
// FileExportedAt is when an encrypted input file was exported. It is bound to the
// file's encryption, so it can be relied on to tell an older export from the one
// expected. It is zero for a plaintext file.
FileExportedAt time.Time `json:"fileExportedAt,omitzero"`
}
ImportResult contains the result of an import operation.
func Import ¶
func Import(params ImportParams) (*ImportResult, error)
Import performs a state import operation based on the provided parameters. The input file must be a JSON array of blueprint instances.
type ObjectStoreAzureBlobConfig ¶ added in v0.10.0
type ObjectStoreAzureBlobConfig struct {
ServiceURL string `json:"service_url"`
AccountName string `json:"account_name"`
AccountKey string `json:"account_key"`
Container string `json:"container"`
}
ObjectStoreAzureBlobConfig configures the Azure Blob Storage-backed objectstore storage engine.
type ObjectStoreConfig ¶ added in v0.10.0
type ObjectStoreConfig struct {
// Provider is one of "s3", "gcs" or "azureblob".
Provider string `json:"provider"`
// Prefix is prepended to every storage key in the bucket or container.
Prefix string `json:"prefix"`
S3 ObjectStoreS3Config `json:"s3"`
GCS ObjectStoreGCSConfig `json:"gcs"`
AzureBlob ObjectStoreAzureBlobConfig `json:"azureblob"`
}
ObjectStoreConfig mirrors the deploy engine's objectstore storage engine configuration.
type ObjectStoreGCSConfig ¶ added in v0.10.0
type ObjectStoreGCSConfig struct {
Bucket string `json:"bucket"`
Endpoint string `json:"endpoint"`
WithoutAuthentication bool `json:"without_authentication"`
}
ObjectStoreGCSConfig configures the Google Cloud Storage-backed objectstore storage engine.
type ObjectStoreS3Config ¶ added in v0.10.0
type ObjectStoreS3Config struct {
Bucket string `json:"bucket"`
Region string `json:"region"`
Endpoint string `json:"endpoint"`
UsePathStyle bool `json:"use_path_style"`
AccessKeyID string `json:"access_key_id"`
SecretAccessKey string `json:"secret_access_key"`
}
ObjectStoreS3Config configures the S3-backed objectstore storage engine.
type RemoteDownloadOptions ¶
type RemoteDownloadOptions struct {
// S3Endpoint overrides the default S3 endpoint (useful for testing with LocalStack).
S3Endpoint string
// S3UsePathStyle enables path-style addressing for S3 (required for LocalStack).
S3UsePathStyle bool
// GCSEndpoint overrides the default GCS endpoint (useful for testing with fake-gcs-server).
GCSEndpoint string
// AzureConnectionString is the connection string for Azure Blob Storage.
// If empty, DefaultAzureCredential will be used.
AzureConnectionString string
}
RemoteDownloadOptions contains options for downloading files from remote storage.
type RemoteUploadOptions ¶
type RemoteUploadOptions struct {
// S3Endpoint overrides the default S3 endpoint (useful for testing with LocalStack).
S3Endpoint string
// S3UsePathStyle enables path-style addressing for S3 (required for LocalStack).
S3UsePathStyle bool
// GCSEndpoint overrides the default GCS endpoint (useful for testing with fake-gcs-server).
GCSEndpoint string
// AzureConnectionString is the connection string for Azure Blob Storage.
// If empty, DefaultAzureCredential will be used.
AzureConnectionString string
}
RemoteUploadOptions contains options for uploading files to remote storage.
type StateAccessError ¶ added in v0.10.0
type StateAccessError struct {
Code StateAccessErrorCode
// Message is a short summary of what failed.
Message string
// Hint says what to check or change to fix the error, if anything.
Hint string
Err error
}
StateAccessError represents an error opening the state an import or export works on.
func (*StateAccessError) Error ¶ added in v0.10.0
func (e *StateAccessError) Error() string
func (*StateAccessError) Unwrap ¶ added in v0.10.0
func (e *StateAccessError) Unwrap() error
type StateAccessErrorCode ¶ added in v0.10.0
type StateAccessErrorCode string
StateAccessErrorCode represents the reason state could not be opened for an import or export.
const ( // could not be built from the engine config, for example a missing passphrase, // an unreadable key file or an unreachable key management service. ErrCodeEncryptionKeyUnavailable StateAccessErrorCode = "encryption_key_unavailable" // ErrCodeStateDecryptionFailed indicates encrypted state could not be decrypted // with the configured key. ErrCodeStateDecryptionFailed StateAccessErrorCode = "state_decryption_failed" // ErrCodeStateConfigInvalid indicates the deploy engine's state configuration, from its // config file or environment variables, cannot be used as it is. ErrCodeStateConfigInvalid StateAccessErrorCode = "state_config_invalid" // for example a database or bucket that cannot be connected to. ErrCodeStateUnavailable StateAccessErrorCode = "state_unavailable" )
type StateConfig ¶
type StateConfig struct {
StorageEngine string `json:"storage_engine"`
MemFileStateDir string `json:"memfile_state_dir"`
PostgresUser string `json:"postgres_user"`
PostgresPassword string `json:"postgres_password"`
PostgresHost string `json:"postgres_host"`
PostgresPort int `json:"postgres_port"`
PostgresDatabase string `json:"postgres_database"`
PostgresSSLMode string `json:"postgres_ssl_mode"`
PostgresPoolMaxConns int `json:"postgres_pool_max_conns"`
PostgresPoolMaxConnLifetime string `json:"postgres_pool_max_conn_lifetime"`
// Encryption holds the configuration for encrypting persisted state at rest.
// The deploy engine only supports this for the memfile storage engine.
Encryption StateEncryptionConfig `json:"encryption"`
// ObjectStore holds the configuration for the objectstore storage engine.
ObjectStore ObjectStoreConfig `json:"objectstore"`
}
StateConfig holds the state-related configuration from an engine config file. This is a subset of the deploy engine's StateConfig, containing only the fields needed for state import/export operations.
type StateEncryptionAWSKMSConfig ¶ added in v0.10.0
type StateEncryptionAWSKMSConfig struct {
KeyID string `json:"key_id"`
Region string `json:"region"`
Endpoint string `json:"endpoint"`
AccessKeyID string `json:"access_key_id"`
SecretAccessKey string `json:"secret_access_key"`
}
StateEncryptionAWSKMSConfig configures state encryption against AWS KMS.
type StateEncryptionAzureKeyVaultConfig ¶ added in v0.10.0
type StateEncryptionAzureKeyVaultConfig struct {
VaultURL string `json:"vault_url"`
KeyName string `json:"key_name"`
KeyVersion string `json:"key_version"`
Algorithm string `json:"algorithm"`
}
StateEncryptionAzureKeyVaultConfig configures state encryption against Azure Key Vault.
type StateEncryptionConfig ¶ added in v0.10.0
type StateEncryptionConfig struct {
Enabled bool `json:"enabled"`
// StateEncryptionKeyConfig is embedded so the active key's fields sit directly
// under "encryption", matching the deploy engine's config file layout.
StateEncryptionKeyConfig
// PreviousKeys holds keys that state is no longer encrypted with but that
// objects written before a key change may still be sealed with.
PreviousKeys []StateEncryptionKeyConfig `json:"previous_keys"`
}
StateEncryptionConfig mirrors the deploy engine's state encryption configuration.
type StateEncryptionGCPKMSConfig ¶ added in v0.10.0
type StateEncryptionGCPKMSConfig struct {
KeyName string `json:"key_name"`
CredentialsFile string `json:"credentials_file"`
}
StateEncryptionGCPKMSConfig configures state encryption against Google Cloud KMS.
type StateEncryptionKeyConfig ¶ added in v0.10.0
type StateEncryptionKeyConfig struct {
// Provider is one of "passphrase", "localkey", "awskms", "gcpkms" or "azurekeyvault".
Provider string `json:"provider"`
Passphrase string `json:"passphrase"`
PassphraseFile string `json:"passphrase_file"`
LocalKeyFile string `json:"local_key_file"`
AWSKMS StateEncryptionAWSKMSConfig `json:"awskms"`
GCPKMS StateEncryptionGCPKMSConfig `json:"gcpkms"`
AzureKeyVault StateEncryptionAzureKeyVaultConfig `json:"azurekeyvault"`
}
StateEncryptionKeyConfig identifies one key that state is, or was, encrypted with.
func ResolveFileEncryptionKey ¶ added in v0.10.0
func ResolveFileEncryptionKey(opts FileEncryptionKeyOptions) (*StateEncryptionKeyConfig, error)
ResolveFileEncryptionKey returns the key configuration an export file is encrypted or decrypted with, or nil when no key was given.
A key or passphrase file given explicitly takes precedence over a passphrase from the environment, which may be set for every job in a pipeline. Giving both a key and a passphrase file is an error, since it is unclear which was meant.
type StateExporter ¶
type StateExporter interface {
// ExportInstances exports instances by their IDs or names.
// If instanceFilters is empty, exports all instances.
// Returns the full instance state including child blueprints. Each instance is
// returned once: one nested under another returned instance is only returned there.
ExportInstances(ctx context.Context, instanceFilters []string) ([]state.InstanceState, error)
}
StateExporter defines the interface for exporting instance state data. This abstraction allows different storage backends to implement their own export logic with optimal performance characteristics.
type StateImporter ¶
type StateImporter interface {
// ImportInstances imports a slice of instance states.
// Implementations should handle batch operations efficiently where possible.
ImportInstances(ctx context.Context, instances []state.InstanceState) error
}
StateImporter defines the interface for importing instance state data. This abstraction allows different storage backends to implement their own import logic with optimal performance characteristics.