cloud

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CloudProvider

type CloudProvider interface {
	// Name returns the provider name (aws, azure, gcp)
	Name() string

	// ValidateInstance checks if instance is accessible via remote management
	// (SSM for AWS, Run Command for Azure, OS Login for GCP).
	// Returns error if instance is not online or not manageable.
	ValidateInstance(ctx context.Context, instance *Instance) error

	// ExecuteCommand executes shell commands remotely on the instance.
	// commands: slice of commands to execute
	// timeout: maximum execution time
	// Returns execution result with stdout, stderr and exit code.
	ExecuteCommand(ctx context.Context, instance *Instance, commands []string, timeout time.Duration) (*CommandResult, error)

	// TestConnectivity tests network connectivity from instance to a host:port.
	// Useful for validating if instance can reach external services
	// (e.g., Puppet Server on port 8140).
	TestConnectivity(ctx context.Context, instance *Instance, host string, port int) error

	// TagInstance adds tags/labels to the instance.
	// tags: map of key-value to apply
	// Used to mark instances after successful installation.
	TagInstance(ctx context.Context, instance *Instance, tags map[string]string) error

	// HasTag checks if instance already has a specific tag.
	// Useful for idempotency - don't reprocess already configured instances.
	HasTag(ctx context.Context, instance *Instance, key, value string) (bool, error)
}

CloudProvider abstracts operations for any cloud provider (AWS, Azure, GCP). This interface defines the "contract" that any cloud implementation must follow. This allows us to write generic code that works with any cloud!

type CommandResult

type CommandResult struct {
	InstanceID string        // ID of instance where command was executed
	ExitCode   int           // Command exit code (0 = success)
	Stdout     string        // Standard output of the command
	Stderr     string        // Error output of the command
	Duration   time.Duration // Time it took to execute
	Error      error         // Go error (if any) during execution
}

CommandResult encapsulates the result of a remote command execution

func (*CommandResult) Failed

func (cr *CommandResult) Failed() bool

Failed returns true if command failed

func (*CommandResult) Success

func (cr *CommandResult) Success() bool

Success returns true if command executed successfully (exit code 0)

type Instance

type Instance struct {
	ID       string            // Unique instance ID (e.g., i-1234567890abcdef0)
	Cloud    string            // Provider: "aws", "azure", "gcp"
	Account  string            // Account/Subscription/Project ID
	Region   string            // Instance region (e.g., us-east-1)
	Metadata map[string]string // Optional extra data (existing tags, hostname, etc)
}

Instance represents a generic VM instance in any cloud. This struct is cloud-agnostic - works for AWS EC2, Azure VM, GCP Compute.

func (*Instance) String

func (i *Instance) String() string

String returns readable representation of the instance

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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