swarmtool

package module
v0.0.0-...-4238f92 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backup

type Backup struct {
	BackupOutputDir string
	Filename        string
	BackupDir       string
	Hot             bool
	S3Client        S3Client
	S3Bucket        string
	Cluster         *Cluster
	Dockerd         *Dockerd
}

Backup compresses and uploads a directory to s3 bucket.

func (*Backup) Run

func (b *Backup) Run() error

Run starts hot/cold backup based on configuration and swarm cluster's state

type Cluster

type Cluster struct {
	Client DockerClient
}

Cluster represents a cluster of swarm nodes.

func (*Cluster) IsSafeToShutdown

func (c *Cluster) IsSafeToShutdown() bool

IsSafeToShutdown checks if cluster stays functional after shutting down a manager node.

type ClusterClient

type ClusterClient struct {
	Client *client.Client
}

ClusterClient implements DockerClient for cluster operations.

func (*ClusterClient) ManagerList

func (c *ClusterClient) ManagerList(ctx context.Context) ([]*Node, error)

ManagerList returns list of manager nodes.

type Config

type Config struct {
	BackupOutputDir   string `mapstructure:"backup_output_dir"`
	Filename          string `mapstructure:"filename"`
	BackupDir         string `mapstructure:"backup_dir"`
	HotBackup         bool   `mapstructure:"hot_backup"`
	S3AccessKeyID     string `mapstructure:"s3_access_key_id"`
	S3SecretAccessKey string `mapstructure:"s3_secret_access_key"`
	S3BucketName      string `mapstructure:"s3_bucket"`
	S3EndpointUrl     string `mapstructure:"s3_endpoint_url"`
}

type Connection

type Connection interface {
	StartUnit(ctx context.Context, name string) error
	StopUnit(ctx context.Context, name string) error
	Status(ctx context.Context, name string) (string, error)
	Close()
}

Connection is a connection to systemd's dbus endpoint.

type DbusConnection

type DbusConnection struct {
	Conn *dbus.Conn
}

DbusConnection implements Connection.

func (*DbusConnection) Close

func (d *DbusConnection) Close()

func (*DbusConnection) StartUnit

func (d *DbusConnection) StartUnit(ctx context.Context, name string) error

StartUnit starts specified unit.

func (*DbusConnection) Status

func (d *DbusConnection) Status(ctx context.Context, name string) (string, error)

Status returns status of specified unit.

func (*DbusConnection) StopUnit

func (d *DbusConnection) StopUnit(ctx context.Context, name string) error

StopUnit stops specified unit.

type DockerClient

type DockerClient interface {
	ManagerList(ctx context.Context) ([]*Node, error)
}

DockerClient is the API client that performs all operations against a docker server.

type Dockerd

type Dockerd struct {
	DbusConn Connection
}

Dockerd manages docker daemon.

func (*Dockerd) IsActive

func (d *Dockerd) IsActive() (bool, error)

IsActive checks if docker service is running.

func (*Dockerd) Start

func (d *Dockerd) Start() error

Start starts docker service.

func (*Dockerd) Status

func (d *Dockerd) Status() (string, error)

Status returns status of docker service.

func (*Dockerd) Stop

func (d *Dockerd) Stop() error

Stop stops docker service.

type MinIOClient

type MinIOClient struct {
	Client *minio.Client
}

MinIOClient implements S3Client.

func (*MinIOClient) Upload

func (c *MinIOClient) Upload(ctx context.Context, bucketName, filePath string) error

Upload creates an object in a bucket, with contents from file at filePath.

type Node

type Node struct {
	Reachability string
}

Node represents a swarm node.

func (*Node) IsActive

func (n *Node) IsActive() bool

IsActive checks if a node is reachable or not.

type S3Client

type S3Client interface {
	Upload(ctx context.Context, bucketName, filePath string) error
}

S3Client amazon s3 compatible methods.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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