pkg

package
v0.0.0-...-54838ba Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorLog *log.Logger

ErrorLog is the default error log to use

Log is the default log to use

View Source
var VerboseMode bool

VerboseMode is a global switch to turn verbose mode off or on

Functions

func AlertError

func AlertError(alertingConfig *AlertingConfig, message string, err error)

AlertError alerts an error to the system administrator

func AlertMessage

func AlertMessage(alertingConfig *AlertingConfig, message string)

AlertMessage simply alerts a message to the correct channels

func CreateVolume

func CreateVolume(createRequest *godo.VolumeCreateRequest, digitalOceanClient *DigitalOceanClient) (*godo.Volume, error)

CreateVolume creates a DigitalOcean volume

func DestroyVolume

func DestroyVolume(volumeID string, digitalOceanClient *DigitalOceanClient) error

DestroyVolume destroys a volume

func DirSize

func DirSize(path string) (int64, error)

DirSize get size of directory

func DownloadFileFromBucket

func DownloadFileFromBucket() error

DownloadFileFromBucket downloads a file

func FileOrDirSize

func FileOrDirSize(path string) (int64, error)

FileOrDirSize gets the size of a directory or file

func FindVolume

func FindVolume(id string, digitalOceanClient *DigitalOceanClient) (*godo.Volume, error)

FindVolume finds a DigitalOcean volume by ID

func GetRunningInstanceData

func GetRunningInstanceData() (*metadata.Metadata, error)

GetRunningInstanceData returns current droplets data

func MountVolume

func MountVolume(volumeName string, mountPoint string, volumeID string, dropletID int, digitalOceanClient *DigitalOceanClient) error

MountVolume mounts volume on machine and won't return until complete

func ParseCommandLineFlags

func ParseCommandLineFlags(args []string) error

ParseCommandLineFlags parsed flags defined by `flag` package. Required to work with sub-commands

func PerformCommand

func PerformCommand(cmdArgs ...string) (string, error)

PerformCommand performs a command line command with nice helpers

func PerformCommandWithFileOutput

func PerformCommandWithFileOutput(outputFilename string, cmd string, cmdArgs ...string) error

PerformCommandWithFileOutput performs a command with output to a file

func ReportProgressOnCopy

func ReportProgressOnCopy(source string, destination string, doneChan chan bool)

ReportProgressOnCopy will start printing the size of a file/directory in relation to another file/directory If source file/directory does not exist it will return immediately

func ReportProgressOnFileSize

func ReportProgressOnFileSize(location string, expectedSize int64, doneChan chan bool)

ReportProgressOnFileSize will start printing the size of a file in relation to what the expected size is

func UnmountVolume

func UnmountVolume(mountPoint string, volumeID string, dropletID int, digitalOceanClient *DigitalOceanClient) error

UnmountVolume unmounts a volume

func UploadFileToBucket

func UploadFileToBucket(bucketName string, objectName string, filePath string, minioClient *minio.Client) error

UploadFileToBucket uploads a file to a DigitalOcean bucket

func WithRetry

func WithRetry(tag string, runner func() error) error

WithRetry runs runner, and if it returns an error waits again, then tries again

Types

type AlertingConfig

type AlertingConfig struct {
	Slack *alerting.SlackConfig `json:"slack"`
}

AlertingConfig sub-config type for alerting related

type DigitalOceanClient

type DigitalOceanClient struct {
	AccessToken string
	Context     context.Context
	Client      *godo.Client
}

DigitalOceanClient is a wrapper to be able to make calls to the DigitalOcean API

func NewDigitalOceanClient

func NewDigitalOceanClient(accessToken string) *DigitalOceanClient

NewDigitalOceanClient creates a client

func (*DigitalOceanClient) Token

func (t *DigitalOceanClient) Token() (*oauth2.Token, error)

Token exists to conform to the oauth2.TokenSource interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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