Documentation
¶
Overview ¶
Package inventory provides the needed pieces to correctly create an Inventory of a directory
Index ¶
- Constants
- func ArchiveTOC(fn string) ([]string, error)
- func BindCobra(cmd *cobra.Command)
- func FormatCompletion(_ *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective)
- func GetMetadataWithFiles(files []string) (map[string]string, error)
- func GetMetadataWithGlob(fpg string) (map[string]string, error)
- func HashCompletion(_ *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective)
- func NewInventoryCmd() *cobra.Command
- func WithArchiveTOC() func(*Options)
- func WithArchiveTOCDeep() func(*Options)
- func WithCobra(cmd *cobra.Command, args []string) func(*Options)
- func WithDirectories(d []string) func(*Options)
- func WithFollowSymlinks() func(*Options)
- func WithHashAlgorithms(a HashAlgorithm) func(*Options)
- func WithIgnoreGlobs(g []string) func(*Options)
- func WithInventoryFormat(f string) func(*Options)
- func WithLimitFileCount(c int) func(*Options)
- func WithMaxSuitcaseSize(s int64) func(*Options)
- func WithPrefix(p string) func(*Options)
- func WithSuitcaseFormat(f string) func(*Options)
- func WithUser(u string) func(*Options)
- func WithViper(v *viper.Viper) func(*Options)
- func WithWizardForm(f WizardForm) func(*Options)
- type Analysis
- type CaseSet
- type Collection
- type File
- type FileBucket
- type Format
- type HashAlgorithm
- type IndexSummary
- type Inventory
- func (di Inventory) Analyze() Analysis
- func (di *Inventory) IndexWithSize(maxSize int64) error
- func (di Inventory) JSONString() (string, error)
- func (di Inventory) MustJSONString() string
- func (di Inventory) Search(p string) SearchResults
- func (di *Inventory) SuitcaseNameWithIndex(i int) string
- func (di Inventory) SuitcaseNames() []string
- func (di Inventory) SummaryLog()
- func (di Inventory) UniqueSuitcaseNames() []string
- func (di Inventory) ValidateAccess() error
- type Inventoryer
- type Options
- type SearchDirMatch
- type SearchDirMatches
- type SearchFileMatches
- type SearchResults
- type VAMLer
- type WizardForm
Constants ¶
const ( // NullFormat is the unset value for this type NullFormat = iota // YAMLFormat is for yaml YAMLFormat // JSONFormat is for yaml JSONFormat )
const DefaultSuitcaseFormat string = "tar.zst"
DefaultSuitcaseFormat is just the default format we're going to use for a suitcase. Hopefully this fits for most use cases, but can always be overridden
Variables ¶
This section is empty.
Functions ¶
func ArchiveTOC ¶ added in v0.18.0
ArchiveTOC is a v4 TOC generator for archiver
func FormatCompletion ¶ added in v0.11.0
func FormatCompletion(_ *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective)
FormatCompletion returns shell completion
func GetMetadataWithFiles ¶
GetMetadataWithFiles returns the metadata for a set of files
func GetMetadataWithGlob ¶
GetMetadataWithGlob Given a file path with a glob, return metadata. The metadata is a map of filename to data
func HashCompletion ¶ added in v0.12.0
func HashCompletion(_ *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective)
HashCompletion returns shell completion
func NewInventoryCmd ¶ added in v0.18.0
NewInventoryCmd is a shortcut for an inventory command
func WithArchiveTOC ¶ added in v0.13.0
func WithArchiveTOC() func(*Options)
WithArchiveTOC enables table of contents in the archive file inventory. This only checks files with a known archive extension.
func WithArchiveTOCDeep ¶ added in v0.14.4
func WithArchiveTOCDeep() func(*Options)
WithArchiveTOCDeep enables table of contents in the archive file inventory. This checks every file, regardless of extension.
func WithDirectories ¶ added in v0.12.0
WithDirectories sets the top level directories to be suitcased up
func WithFollowSymlinks ¶ added in v0.12.0
func WithFollowSymlinks() func(*Options)
WithFollowSymlinks sets the FollowSymlinks option to true
func WithHashAlgorithms ¶ added in v0.12.0
func WithHashAlgorithms(a HashAlgorithm) func(*Options)
WithHashAlgorithms sets the hashing algorithms to use for signatures
func WithIgnoreGlobs ¶ added in v0.12.0
WithIgnoreGlobs sets the IgnoreGlobs strings
func WithInventoryFormat ¶ added in v0.12.0
WithInventoryFormat sets the format for the suitcases that will be generated
func WithLimitFileCount ¶ added in v0.12.0
WithLimitFileCount sets the number of files to process before stopping. 0 means process them all
func WithMaxSuitcaseSize ¶ added in v0.12.0
WithMaxSuitcaseSize sets the maximum size for any of the generated suitcases
func WithPrefix ¶ added in v0.12.0
WithPrefix sets the prefix for an inventory
func WithSuitcaseFormat ¶ added in v0.12.0
WithSuitcaseFormat sets the format for the suitcases that will be generated
func WithWizardForm ¶ added in v0.20.0
func WithWizardForm(f WizardForm) func(*Options)
WithWizardForm sets up data from a wizard form
Types ¶
type Analysis ¶ added in v0.14.0
type Analysis struct { LargestFileSize int64 LargestFileSizeHR string FileCount uint AverageFileSize int64 AverageFileSizeHR string TotalFileSize int64 TotalFileSizeHR string }
Analysis is some useful information about a given inventory
type CaseSet ¶
CaseSet is just a holder for case sizes
func NewCaseSet ¶
NewCaseSet returns a new set of suitcase params This is used to keep track of sizing
type Collection ¶ added in v0.14.0
Collection is map of inventory paths to Inventory objects
func CollectionWithDirs ¶ added in v0.14.0
func CollectionWithDirs(d []string) (*Collection, error)
CollectionWithDirs returns a Collection of inventories using a list of directories
type File ¶
type File struct { Path string `yaml:"path" json:"path"` Destination string `yaml:"destination" json:"destination"` Name string `yaml:"name" json:"name"` Size int64 `yaml:"size" json:"size"` ArchiveTOC []string `yaml:"archive_toc,omitempty" json:"archive_toc,omitempty"` SuitcaseIndex int `yaml:"suitcase_index,omitempty" json:"suitcase_index,omitempty"` SuitcaseName string `yaml:"suitcase_name,omitempty" json:"suitcase_name,omitempty"` }
File is a file item inside an inventory
type FileBucket ¶
type FileBucket struct {
Free int64
}
FileBucket describes what a filebucket state is
type Format ¶ added in v0.11.0
type Format int
Format is the format the inventory will use, such as yaml, json, etc
func (*Format) MarshalJSON ¶ added in v0.11.0
MarshalJSON ensures that json conversions use the string value here, not the int value
type HashAlgorithm ¶ added in v0.12.0
type HashAlgorithm int
HashAlgorithm is the hashing algorithm used for calculating file signatures
const ( // NullHash represents no hashing NullHash HashAlgorithm = iota // MD5Hash uses and md5 checksum MD5Hash // SHA1Hash is the sha-1 version of a signature SHA1Hash // SHA256Hash is the more secure sha-256 version of a signature SHA256Hash // SHA512Hash is most secure, but super slow, probably not useful here SHA512Hash )
func (*HashAlgorithm) MarshalJSON ¶ added in v0.12.0
func (h *HashAlgorithm) MarshalJSON() ([]byte, error)
MarshalJSON ensures that json conversions use the string value here, not the int value
func (*HashAlgorithm) Set ¶ added in v0.12.0
func (h *HashAlgorithm) Set(v string) error
Set helps fulfill the pflag.Value interface
func (HashAlgorithm) String ¶ added in v0.12.0
func (h HashAlgorithm) String() string
String satisfies the pflags interface
func (HashAlgorithm) Type ¶ added in v0.12.0
func (h HashAlgorithm) Type() string
Type satisfies part of the pflags.Value interface
type IndexSummary ¶
type IndexSummary struct { Count uint `yaml:"count"` Size int64 `yaml:"size"` HumanSize string `yaml:"human_size"` }
IndexSummary will give an overall summary to a set of suitcases
type Inventory ¶ added in v0.14.5
type Inventory struct { Files []*File `yaml:"files" json:"files"` Options *Options `yaml:"options" json:"options"` TotalIndexes int `yaml:"total_indexes" json:"total_indexes"` IndexSummaries map[int]*IndexSummary `yaml:"index_summaries" json:"index_summaries"` InternalMetadata map[string]string `yaml:"internal_metadata" json:"internal_metadata"` ExternalMetadata map[string]string `yaml:"external_metadata" json:"external_metadata"` }
Inventory is the inventory of a set of suitcases
func NewDirectoryInventory ¶
NewDirectoryInventory creates a new DirectoryInventory using options
func NewInventoryWithFilename ¶
NewInventoryWithFilename returns a new DirectoryInventory from an inventory File
func (Inventory) Analyze ¶ added in v0.14.5
Analyze examines an inventory and returns an Analysis object
func (*Inventory) IndexWithSize ¶ added in v0.14.5
IndexWithSize Loops through inventory and assign suitcase indexes based on a given max size
func (Inventory) JSONString ¶ added in v0.18.0
JSONString returns the inventory in JSON and an optional error
func (Inventory) MustJSONString ¶ added in v0.18.0
MustJSONString returns the json representation as a string or panic
func (Inventory) Search ¶ added in v0.14.5
func (di Inventory) Search(p string) SearchResults
Search iterates through files inside of an inventory and returns a set of results
func (*Inventory) SuitcaseNameWithIndex ¶ added in v0.14.5
SuitcaseNameWithIndex gives what the name of a suitcase file will be, given the index number
func (Inventory) SuitcaseNames ¶ added in v0.14.5
SuitcaseNames returns a list of suitcase names as strings
func (Inventory) SummaryLog ¶ added in v0.14.5
func (di Inventory) SummaryLog()
SummaryLog logs out a summary of the suitcase data
func (Inventory) UniqueSuitcaseNames ¶ added in v0.14.5
UniqueSuitcaseNames returns a list of suitcase names as strings
func (Inventory) ValidateAccess ¶ added in v0.21.0
ValidateAccess ensures that we have access to all files in a given inventory
type Inventoryer ¶
Inventoryer is an interface to define what an Inventory Operator does
func NewInventoryerWithFilename ¶
func NewInventoryerWithFilename(filename string) (Inventoryer, error)
NewInventoryerWithFilename creates a new inventoryer with a filename
type Options ¶ added in v0.12.0
type Options struct { User string `yaml:"user" json:"user"` Prefix string `yaml:"prefix" json:"prefix"` Directories []string `yaml:"top_level_directories" json:"top_level_directories"` SizeConsideredLarge int64 `yaml:"size_considered_large" json:"size_considered_large"` MaxSuitcaseSize int64 `yaml:"max_suitcase_size" json:"max_suitcase_size"` InternalMetadataGlob string `yaml:"internal_metadata_glob,omitempty" json:"internal_metadata_glob,omitempty"` IgnoreGlobs []string `yaml:"ignore_globs,omitempty" json:"ignore_globs,omitempty"` ExternalMetadataFiles []string `yaml:"external_metadata_files,omitempty" json:"external_metadata_files,omitempty"` EncryptInner bool `yaml:"encrypt_inner" json:"encrypt_inner"` HashInner bool `yaml:"hash_inner" json:"hash_inner"` LimitFileCount int `yaml:"limit_file_count" json:"limit_file_count"` SuitcaseFormat string `yaml:"suitcase_format" json:"suitcase_format"` InventoryFormat string `yaml:"inventory_format" json:"inventory_format"` FollowSymlinks bool `yaml:"follow_symlinks" json:"follow_symlinks"` HashAlgorithm HashAlgorithm `yaml:"hash_algorithm" json:"hash_algorithm"` IncludeArchiveTOC bool `yaml:"include_archive_toc" json:"include_archive_toc"` IncludeArchiveTOCDeep bool `yaml:"include_archive_toc_deep" json:"include_archive_toc_deep"` TransportPlugin transporters.Transporter `yaml:"transport_plugin" json:"transport_plugin"` }
Options are the options used to create a DirectoryInventory
func NewOptions ¶ added in v0.11.5
NewOptions uses functional options to generatea DirectoryInventoryOptions object
func (*Options) AbsoluteDirectories ¶ added in v0.12.0
AbsoluteDirectories converts the Directories entries to absolute paths
type SearchDirMatch ¶ added in v0.13.0
type SearchDirMatch struct { Directory string TotalSize uint64 TotalSizeHR string Suitcases []string }
SearchDirMatch is a single directory match
type SearchDirMatches ¶ added in v0.13.0
type SearchDirMatches []SearchDirMatch
SearchDirMatches is a recursive listing of what is contained in a directory
type SearchFileMatches ¶ added in v0.13.0
type SearchFileMatches []File
SearchFileMatches is a listing of files that match a given search
type SearchResults ¶ added in v0.13.0
type SearchResults struct { Files SearchFileMatches Directories SearchDirMatches }
SearchResults is all the stuff that a given search gets back