porter

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package porter is the superset of things that can operate the suitcases and such

This package came about because I found myself having these giant functions that had to pass in tons of individual items to get everything it needed. This object is an attempt to simplify all those in to one cohesive bit

Index

Constants

View Source
const (
	// PorterKey is where we sneak porter in to the cmd contexs.
	PorterKey contextKey = iota
)

Variables

This section is empty.

Functions

func CalculateHash

func CalculateHash(rd io.Reader, ht string) (string, error)

CalculateHash returns a certain type of hash string and an optional error

func GetCurrentUser

func GetCurrentUser() (string, error)

GetCurrentUser just returns the current user and an error if one occurred

func MustCalculateHash

func MustCalculateHash(rd io.Reader, ht string) string

MustCalculateHash returns a certain type of hash string and panics on error

func WithCLIMeta

func WithCLIMeta(c *CLIMeta) func(*Porter)

WithCLIMeta sets CLIMeta at create time

func WithCmdArgs

func WithCmdArgs(cmd *cobra.Command, args []string) func(*Porter)

WithCmdArgs sets cobra command and args

func WithDestination

func WithDestination(s string) func(*Porter)

WithDestination sets the destination at create time

func WithHashAlgorithm

func WithHashAlgorithm(h inventory.HashAlgorithm) func(*Porter)

WithHashAlgorithm sets the hash algorithm at create time

func WithInventory

func WithInventory(i *inventory.Inventory) func(*Porter)

WithInventory sets the inventory at create time

func WithLogger

func WithLogger(l *slog.Logger) func(*Porter)

WithLogger sets the logger at create

func WithTravelAgent

func WithTravelAgent(t travelagent.TravelAgenter) func(*Porter)

WithTravelAgent sets the travel agent at create time

func WithUserOverrides

func WithUserOverrides(o *viper.Viper) func(*Porter)

WithUserOverrides sets UserOverrides at create time

func WithVersion

func WithVersion(s string) func(*Porter)

WithVersion sets the version

Types

type CLIMeta

type CLIMeta struct {
	Username     string                 `yaml:"username"`
	Hostname     string                 `yaml:"hostname"`
	StartedAt    *time.Time             `yaml:"started_at"`
	CompletedAt  *time.Time             `yaml:"completed_at"`
	Arguments    []string               `yaml:"arguments"`
	ActiveFlags  map[string]interface{} `yaml:"active_flags"`
	DefaultFlags map[string]interface{} `yaml:"default_flags"`
	ViperConfig  map[string]interface{} `yaml:"viper_config"`
	Version      string                 `yaml:"version"`
	Wizard       *inventory.WizardForm  `yaml:"wizard"`
}

CLIMeta is the command line meta information generated on a run

func NewCLIMeta

func NewCLIMeta(opts ...CLIMetaOption) *CLIMeta

NewCLIMeta returns a new CLIMeta option with functional options

func NewCLIMetaWithCobra added in v0.20.0

func NewCLIMetaWithCobra(cmd *cobra.Command, args []string) *CLIMeta

NewCLIMetaWithCobra returns a new CLIMeta option

func (*CLIMeta) Complete

func (c *CLIMeta) Complete(od string) (string, error)

Complete is the final method for a CLI meta thing

func (*CLIMeta) MustComplete

func (c *CLIMeta) MustComplete(od string) string

MustComplete returns the completed file or panics if an error occurs

func (*CLIMeta) Print

func (c *CLIMeta) Print(w io.Writer)

Print writes the CLIMeta to an io.Writer

type CLIMetaOption added in v0.20.0

type CLIMetaOption func(*CLIMeta)

CLIMetaOption is passed to create functional arguments for a new CLIMeta

func WithMetaVersion added in v0.20.0

func WithMetaVersion(s string) CLIMetaOption

WithMetaVersion sets the suitcasectl version in the meta

func WithStart added in v0.20.0

func WithStart(t *time.Time) CLIMetaOption

WithStart sets the start time for a CLIMeta

type Option added in v0.20.0

type Option func(*Porter)

Option is a functional option that can be passed to create a new Porter instance

type Porter

