Documentation
¶
Index ¶
- Constants
- Variables
- func EnsureDefaultListParams(values url.Values)
- func EnsureDefaultTags(tags []*bagit.TagDefinition) []*bagit.TagDefinition
- func Execute()
- func FindTag(tags []*bagit.TagDefinition, tagFile, tagName string) *bagit.TagDefinition
- func GetFlagValue(flags *pflag.FlagSet, flagName, errMsg string) string
- func GetTagValues(args []string) []*bagit.TagDefinition
- func GetUrlValues(args []string) url.Values
- func InitRegistryRequest(config *Config, args []string) (*network.RegistryClient, url.Values)
- func LoadProfile(name string) (*bagit.Profile, error)
- func LooksLikePreservationBucket(bucket string) bool
- func NewRegistryClient(config *Config) (*network.RegistryClient, error)
- func NewS3Client(config *Config, s3Host string) *minio.Client
- func PrettyPrintJSON(jsonBytes []byte)
- func PrintErrors(errors []string)
- func ValidateManifestAlgorithms(profile *bagit.Profile, algs []string) []string
- func ValidateTags(profile *bagit.Profile, tags []*bagit.TagDefinition) []string
- type ArgPair
- type Config
Constants ¶
const ( // EXIT_OK means program completed successfully. EXIT_OK = 0 // EXIT_RUNTIME_ERR means program did not complete // successfully due to an error. The error may have // occurred outside the program, such as a network // error or an error on a remote server. EXIT_RUNTIME_ERR = 1 // EXIT_BAG_INVALID is used primarily for apt_validate. // It means the program completed its run and found that // the bag is not valid. EXIT_BAG_INVALID = 2 // EXIT_USER_ERR means the user did not supply some // required option or argument, or the user supplied // invalid options/arguments. EXIT_USER_ERR = 3 // EXIT_REQUEST_ERROR means the remote server responded // with a 4xx or 5xx HTTP status code. EXIT_REQUEST_ERROR = 4 // EXIT_NO_OP means the user requested help message or // version info. The program printed the info, and no other // operations were performed. EXIT_NO_OP = 100 )
Variables ¶
var BuildDate string
var CommitId string
var ErrImbalancedArgPair = errors.New("odd number of filter args")
var Version string
Functions ¶
func EnsureDefaultListParams ¶
EnsureDefaultListParams adds sort and per_page params to url.Values if they're not already there. This ensures that we don't get too many results per page, and that paging works correctly.
func EnsureDefaultTags ¶
func EnsureDefaultTags(tags []*bagit.TagDefinition) []*bagit.TagDefinition
func FindTag ¶
func FindTag(tags []*bagit.TagDefinition, tagFile, tagName string) *bagit.TagDefinition
TODO: Change this to find tags? Tags can repeat.
func GetFlagValue ¶
GetFlagValue returns the parsed value of flagName. If you specify a non-empty error message, this will cause the program to exit with code EXIT_USER_ERROR and will print the message.
Call this with an empty error message for optional flags, and it won't exit if the flag is missing.
func GetTagValues ¶
func GetTagValues(args []string) []*bagit.TagDefinition
GetTagValues parses tag values from the supplied string slice, which should be collected from the --tags flags.
Format is "tagfile.txt/Tag-Name=Value". If tag file name is missing from param, it's assumed to be bag-info.txt, which is the only customizable tag file in the BagIt standard.
As with the LOC's BagIt-Python library, we convert the first letter of each word in tag names to upper-case. For example, "source-organization" will be converted here to "Source-Organization".
While the BagIt spec does not officially say that tag names must use title case, the examples in the BagIt spec and common convention use title-cased tag names. Some parses may expect or demand title-cased names when validating bags, so we will stick to title case for now.
func GetUrlValues ¶
GetUrlValues converts command-line args that look like name-value pairs into URL values. It converts only those args that contain an equal sign. If an arg is specified more than once, the resulting url.Values will include all of that arg's values.
func InitRegistryRequest ¶
InitRegistryRequest initializes a registry REST client and the params to be sent in a query string.
func LoadProfile ¶
LoadProfile loads a BagIt profile.
func LooksLikePreservationBucket ¶
LooksLikePreservationBucket returns true if the bucket name looks like the name of an APTrust preservation bucket.
The caller should exit if the user tries to access an APTrust preservation bucket. Though these buckets have strict access controls with only a single IAM user allowed to write or delete files, we want to protect against the case where some inattentive APTrust admin runs this tool with credentials belonging to that one IAM user. (E.g. An APTrust admin runs this on a production server, and the app pulls crendentials from the environment.) We call this only on S3 upload and delete.
func NewRegistryClient ¶
func NewRegistryClient(config *Config) (*network.RegistryClient, error)
NewRegistryClient returns a new client that can talk to the APTrust Registry. It will return an error if the config lacks essential Registry settings.
func NewS3Client ¶
NewS3Client returns a client that can talk to an S3 endpoint. It will return an error if the config is lacking S3 authentication settings.
func PrettyPrintJSON ¶
func PrettyPrintJSON(jsonBytes []byte)
PrettyPrintJSON converts unformatted JSON, such as that returned by the Registry, to formatted JSON.
func PrintErrors ¶
func PrintErrors(errors []string)
func ValidateManifestAlgorithms ¶
ValidateManifestAlgorithms checks to see whether the user-specified manifest algorithms are allowed by the profile, and whether the user specified all of the profile's required algorithms. We do this work up front, before creating the bag, to avoid creating an invalid bag.
func ValidateTags ¶
func ValidateTags(profile *bagit.Profile, tags []*bagit.TagDefinition) []string
ValidateTags verifies that tags required by the BagIt profile are present and contain valid values. We check this BEFORE bagging because in case where the user is packaging 500+ GB, they don't want to wait two hours to find out their bag is invalid.
Types ¶
type ArgPair ¶
func ParseArgPairs ¶
ParseArgPairs converts command-line args that look like key-value pairs into ArgPair objects. It ignores flags and args that do not contain an equal sign.
Source Files
¶
- bag.go
- bag_create.go
- bag_validate.go
- common.go
- config.go
- registry.go
- registry_get.go
- registry_get_file.go
- registry_get_object.go
- registry_get_workitem.go
- registry_list.go
- registry_list_files.go
- registry_list_objects.go
- registry_list_workitems.go
- root.go
- s3.go
- s3_delete.go
- s3_download.go
- s3_list.go
- s3_upload.go
- version.go