src

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CONFIG string // Path/name to config file to be parsed, defaults to whatever
View Source
var NAME string // Name of remote to add/delete/update, etc.

Functions

func CheckUserYesNo

func CheckUserYesNo(input string, defaultyes bool) (b bool, e error)

func DefName

func DefName(scan *bufio.Scanner) (name string)

Types

type Client

type Client struct {
	// Specific s3 client for this remote
	Client *s3.S3
	// Set of options for this remote
	RemoteOptions Remote
}

A single remote config and its accompanying s3 client.

type Clients

type Clients struct {
	// Array of remotes.
	Remotes []Client
}

List of all remotes and their s3 client for utilizing for synching.

type LocalFileSummary

type LocalFileSummary struct {
	// Name of object
	Name string
	// Pointer to some file object that is either an s3 object version or an os.File
	File *os.File
	// Error if there was any with finding the operation.
	Error error
}

type OptionMeta

type OptionMeta struct {
	// The exact file descriptor of the options file.
	File *os.File
	// Raw file data of the options file
	FileData []byte
	// Absolute path to options file
	FilePath string
	// Unmarshalled options information
	Options *Options

	// List of s3 clients for each of the remotes that are defined in
	// the options file. Depending on mode there could be only 1 client in the object.
	Clients []Client
	// Earlier parts of the program find the default remote, and this will be the
	// index value for downstream operation to reference the slice instance without having to do all sorts
	// of stuff with finding the default value again.
	DefaultRemoteIndex int
	// This is the default client referenced by the "default" synching routine.
	DefClient *Client
}

func NewOptions

func NewOptions() (o *OptionMeta)

Import options from options.json file in the local directory of where the binary is.

func (*OptionMeta) AddRemote

func (o *OptionMeta) AddRemote()

Adds new remote to current options object.

func (*OptionMeta) GetNewestLocalDB

func (o *OptionMeta) GetNewestLocalDB() (name string, file *os.File, e error)

Finds the newest version of the key database within the desired directory, defaults to the working directory of the binary.

func (*OptionMeta) GetNewestRemoteDB

func (o *OptionMeta) GetNewestRemoteDB() (name string, file *s3.ObjectVersion, client *Client, e error)

Looks at the default remote in the options file and then returns the file info/modtime for the newest

func (*OptionMeta) HandleDefaults

func (o *OptionMeta) HandleDefaults()

func (*OptionMeta) NewS3Client

func (o *OptionMeta) NewS3Client(name string, def bool) (c *Client, e error)

Returns a new s3 Client according to the specified remote name.

func (*OptionMeta) PrintRemotes

func (o *OptionMeta) PrintRemotes(printkey bool)

Prints each of the remotes out to stout.

func (*OptionMeta) PulltoLocal

func (o *OptionMeta) PulltoLocal(rinfo *RemoteFileSumary, linfo *LocalFileSummary) error

func (*OptionMeta) PushPull

func (o *OptionMeta) PushPull() error

Main function that either triggers a pull of the newer version of the database from the default remote, or will upload the current version of the database locally to the remote. Designed to be used by default running of the binary or in "sync" mode.

func (*OptionMeta) PushtoRemote

func (o *OptionMeta) PushtoRemote(rinfo *RemoteFileSumary, linfo *LocalFileSummary) error

func (*OptionMeta) RemoveRemote

func (o *OptionMeta) RemoveRemote()

func (*OptionMeta) S3ClientsAll

func (o *OptionMeta) S3ClientsAll() (c *Clients)

func (*OptionMeta) SaveOptions

func (o *OptionMeta) SaveOptions() error

Save updates to disk.

func (*OptionMeta) SyncOptionsToDisk

func (o *OptionMeta) SyncOptionsToDisk() error

func (*OptionMeta) UpdateRemote

func (o *OptionMeta) UpdateRemote()

type Options

type Options struct {
	// Specifies the supposed name of the databse that you want to sync
	// with this binary. Should be a name
	DatabaseName string `json:"db_name" yaml:"DatabaseName"`
	// Use this regex to match files in the specified directory and just choose
	// the newest file that is matched by tyhe regex.
	DatabaseRegex string `json:"db_regex" yaml:"DatabaseRegex"`
	// Array of remotes that can be uploaded to/downloaded form.
	Remotes []Remote `json:"remotes" yaml:"Remotes"`
}

Primary options struct, options.json/.yml/.yaml file unmarshalls into this

type Remote

type Remote struct {
	// Name of the remote endpoint.
	Name string `json:"name" yaml:"Name"`
	// Actual URI of the endpoint.
	Endpoint string `json:"endpoint" yaml:"Endpoint"`
	// Specify the region of the endpoint to pass in to the sdk.
	Region string `json:"region" yaml:"Region"`
	// Specify the bucket name to sync with
	Bucket string `json:"bucket" yaml:"Bucket"`
	// API key id of the remote.
	Id string `json:"api_id" yaml:"ApiId"`
	// API key of the remote.
	Key string `json:"api_key" yaml:"ApiKey"`
	// Only one of these remotes can be specified as default, but if this
	// bool is set to true, the binary will default to try and sync with
	// this remote as the first attempt. Only one remote in each file can be set
	// to default, otherwise the "default" remote will be inconsistently chosen.
	IsDefault bool `json:"isdefault" yaml:"IsDefault"`
}

Describes a remote object, or a specific instance

type RemoteFileSumary

type RemoteFileSumary struct {
	// Name of object
	Name string
	// Pointer to some file object that is either an s3 object version or an os.File
	File *s3.ObjectVersion
	// Error if there was any with finding the operation.
	Error error
	// Return client that should be used for future operations.
	Client *Client
}

Directories

Path Synopsis
config

Jump to

Keyboard shortcuts

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