type Porter struct {
	Cmd         *cobra.Command
	Args        []string
	CLIMeta     *CLIMeta
	TravelAgent travelagent.TravelAgenter

	Inventory        *inventory.Inventory
	InventoryHash    string
	Logger           *slog.Logger
	HashAlgorithm    inventory.HashAlgorithm
	Hashes           []config.HashSet
	UserOverrides    *viper.Viper
	Destination      string
	Version          string
	SuitcaseOpts     *config.SuitCaseOpts
	LogFile          *os.File
	TotalTransferred int64
	WizardForm       *inventory.WizardForm
	// contains filtered or unexported fields
}

Porter holds all the pieces of the suitcases together and such. Trying to flatten this nest of modules together, this is the first step in getting something that can perform that way

func New

func New(options ...Option) *Porter

New returns a new porter using functional options

func (Porter) CreateHashes

func (p Porter) CreateHashes(s []string) ([]config.HashSet, error)

CreateHashes returns a HashSet from a set of strings

func (*Porter) CreateOrReadInventory

func (p *Porter) CreateOrReadInventory(inventoryFile string) (*inventory.Inventory, error)

CreateOrReadInventory returns an inventory and optionally creates it if it didn't exist

func (*Porter) RetryTransport

func (p *Porter) RetryTransport(f string, statusC chan rclone.TransferStatus, retryCount int, retryInterval time.Duration) error

RetryTransport does some retries when doing a transport push

func (*Porter) RunWizard added in v0.21.0

func (p *Porter) RunWizard() error

RunWizard uses an interactive form to select some base pieces and package up date in to suitcases

func (Porter) SendUpdate

func (p Porter) SendUpdate(u travelagent.StatusUpdate) error

SendUpdate sends an update to the travel agent if it exists

func (*Porter) SetOrReadInventory added in v0.20.0

func (p *Porter) SetOrReadInventory(invf string) error

SetOrReadInventory is similar to createorreadinventory, however it sets the inventory in the porter object instead of returning it

func (*Porter) SetTravelAgent

func (p *Porter) SetTravelAgent(t travelagent.TravelAgenter)

SetTravelAgent sets the travel agent property

func (*Porter) ShipItems added in v0.18.1

func (p *Porter) ShipItems(items []string, uniqDir string)

ShipItems sends items through a transporter and optionally reports them to the Travel Agent

func (*Porter) WriteInventory

func (p *Porter) WriteInventory() (*inventory.Inventory, *os.File, error)

WriteInventory writes out an inventory file, and returns it, along with the actual Inventory

Directories

Path Synopsis
Package config holds configuration options for suitcases
Package config holds configuration options for suitcases
Package gpg provides encrypted files
Package gpg provides encrypted files
Package inventory provides the needed pieces to correctly create an Inventory of a directory
Package inventory provides the needed pieces to correctly create an Inventory of a directory
plugins
transporters
Package transporters define how transport plugins behave
Package transporters define how transport plugins behave
transporters/cloud
Package cloud defines how to transport the files out to the cloud ☁️
Package cloud defines how to transport the files out to the cloud ☁️
transporters/shell
Package shell is a shell transporter plugin
Package shell is a shell transporter plugin
Package rclone contains all the rclone operations
Package rclone contains all the rclone operations
Package suitcase holds all the stuff necessary for a suitecase generation
Package suitcase holds all the stuff necessary for a suitecase generation
tar
Package tar provides simple tar suitcases
Package tar provides simple tar suitcases
tarbz2
Package tarbz2 creates tar.bz2 files
Package tarbz2 creates tar.bz2 files
targpg
Package targpg works the tar.gpg suitcases
Package targpg works the tar.gpg suitcases
targz
Package targz creates tar.gz files
Package targz creates tar.gz files
targzgpg
Package targzgpg provides gpg encrypted tar.gz suitcases
Package targzgpg provides gpg encrypted tar.gz suitcases
tarzstd
Package tarzstd creates tar.zst files
Package tarzstd creates tar.zst files
tarzstdgpg
Package tarzstgpg provides gpg encrypted tar.zst suitcases
Package tarzstgpg provides gpg encrypted tar.zst suitcases
Package travelagent gets the suitcases to their final destination
Package travelagent gets the suitcases to their final destination

Jump to

Keyboard shortcuts

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