backend

package
v0.0.0-...-e5e9e03 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

README

Backend Package

The Backend package provides a unified interface for managing cloud infrastructure across multiple cloud providers (AWS, GCP, Docker). It abstracts cloud-specific operations and provides a consistent API for cluster management, instance provisioning, and resource management.

Overview

This package serves as the main entry point for cloud backend operations in Aerolab. It initializes and manages different cloud backends through a plugin-like architecture where each cloud provider is implemented as a separate backend.

Supported Backends

  • AWS (baws) - Amazon Web Services backend
  • GCP (bgcp) - Google Cloud Platform backend
  • Docker (bdocker) - Local Docker backend for development/testing

Key Components

Main Functions
  • New(project string, c *Config, pollInventoryHourly bool, enabledBackends []backends.BackendType, setInventory *backends.Inventory) (backends.Backend, error) - Creates a new backend instance with specified configuration and enabled cloud providers
Configuration

The Config type (alias for backends.Config) contains all necessary configuration for backend initialization including:

  • Root directory for backend data
  • Caching settings
  • Log level configuration
  • Aerolab version information
  • Credentials for cloud providers

Subpackages

backends

Core backend interface definitions and common functionality shared across all cloud providers.

clouds

Cloud-specific implementations:

  • baws - AWS implementation with EC2, EKS, IAM, Route53 integration
  • bgcp - GCP implementation with Compute Engine integration
  • bdocker - Docker implementation for local development
cache

Caching layer for backend operations to improve performance and reduce API calls.

Usage

Basic Backend Initialization
import (
    "github.com/aerospike/aerolab/pkg/backend"
    "github.com/aerospike/aerolab/pkg/backend/backends"
)

config := &backend.Config{
    RootDir:         "/path/to/aerolab",
    Cache:           true,
    LogLevel:        4,
    AerolabVersion:  "8.0.0",
    ListAllProjects: false,
}

// Initialize backend with AWS and GCP support
backend, err := backend.New("my-project", config, true, 
    []backends.BackendType{backends.BackendTypeAWS, backends.BackendTypeGCP}, nil)
if err != nil {
    log.Fatal(err)
}
Multi-Cloud Operations

The backend package allows you to work with multiple cloud providers simultaneously:

// Add regions for different providers
err = backend.AddRegion(backends.BackendTypeAWS, "us-west-2")
err = backend.AddRegion(backends.BackendTypeGCP, "us-central1-a")

// Operations work across all configured backends
inventory := backend.GetInventory()
instances := inventory.Instances.Describe()

Architecture

The backend package uses a plugin architecture where:

  1. Each cloud provider implements the backends.Cloud interface
  2. Backends are registered during package initialization
  3. The main backend multiplexes operations across enabled backends
  4. Common operations (caching, inventory management) are handled centrally

This design allows for easy extension to new cloud providers while maintaining a consistent API for users.

Error Handling

The backend package provides comprehensive error handling with context about which cloud provider and operation failed. Errors are wrapped to provide clear debugging information.

Thread Safety

All backend operations are designed to be thread-safe, with appropriate locking mechanisms for shared resources like inventory caches and configuration data.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(project string, c *Config, pollInventoryHourly bool, enabledBackends []backends.BackendType, setInventory *backends.Inventory) (backends.Backend, error)

New creates and initializes a new multi-cloud backend instance with the specified configuration. This is the main entry point for creating backend instances that can manage resources across multiple cloud providers simultaneously.

The function automatically registers and initializes all available cloud backends (AWS, GCP, Docker) based on the enabledBackends parameter. It sets up inventory polling, credential management, and caching as specified in the configuration.

Parameters:

  • project: The project name/identifier for resource organization and tagging
  • c: Backend configuration containing credentials, settings, and options
  • pollInventoryHourly: Whether to automatically refresh inventory every hour
  • enabledBackends: List of backend types to enable (AWS, GCP, Docker, etc.)
  • setInventory: Optional pre-populated inventory to use instead of discovering resources

Returns:

  • backends.Backend: The initialized backend interface for managing cloud resources
  • error: nil on success, or an error if initialization fails

Usage:

config := &backend.Config{
    RootDir:         "/path/to/aerolab",
    Cache:           true,
    LogLevel:        4,
    AerolabVersion:  "8.0.0",
}

backend, err := backend.New("my-project", config, true,
    []backends.BackendType{backends.BackendTypeAWS, backends.BackendTypeGCP}, nil)
if err != nil {
    log.Fatal(err)
}

Types

type Config

type Config backends.Config

Config is an alias for backends.Config, providing a simplified interface for backend configuration. It contains all necessary settings for initializing cloud backends including credentials, logging, caching, and project settings.

Directories

Path Synopsis
Package backendtest provides reusable test doubles for the backends package: a FakeBackend (implementing backends.Backend), a FakeCloud (implementing backends.Cloud), inventory fixture builders, and a helper for registering a fake Cloud in the global registry with automatic cleanup.
Package backendtest provides reusable test doubles for the backends package: a FakeBackend (implementing backends.Backend), a FakeCloud (implementing backends.Cloud), inventory fixture builders, and a helper for registering a fake Cloud in the global registry with automatic cleanup.
bgcp/iap
Package iap provides a thin adapter around github.com/cedws/iapc/iap that hides the third-party import behind aerolab-shaped types.
Package iap provides a thin adapter around github.com/cedws/iapc/iap that hides the third-party import behind aerolab-shaped types.
sshkey
Package sshkey manages the SSH key pair that a project's instances are created with.
Package sshkey manages the SSH key pair that a project's instances are created with.

Jump to

Keyboard shortcuts

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