Documentation ¶
Index ¶
- Constants
- Variables
- func GetVersion() string
- type DownloadResult
- type Options
- func (opts *Options) AllErrorsAsString() string
- func (opts *Options) ClearErrors()
- func (opts *Options) EnsureDownloadDirIsSet()
- func (opts *Options) Errors() []string
- func (opts *Options) HasErrors() bool
- func (opts *Options) LoadConfigFile() (*PartnerConfig, error)
- func (opts *Options) MergeConfigFileOptions(action string)
- func (opts *Options) SetAndVerifyDeleteOptions()
- func (opts *Options) SetAndVerifyDownloadOptions()
- func (opts *Options) SetAndVerifyListOptions()
- func (opts *Options) SetAndVerifyUploadOptions()
- func (opts *Options) VerifyOutputFormat()
- func (opts *Options) VerifyRequiredAPICredentials()
- func (opts *Options) VerifyRequiredDeleteOptions()
- func (opts *Options) VerifyRequiredDownloadOptions()
- func (opts *Options) VerifyRequiredListOptions()
- func (opts *Options) VerifyRequiredUploadOptions()
- type PartnerConfig
- type UploadResult
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_ITEM_NOT_FOUND can occur when the user tries to // upload, download, or validate a file that doesn't exist, // or when apt_check_ingest is asked to check on a bag // which has no record in Pharos. EXIT_ITEM_NOT_FOUND = 4 // EXIT_NOT_INGESTED occurs when apt_check_ingest finds // a WorkItem record for a bag in Pharos, but the bag has // not yet been fully ingested. EXIT_NOT_INGESTED = 5 // EXIT_SOME_INGESTED occurs when apt_check_ingest finds // multiple WorkItems in Pharos matching a bag name, and // some versions of the bag have been ingested while others // have not. EXIT_SOME_INGESTED = 6 // 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 )
Exit Codes
const PharosAPIVersion = "v2"
Current Pharos API Version
Variables ¶
var ( Version string BuildDate string GitHash string License string WikiUrl string RepoUrl string Email string )
These vars are set by the build script in scripts/build_partner_tools.rb
Functions ¶
func GetVersion ¶
func GetVersion() string
Types ¶
type DownloadResult ¶
type DownloadResult struct { Region string `json:"region"` Bucket string `json:"bucket"` Key string `json:"key"` SavedTo string `json:"saved_to"` Md5 string `json:"md5"` Sha256 string `json:"sha256"` BytesDownloaded int64 `json:"bytes_downloaded"` S3ContentLength int64 `json:"s3_content_length"` S3ETag string `json:"s3_etag"` S3LastModified time.Time `json:"s3_last_modified"` S3Metadata map[string]*string `json:"s3_metadata,omitempty"` S3PartsCount int64 `json:"s3_parts_count,omitempty"` S3ServerSideEncryption string `json:"s3_server_side_encryption,omitempty"` S3StorageClass string `json:"s3_storage_class,omitempty"` S3VersionId string `json:"s3_version_id,omitempty"` ErrorMessage string `json:"error_message,omitempty"` }
func NewDownloadResult ¶
func NewDownloadResult(opts *Options, client *network.S3Download) *DownloadResult
func (*DownloadResult) ToJson ¶
func (result *DownloadResult) ToJson() (string, error)
ToJson returns a JSON representation of the result. This contains more information than the plain text version returned by ToText().
func (*DownloadResult) ToText ¶
func (result *DownloadResult) ToText() string
ToText() returns a plain-text representation of the result, suitable for printing to STDOUT. To get more detailed information, use ToJson().
type Options ¶
type Options struct { // PathToConfigFile is the path the APTrust partner config // file. If not specified, this defaults to ~/.aptrust_partner.conf. // This can be omitted entirely if you supply the -bucket and -key // options on the command line. Any required options not specified // on the command line will be pulled from this file. PathToConfigFile string // AccessKeyId is your AWS access key id. Used for authentication. AccessKeyId string // AccessKeyFrom describes the source from which the Options object // loaded the AWS AccessKeyId. This is used only for testing and debugging. AccessKeyFrom string // APTrustAPIKey is the key to connect to APTrust REST API. // The key must belong to APTrustAPIUser. APTrustAPIKey string // APTrustAPIKeyFrom tells whether the API key came from the config // file or the environment. APTrustAPIKeyFrom string // APTrustAPIKey is the user email address to connect to APTrust REST API. APTrustAPIUser string // APTrustAPIUserFrom tells whether the API user came from the config // file or the environment. APTrustAPIUserFrom string // ETag is the etag of an S3 upload. This is for tools that look up // bags by etag. ETag string // SecretAccessKey is the AWS Secret Access Key used to access your // S3 bucket. SecretAccessKey string // SecretKeyFrom describes the source from which the Options object // loaded the AWS SecretAccessKey. This is used only for testing and // debugging. SecretKeyFrom string // Region is the AWS S3 region to connect to. Region string // Bucket is the name of the bucket you're working with. Bucket string // Key is the name of the S3 key to download, list, or delete. Key string // Dir is the directory into which the S3 object should be downloaded. // This option is for downloads only. Dir string // ContentType is the content type of the object being uploaded // to S3. This option applies to uploads only, and can be left // empty. ContentType string // Limit is for apt_list. It specifies the maximum number of items // to list. Limit int // Prefix is the key prefix to list in apt_list. (I.e. List only those // S3 objects whose key begins with this string.) Prefix string // Metadata is optional metadata to be saved in S3 when uploading // a file. Metadata map[string]string // FileToUpload is the path the file that should be uploaded to S3. // This is required for apt_upload only, and is ignored elsewhere. FileToUpload string // PharosURL is the URL of the Pharos production or demo system. PharosURL string // OutputFormat specifies how the program should print its results // to STDOUT. Options are "text" and "json". OutputFormat string // Debug indicates whether we should print debug output to Stdout. Debug bool // contains filtered or unexported fields }
func (*Options) AllErrorsAsString ¶
AllErrorsAsString returns all errors as a single string, with each error ending in a newline. This is suitable for printing to STDOUT/STDERR.
func (*Options) ClearErrors ¶
func (opts *Options) ClearErrors()
ClearErrors clears all errors. This is used in testing.
func (*Options) EnsureDownloadDirIsSet ¶
func (opts *Options) EnsureDownloadDirIsSet()
EnsureDownloadDirIsSet makes sure we have a directory to download the file into.
func (*Options) LoadConfigFile ¶
func (opts *Options) LoadConfigFile() (*PartnerConfig, error)
LoadConfigFile loads the Partner Config file, which contains settings to connect to AWS S3. We must be able to load this file if certain command-line options are not specified.
func (*Options) MergeConfigFileOptions ¶
MergeConfigFileOptions supplements command-line options with the default values the user specified in their APTrust parner config file.
If the user left some options unspecified on the command line, load them from the config file, if we can. If the user specified a config file, use that. Otherwise, use the default config file in ~/.aptrust_partner.conf or %HOMEPATH%\.aptrust_partner.conf
func (*Options) SetAndVerifyDeleteOptions ¶
func (opts *Options) SetAndVerifyDeleteOptions()
SetAndVerifyDeleteOptions
func (*Options) SetAndVerifyDownloadOptions ¶
func (opts *Options) SetAndVerifyDownloadOptions()
SetAndVerifyDownloadOptions tries to fill in options that were not supplied on the command line with those specified in the APTrust partner config file. It also verifies that all required and allowed values are present. Check opts.HasErrors() after calling this, to see if we have sufficient options info to proceed with a download.
func (*Options) SetAndVerifyListOptions ¶
func (opts *Options) SetAndVerifyListOptions()
SetAndVerifyListOptions
func (*Options) SetAndVerifyUploadOptions ¶
func (opts *Options) SetAndVerifyUploadOptions()
SetAndVerifyUploadOptions
func (*Options) VerifyOutputFormat ¶
func (opts *Options) VerifyOutputFormat()
VerifyOutputFormat makes sure the user specified a valid output format.
func (*Options) VerifyRequiredAPICredentials ¶
func (opts *Options) VerifyRequiredAPICredentials()
func (*Options) VerifyRequiredDeleteOptions ¶
func (opts *Options) VerifyRequiredDeleteOptions()
VerifyRequiredDeleteOptions checks to see that all required S3 delete options are set.
func (*Options) VerifyRequiredDownloadOptions ¶
func (opts *Options) VerifyRequiredDownloadOptions()
VerifyRequiredDownloadOptions checks to see that all required download options are set.
func (*Options) VerifyRequiredListOptions ¶
func (opts *Options) VerifyRequiredListOptions()
VerifyRequiredListOptions checks to see that all required S3 list options are set.
func (*Options) VerifyRequiredUploadOptions ¶
func (opts *Options) VerifyRequiredUploadOptions()
VerifyRequiredUploadOptions checks to see that all required upload options are set.
type PartnerConfig ¶
type PartnerConfig struct { AwsAccessKeyId string AwsSecretAccessKey string ReceivingBucket string RestorationBucket string DownloadDir string APTrustAPIUser string APTrustAPIKey string // contains filtered or unexported fields }
func LoadPartnerConfig ¶
func LoadPartnerConfig(configFile string) (*PartnerConfig, error)
func (*PartnerConfig) ExpandFilePaths ¶
func (partnerConfig *PartnerConfig) ExpandFilePaths()
func (*PartnerConfig) LoadAwsFromEnv ¶
func (partnerConfig *PartnerConfig) LoadAwsFromEnv()
Fill in AWS values if their missing from config file but present in the environment.
func (*PartnerConfig) Validate ¶
func (partnerConfig *PartnerConfig) Validate() error
func (*PartnerConfig) Warnings ¶
func (partnerConfig *PartnerConfig) Warnings() []string
type UploadResult ¶
type UploadResult struct { Region string `json:"region"` Bucket string `json:"bucket"` Key string `json:"key"` CopiedFrom string `json:"copied_from"` S3Location string `json:"s3_location,omitempty"` S3UploadId string `json:"s3_upload_id,omitempty"` S3LastModified time.Time `json:"s3_last_modified,omitempty"` S3ContentLength int64 `json:"s3_content_length,omitempty"` S3ContentType string `json:"s3_content_type"` S3ETag string `json:"s3_etag,omitempty"` S3PartsCount int64 `json:"s3_parts_count,omitempty"` ErrorMessage string `json:"error_message,omitempty"` }
func NewUploadResult ¶
func (*UploadResult) ToJson ¶
func (result *UploadResult) ToJson() (string, error)
ToJson returns a JSON representation of the result. This contains more information than the plain text version returned by ToText().
func (*UploadResult) ToText ¶
func (result *UploadResult) ToText() string
ToText() returns a plain-text representation of the result, suitable for printing to STDOUT. To get more detailed information, use ToJson().