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
- func CalculateHash(rd io.Reader, ht string) (string, error)
- func GetCurrentUser() (string, error)
- func MustCalculateHash(rd io.Reader, ht string) string
- func WithCLIMeta(c *CLIMeta) func(*Porter)
- func WithCmdArgs(cmd *cobra.Command, args []string) func(*Porter)
- func WithDestination(s string) func(*Porter)
- func WithHashAlgorithm(h inventory.HashAlgorithm) func(*Porter)
- func WithInventory(i *inventory.Inventory) func(*Porter)
- func WithLogger(l *slog.Logger) func(*Porter)
- func WithTravelAgent(t travelagent.TravelAgenter) func(*Porter)
- func WithUserOverrides(o *viper.Viper) func(*Porter)
- func WithVersion(s string) func(*Porter)
- type CLIMeta
- type CLIMetaOption
- type Option
- type Porter
- func (p Porter) CreateHashes(s []string) ([]config.HashSet, error)
- func (p *Porter) CreateOrReadInventory(inventoryFile string) (*inventory.Inventory, error)
- func (p *Porter) RetryTransport(f string, statusC chan rclone.TransferStatus, retryCount int, ...) error
- func (p *Porter) RunWizard() error
- func (p Porter) SendUpdate(u travelagent.StatusUpdate) error
- func (p *Porter) SetOrReadInventory(invf string) error
- func (p *Porter) SetTravelAgent(t travelagent.TravelAgenter)
- func (p *Porter) ShipItems(items []string, uniqDir string)
- func (p *Porter) WriteInventory() (*inventory.Inventory, *os.File, error)
Constants ¶
const ( // PorterKey is where we sneak porter in to the cmd contexs. PorterKey contextKey = iota )
Variables ¶
This section is empty.
Functions ¶
func CalculateHash ¶
CalculateHash returns a certain type of hash string and an optional error
func GetCurrentUser ¶
GetCurrentUser just returns the current user and an error if one occurred
func MustCalculateHash ¶
MustCalculateHash returns a certain type of hash string and panics on error
func WithCLIMeta ¶
WithCLIMeta sets CLIMeta at create time
func WithCmdArgs ¶
WithCmdArgs sets cobra command and args
func WithDestination ¶
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 ¶
WithInventory sets the inventory at create time
func WithLogger ¶
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 ¶
WithUserOverrides sets UserOverrides at create time
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
NewCLIMetaWithCobra returns a new CLIMeta option
func (*CLIMeta) MustComplete ¶
MustComplete returns the completed file or panics if an error occurs
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 (Porter) CreateHashes ¶
CreateHashes returns a HashSet from a set of strings
func (*Porter) CreateOrReadInventory ¶
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
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
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
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 |