lib

package
v3.0.11+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2019 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GroupTypeNormalCommand string = "\nCommands:\n"

	GroupTypeAdditionalCommand string = "\nAdditional Commands:\n"

	GroupTypeDeprecatedCommand string = "\nDeprecated Commands:\n"
)

group spec text of all commands

View Source
const (
	CREDSection string = "Credentials"

	BucketEndpointSection string = "Bucket-Endpoint"

	BucketCnameSection string = "Bucket-Cname"
)

sections in config file

View Source
const (
	OptionConfigFile       string = "configFile"
	OptionEndpoint                = "endpoint"
	OptionAccessKeyID             = "accessKeyID"
	OptionAccessKeySecret         = "accessKeySecret"
	OptionSTSToken                = "stsToken"
	OptionACL                     = "acl"
	OptionShortFormat             = "shortFormat"
	OptionLimitedNum              = "limitedNum"
	OptionMarker                  = "marker"
	OptionUploadIDMarker          = "uploadIDMarker"
	OptionDirectory               = "directory"
	OptionMultipart               = "multipart"
	OptionAllType                 = "allType"
	OptionRecursion               = "recursive"
	OptionBucket                  = "bucket"
	OptionStorageClass            = "storageClass"
	OptionForce                   = "force"
	OptionUpdate                  = "update"
	OptionDelete                  = "delete"
	OptionContinue                = "continue"
	OptionOutputDir               = "outputDir"
	OptionBigFileThreshold        = "bigfileThreshold"
	OptionCheckpointDir           = "checkpointDir"
	OptionSnapshotPath            = "snapshotPath"
	OptionRetryTimes              = "retryTimes"
	OptionRoutines                = "routines"
	OptionParallel                = "parallel"
	OptionRange                   = "range"
	OptionEncodingType            = "encodingType"
	OptionLanguage                = "language"
	OptionHashType                = "hashType"
	OptionVersion                 = "version"
	OptionPartSize                = "partSize"
	OptionDisableCRC64            = "disableCRC64"
	OptionTimeout                 = "timeout"
	OptionInclude                 = "include"
	OptionExclude                 = "exclude"
	OptionMeta                    = "meta"
)

all supported options of ossutil

View Source
const (
	StatName             string = "Name"
	StatLocation                = "Location"
	StatCreationDate            = "CreationDate"
	StatExtranetEndpoint        = "ExtranetEndpoint"
	StatIntranetEndpoint        = "IntranetEndpoint"
	StatACL                     = "ACL"
	StatOwner                   = "Owner"
	StatLastModified            = "Last-Modified"
	StatContentMD5              = "Content-Md5"
	StatCRC64                   = "X-Oss-Hash-Crc64ecma"
	StatStorageClass            = "StorageClass"
)

the elements show in stat object

View Source
const (
	HashCRC64      = "CRC64-ECMA"
	HashMD5        = "MD5"
	HashContentMD5 = "Content-MD5"
)

the elements show in hash file

View Source
const (
	Package                 string = "ossutil"
	ChannelBuf              int    = 1000
	Version                 string = "1.4.0"
	DefaultEndpoint         string = "oss.aliyuncs.com"
	ChineseLanguage                = "CH"
	EnglishLanguage                = "EN"
	Scheme                  string = "oss"
	DefaultConfigFile              = "~" + string(os.PathSeparator) + ".ossutilconfig"
	MaxUint                 uint   = ^uint(0)
	MaxInt                  int    = int(MaxUint >> 1)
	MaxUint64               uint64 = ^uint64(0)
	MaxInt64                int64  = int64(MaxUint64 >> 1)
	ReportPrefix                   = "ossutil_report_"
	ReportSuffix                   = ".report"
	DefaultOutputDir               = "ossutil_output"
	CheckpointDir                  = ".ossutil_checkpoint"
	CheckpointSep                  = "---"
	SnapshotConnector              = "==>"
	SnapshotSep                    = "#"
	MaxPartNum                     = 10000
	MaxIdealPartNum                = MaxPartNum / 10
	MinIdealPartNum                = MaxPartNum / 500
	MaxIdealPartSize               = 524288000
	MinIdealPartSize               = 1048576
	DefaultBigFileThreshold int64  = 104857600
	MaxBigFileThreshold     int64  = MaxInt64
	MinBigFileThreshold     int64  = 0
	DefaultPartSize         int64  = -1
	MaxPartSize             int64  = MaxInt64
	MinPartSize             int64  = 1
	DefaultLimitedNum              = -1
	MinLimitedNum                  = 0
	RetryTimes              int    = 3
	MaxRetryTimes           int64  = 500
	MinRetryTimes           int64  = 1
	Routines                int    = 5
	MaxRoutines             int64  = 10000
	MinRoutines             int64  = 1
	MaxParallel             int64  = 10000
	MinParallel             int64  = 1
	DefaultHashType         string = "crc64"
	MD5HashType             string = "md5"
	LogFilePrefix                  = "ossutil_log_"
	URLEncodingType                = "url"
	StorageStandard                = string(oss.StorageStandard)
	StorageIA                      = string(oss.StorageIA)
	StorageArchive                 = string(oss.StorageArchive)
	DefaultStorageClass            = StorageStandard
	DefaultMethod                  = string(oss.HTTPGet)
	DefaultTimeout                 = 60
	MinTimeout                     = 0
	MaxTimeout                     = MaxInt64
	DefaultNonePattern             = ""
	IncludePrompt                  = "--include"
	ExcludePrompt                  = "--exclude"
)

global public variable

View Source
const (
	FormatTAB         = "    "
	MaxCommandNameLen = 16
	UsageTextChinese  = "用法: ossutil [command] [args...] [options...]\n请使用ossutil help command来显示command命令的帮助"
	UsageTextEnglish  = "Usage: ossutil [command] [args...] [options...]\nPlease use 'ossutil help command' to show help of command"
)

global public variable for formating help text

View Source
const (
	OptionTypeString optionType = iota
	OptionTypeInt64
	OptionTypeFlagTrue
	OptionTypeAlternative
)

option types, only support three kinds now

View Source
const SchemePrefix string = "oss://"

SchemePrefix is the prefix of oss url

Variables

CommandGroups is the array of all group types

CredOptionList is all options in Credentials section

View Source
var CredOptionMap = map[string]configOption{
	OptionLanguage:        configOption{[]string{"language", "Language"}, false, true, "", ""},
	OptionEndpoint:        configOption{[]string{"endpoint", "host"}, true, true, "", ""},
	OptionAccessKeyID:     configOption{[]string{"accessKeyID", "accessKeyId", "AccessKeyID", "AccessKeyId", "access_key_id", "access_id", "accessid", "access-key-id", "access-id"}, true, false, "", ""},
	OptionAccessKeySecret: configOption{[]string{"accessKeySecret", "AccessKeySecret", "access_key_secret", "access_key", "accesskey", "access-key-secret", "access-key"}, true, false, "", ""},
	OptionSTSToken:        configOption{[]string{"stsToken", "ststoken", "STSToken", "sts_token", "sts-token"}, true, false, "", ""},
	OptionOutputDir:       configOption{[]string{"outputDir", "output-dir", "output_dir", "output_directory"}, false, true, "ossutil生成的文件的输出目录, ", "the directory to store files generated by ossutil, "},
}

CredOptionMap allows alias name for options in Credentials section name, allow to show in screen

View Source
var DefaultLanguage = getOsLang()
View Source
var LEnglishLanguage = strings.ToLower(EnglishLanguage)

LEnglishLanguage is the lower case of EnglishLanguage

View Source
var OptionMap = map[string]Option{
	OptionConfigFile: Option{"-c", "--config-file", "", OptionTypeString, "", "",
		"ossutil工具的配置文件路径,ossutil启动时从配置文件读取配置,在config命令中,ossutil将配置写入该文件。",
		"Path of ossutil configuration file, where to dump config in config command, or to load config in other commands that need credentials."},
	OptionEndpoint: Option{"-e", "--endpoint", "", OptionTypeString, "", "",
		fmt.Sprintf("ossutil工具的基本endpoint配置(该选项值会覆盖配置文件中的相应设置),注意其必须为一个二级域名。"),
		fmt.Sprintf("Base endpoint for oss endpoint(Notice that the value of the option will cover the value in config file). Take notice that it should be second-level domain(SLD).")},
	OptionAccessKeyID:     Option{"-i", "--access-key-id", "", OptionTypeString, "", "", "访问oss使用的AccessKeyID(该选项值会覆盖配置文件中的相应设置)。", "AccessKeyID while access oss(Notice that the value of the option will cover the value in config file)."},
	OptionAccessKeySecret: Option{"-k", "--access-key-secret", "", OptionTypeString, "", "", "访问oss使用的AccessKeySecret(该选项值会覆盖配置文件中的相应设置)。", "AccessKeySecret while access oss(Notice that the value of the option will cover the value in config file)."},
	OptionSTSToken:        Option{"-t", "--sts-token", "", OptionTypeString, "", "", "访问oss使用的STSToken(该选项值会覆盖配置文件中的相应设置),非必须设置项。", "STSToken while access oss(Notice that the value of the option will cover the value in config file), not necessary."},
	OptionLimitedNum:      Option{"", "--limited-num", strconv.Itoa(DefaultLimitedNum), OptionTypeInt64, strconv.FormatInt(MinLimitedNum, 10), "", "返回结果的最大个数。", "the limited number of return results."},
	OptionMarker:          Option{"", "--marker", "", OptionTypeString, "", "", "列举Buckets时的marker,或列举objects或Multipart Uploads时的key marker。", "the marker of bucket when list buckets, or the marker of key when list object or Multipart Uploads."},
	OptionUploadIDMarker:  Option{"", "--upload-id-marker", "", OptionTypeString, "", "", "列举Multipart Uploads时的uploadID marker。", "the marker of object when list object or Multipart Uploads."},
	OptionACL:             Option{"", "--acl", "", OptionTypeString, "", "", "acl信息的配置。", "acl information."},
	OptionShortFormat:     Option{"-s", "--short-format", "", OptionTypeFlagTrue, "", "", "显示精简格式,如果未指定该选项,默认显示长格式。", "Show by short format, if the option is not specified, show long format by default."},
	OptionDirectory:       Option{"-d", "--directory", "", OptionTypeFlagTrue, "", "", "返回当前目录下的文件和子目录,而非递归显示所有子目录下的所有object。", "Return matching subdirectory names instead of contents of the subdirectory."},
	OptionMultipart:       Option{"-m", "--multipart", "", OptionTypeFlagTrue, "", "", "指定操作的对象为bucket中未完成的Multipart事件,而非默认情况下的object。", "Indicate that the subject of the command are uncompleted Multipart Uploads, instead of objects(which is the subject in default situation."},
	OptionAllType:         Option{"-a", "--all-type", "", OptionTypeFlagTrue, "", "", "指定操作的对象为bucket中的object和未完成的Multipart事件。", "Indicate that the subject of the command contains both objects and uncompleted Multipart Uploads."},
	OptionRecursion:       Option{"-r", "--recursive", "", OptionTypeFlagTrue, "", "", "递归进行操作。对于支持该选项的命令,当指定该选项时,命令会对bucket下所有符合条件的objects进行操作,否则只对url中指定的单个object进行操作。", "operate recursively, for those commands which support the option, when use them, if the option is specified, the command will operate on all match objects under the bucket, else we will search the specified object and operate on the single object."},
	OptionBucket:          Option{"-b", "--bucket", "", OptionTypeFlagTrue, "", "", "对bucket进行操作,该选项用于确认操作作用于bucket", "the option used to make sure the operation will operate on bucket"},
	OptionStorageClass: Option{"", "--storage-class", DefaultStorageClass, OptionTypeAlternative, fmt.Sprintf("%s/%s/%s", StorageStandard, StorageIA, StorageArchive), "",
		fmt.Sprintf("设置对象的存储方式,默认值:%s,取值范围:%s/%s/%s。", DefaultStorageClass, StorageStandard, StorageIA, StorageArchive),
		fmt.Sprintf("set the storage class of bucket(default: %s), value range is: %s/%s/%s.", DefaultStorageClass, StorageStandard, StorageIA, StorageArchive)},
	OptionForce:  Option{"-f", "--force", "", OptionTypeFlagTrue, "", "", "强制操作,不进行询问提示。", "operate silently without asking user to confirm the operation."},
	OptionUpdate: Option{"-u", "--update", "", OptionTypeFlagTrue, "", "", "更新操作", "update"},
	OptionDelete: Option{"", "--delete", "", OptionTypeFlagTrue, "", "", "删除操作", "delete"},
	OptionOutputDir: Option{"", "--output-dir", DefaultOutputDir, OptionTypeString, "", "",
		fmt.Sprintf("指定输出文件所在的目录,输出文件目前包含:cp命令批量拷贝文件出错时所产生的report文件(关于report文件更多信息,请参考cp命令帮助)。默认值为:当前目录下的%s目录。", DefaultOutputDir),
		fmt.Sprintf("The option specify the directory to place output file in, output file contains: report file generated by cp command when error happens of batch copy operation(for more information about report file, see help of cp command). The default value of the option is: %s directory in current directory.", DefaultOutputDir)},
	OptionBigFileThreshold: Option{"", "--bigfile-threshold", strconv.FormatInt(DefaultBigFileThreshold, 10), OptionTypeInt64, strconv.FormatInt(MinBigFileThreshold, 10), strconv.FormatInt(MaxBigFileThreshold, 10),
		fmt.Sprintf("开启大文件断点续传的文件大小阀值,默认值:%dM,取值范围:%dB-%dB", DefaultBigFileThreshold/1048576, MinBigFileThreshold, MaxBigFileThreshold),
		fmt.Sprintf("the threshold of file size, the file size larger than the threshold will use resume upload or download(default: %d), value range is: %d-%d", DefaultBigFileThreshold, MinBigFileThreshold, MaxBigFileThreshold)},
	OptionPartSize: Option{"", "--part-size", strconv.FormatInt(DefaultPartSize, 10), OptionTypeInt64, strconv.FormatInt(MinPartSize, 10), strconv.FormatInt(MaxPartSize, 10),
		fmt.Sprintf("分片大小,单位为Byte,默认情况下ossutil根据文件大小自行计算合适的分片大小值。如果有特殊需求或者需要性能调优,可以设置该值,取值范围:%d-%d(Byte)", MinPartSize, MaxPartSize),
		fmt.Sprintf("Part size, the unit is: Byte, in default situation, ossutil will calculate the suitable part size according to file size. The option is useful when user has special needs or user need to performance tuning, the value range is: %d-%d(Byte)", MinPartSize, MaxPartSize)},
	OptionDisableCRC64: Option{"", "--disable-crc64", "", OptionTypeFlagTrue, "", "", "该选项关闭crc64,默认情况下,ossutil进行数据传输都打开crc64校验。", "Disable crc64, in default situation, ossutil open crc64 check when transmit data."},
	OptionCheckpointDir: Option{"", "--checkpoint-dir", CheckpointDir, OptionTypeString, "", "",
		fmt.Sprintf("checkpoint目录的路径(默认值为:%s),断点续传时,操作失败ossutil会自动创建该目录,并在该目录下记录checkpoint信息,操作成功会删除该目录。如果指定了该选项,请确保所指定的目录可以被删除。", CheckpointDir),
		fmt.Sprintf("Path of checkpoint directory(default:%s), the directory is used in resume upload or download, when operate failed, ossutil will create the directory automatically, and record the checkpoint information in the directory, when the operation is succeed, the directory will be removed, so when specify the option, please make sure the directory can be removed.", CheckpointDir)},
	OptionSnapshotPath: Option{"", "--snapshot-path", "", OptionTypeString, "", "",
		"该选项用于在某些场景下加速增量上传批量文件(目前,下载和拷贝不支持该选项)。在cp上传文件时使用该选项,ossutil在指定的目录下生成文件记录文件上传的快照信息,在下一次指定该选项上传时,ossutil会读取指定目录下的快照信息进行增量上传。用户指定的snapshot目录必须为本地文件系统上的可写目录,若该目录不存在,ossutil会创建该文件用于记录快照信息,如果该目录已存在,ossutil会读取里面的快照信息,根据快照信息进行增量上传(只上传上次未成功上传的文件和本地进行过修改的文件),并更新快照信息。注意:因为该选项通过在本地记录成功上传的文件的本地lastModifiedTime,从而在下次上传时通过比较lastModifiedTime来决定是否跳过相同文件的上传,所以在使用该选项时,请确保两次上传期间没有其他用户更改了oss上的对应object。当不满足该场景时,如果想要增量上传批量文件,请使用--update选项。另外,ossutil不会主动删除snapshot-path下的快照信息,为了避免快照信息过多,当用户确定快照信息无用时,请用户自行清理snapshot-path。",
		"This option is used to accelerate the incremental upload of batch files in certain scenarios(currently, download and copy do not support this option). If you use the option when batch copy files, ossutil will generate files to record the snapshot information in the specified directory. When the next time you upload files with the option, ossutil will read the snapshot information under the specified directory for incremental upload. The snapshot-path you specified must be a local file system directory can be written in, if the directory does not exist, ossutil creates the files for recording snapshot information, else ossutil will read snapshot information from the path for incremental upload(ossutil will only upload the files which has not been successfully upload to oss and the files has been locally modified), and update the snapshot information to the directory. Note: The option record the lastModifiedTime of local files which has been successfully upload in local file system, and compare the lastModifiedTime of local files in the next cp to decided whether to skip the upload of the files, so if you use the option to achieve incremental upload, please make sure no other user modified the corresponding object in oss during the two uploads. If you can not guarantee the scenarios, please use --update option to achieve incremental upload. In addition, ossutil does not automatically delete snapshot-path snapshot information, in order to avoid too much snapshot information, when the snapshot information is useless, please clean up your own snapshot-path on your own."},
	OptionRetryTimes: Option{"", "--retry-times", strconv.Itoa(RetryTimes), OptionTypeInt64, strconv.FormatInt(MinRetryTimes, 10), strconv.FormatInt(MaxRetryTimes, 10),
		fmt.Sprintf("当错误发生时的重试次数,默认值:%d,取值范围:%d-%d", RetryTimes, MinRetryTimes, MaxRetryTimes),
		fmt.Sprintf("retry times when fail(default: %d), value range is: %d-%d", RetryTimes, MinRetryTimes, MaxRetryTimes)},
	OptionRoutines: Option{"-j", "--jobs", strconv.Itoa(Routines), OptionTypeInt64, strconv.FormatInt(MinRoutines, 10), strconv.FormatInt(MaxRoutines, 10),
		fmt.Sprintf("多文件操作时的并发任务数,默认值:%d,取值范围:%d-%d", Routines, MinRoutines, MaxRoutines),
		fmt.Sprintf("amount of concurrency tasks between multi-files(default: %d), value range is: %d-%d", Routines, MinRoutines, MaxRoutines)},
	OptionParallel: Option{"", "--parallel", "", OptionTypeInt64, strconv.FormatInt(MinParallel, 10), strconv.FormatInt(MaxParallel, 10),
		fmt.Sprintf("单文件内部操作的并发任务数,取值范围:%d-%d, 默认将由ossutil根据操作类型和文件大小自行决定。", MinRoutines, MaxRoutines),
		fmt.Sprintf("amount of concurrency tasks when work with a file, value range is: %d-%d, by default the value will be decided by ossutil intelligently.", MinRoutines, MaxRoutines)},
	OptionRange: Option{"", "--range", "", OptionTypeString, "", "", "下载文件时,指定文件下载的范围,格式为:3-9或3-或-9", "the range when download objects, the form is like: 3-9 or 3- or -9"},
	OptionEncodingType: Option{"", "--encoding-type", "", OptionTypeAlternative, URLEncodingType, "",
		fmt.Sprintf("输入的object名或文件名的编码方式,目前只支持url encode,即指定该选项时,取值范围为:%s,如果不指定该选项,则表示object名或文件名未经过编码。bucket名不支持url encode。注意,如果指定了该选项,则形如oss://bucket/object的cloud_url,输入形式为:oss://bucket/url_encode(object),其中oss://bucket/字符串不需要编码。", URLEncodingType),
		fmt.Sprintf("the encoding type of object name or file name that user inputs, currently ossutil only supports url encode, which means the value range of the option is: %s, if you do not specify the option, it means the object name or file name that user inputed was not encoded. bucket name does not support url encode. Note, if the option is specified, the cloud_url like: oss://bucket/object should be inputted as: oss://bucket/url_encode(object), the string: oss://bucket/ should not be url encoded.", URLEncodingType)},
	OptionInclude: Option{"", "--include", DefaultNonePattern, OptionTypeString, "", "",
		fmt.Sprintf("包含对象匹配模式,如:*.jpg"),
		fmt.Sprintf("Include Pattern of key, e.g., *.jpg")},
	OptionExclude: Option{"", "--exclude", DefaultNonePattern, OptionTypeString, "", "",
		fmt.Sprintf("不包含对象匹配模式,如:*.txt"),
		fmt.Sprintf("Exclude Pattern of key, e.g., *.txt")},
	OptionMeta: Option{"", "--meta", "", OptionTypeString, "", "",
		fmt.Sprintf("设置object的meta为[header:value#header:value...],如:Cache-Control:no-cache#Content-Encoding:gzip"),
		fmt.Sprintf("Set object meta as [header:value#header:value...], e.g., Cache-Control:no-cache#Content-Encoding:gzip")},
	OptionTimeout: Option{"", "--timeout", strconv.FormatInt(DefaultTimeout, 10), OptionTypeInt64, strconv.FormatInt(MinTimeout, 10), strconv.FormatInt(MaxTimeout, 10),
		fmt.Sprintf("签名url的超时时间,单位为秒,默认值为:%d,取值范围:%d-%d", DefaultTimeout, MinTimeout, MaxTimeout),
		fmt.Sprintf("time out of signurl, the unit is: s, default value is %d, the value range is: %d-%d", DefaultTimeout, MinTimeout, MaxTimeout)},
	OptionLanguage: Option{"-L", "--language", DefaultLanguage, OptionTypeAlternative, fmt.Sprintf("%s/%s", ChineseLanguage, EnglishLanguage), "",
		fmt.Sprintf("设置ossutil工具的语言,默认值:%s,取值范围:%s/%s,若设置成\"%s\",请确保您的系统编码为UTF-8。", DefaultLanguage, ChineseLanguage, EnglishLanguage, ChineseLanguage),
		fmt.Sprintf("set the language of ossutil(default: %s), value range is: %s/%s, if you set it to \"%s\", please make sure your system language is UTF-8.", DefaultLanguage, ChineseLanguage, EnglishLanguage, ChineseLanguage)},
	OptionHashType: Option{"", "--type", DefaultHashType, OptionTypeAlternative, fmt.Sprintf("%s/%s", DefaultHashType, MD5HashType), "", fmt.Sprintf("计算的类型, 默认值:%s, 取值范围: %s/%s", DefaultHashType, DefaultHashType, MD5HashType),
		fmt.Sprintf("hash type, Default: %s, value range is: %s/%s", DefaultHashType, DefaultHashType, MD5HashType)},
	OptionVersion: Option{"-v", "--version", "", OptionTypeFlagTrue, "", "", fmt.Sprintf("显示ossutil的版本(%s)并退出。", Version), fmt.Sprintf("Show ossutil version (%s) and exit.", Version)},
}

OptionMap is a collection of ossutil supported options

Functions

func CloudURLToString

func CloudURLToString(bucket string, object string) string

CloudURLToString format url string from input

func DecideConfigFile

func DecideConfigFile(configFile string) string

DecideConfigFile return the config file, if user not specified, return default one

func FindPos

func FindPos(elem string, elemArray []string) int

FindPos find the elem position in a string array

func FindPosCaseInsen

func FindPosCaseInsen(elem string, elemArray []string) int

FindPosCaseInsen find the elem position in a string array, ignore case

func GetAllCommands

func GetAllCommands() []interface{}

GetAllCommands returns all commands list

func GetBool

func GetBool(name string, options OptionMapType) (bool, error)

GetBool is used to get bool option from option map parsed by ParseArgOptions

func GetInt

func GetInt(name string, options OptionMapType) (int64, error)

GetInt is used to get int option from option map parsed by ParseArgOptions

func GetString

func GetString(name string, options OptionMapType) (string, error)

GetString is used to get string option from option map parsed by ParseArgOptions

func NewCommandBridge

func NewCommandBridge(a Commander) *cli.Command

func NewOssCommand

func NewOssCommand() *cli.Command

func Output

func Output(str string)

Output print input string to stdout and add '\n'

func ParseAndRunCommand

func ParseAndRunCommand() error

ParseAndRunCommand parse command line user input, get command and options, then run command

func ParseAndRunCommandFromCli

func ParseAndRunCommandFromCli(ctx *cli.Context, args []string) error

func RunCommand

func RunCommand(args []string, options OptionMapType) (bool, error)

Types

type BucketError

type BucketError struct {
	// contains filtered or unexported fields
}

BucketError happens when access bucket error

func (BucketError) Error

func (e BucketError) Error() string

type CPMonitor

type CPMonitor struct {
	// contains filtered or unexported fields
}

* Put same type variables together to make them 64bits alignment to avoid * atomic.AddInt64() panic * Please guarantee the alignment if you add new filed

type CPMonitorSnap

type CPMonitorSnap struct {
	// contains filtered or unexported fields
}

for cp

type CloudURL

type CloudURL struct {
	// contains filtered or unexported fields
}

CloudURL describes oss url

func CloudURLFromString

func CloudURLFromString(urlStr, encodingType string) (CloudURL, error)

CloudURLFromString get a oss url from url, if url is not a cloud url, return error

func ObjectURLFromString

func ObjectURLFromString(urlStr, encodingType string) (CloudURL, error)

ObjectURLFromString get a oss url from url, if url is not a cloud url, return error

func (*CloudURL) Init

func (cu *CloudURL) Init(urlStr, encodingType string) error

Init is used to create a cloud url from a user input url

func (CloudURL) IsCloudURL

func (cu CloudURL) IsCloudURL() bool

IsCloudURL shows if the url is a cloud url

func (CloudURL) IsFileURL

func (cu CloudURL) IsFileURL() bool

IsFileURL shows if the url is a file url

func (CloudURL) ToString

func (cu CloudURL) ToString() string

ToString reconstruct url

type CloudURLType

type CloudURLType string
const (
	CloudURLNone    CloudURLType = "none"
	CloudURLService CloudURLType = "service"
	CloudURLBucket  CloudURLType = "bucket"
	CloudURLObject  CloudURLType = "object"
)

type Command

type Command struct {
	// contains filtered or unexported fields
}

Command contains all elements of a command, it's the base class of all commands

func (*Command) Init

func (cmd *Command) Init(args []string, options OptionMapType, cmder interface{}) error

Init is the common functions for all commands, they use Init to initialize itself

type CommandError

type CommandError struct {
	// contains filtered or unexported fields
}

CommandError happens when use command in invalid way

func (CommandError) Error

func (e CommandError) Error() string

type CommandManager

type CommandManager struct {
	// contains filtered or unexported fields
}

CommandManager is used to manager commands, such as build command map and run command

func (*CommandManager) Init

func (cm *CommandManager) Init()

Init build command map

func (*CommandManager) RunCommand

func (cm *CommandManager) RunCommand(commandName string, args []string, options OptionMapType) (bool, error)

RunCommand select command from command map, initialize command and run command

type Commander

type Commander interface {
	RunCommand() error
	GetCommand() *Command
	Init(args []string, options OptionMapType) error
}

Commander is the interface of all commands

type ConfigCommand

type ConfigCommand struct {
	// contains filtered or unexported fields
}

ConfigCommand is the command config user's credentials information

func (*ConfigCommand) GetCommand

func (cc *ConfigCommand) GetCommand() *Command

func (*ConfigCommand) Init

func (cc *ConfigCommand) Init(args []string, options OptionMapType) error

Init simulate inheritance, and polymorphism

func (*ConfigCommand) RunCommand

func (cc *ConfigCommand) RunCommand() error

RunCommand simulate inheritance, and polymorphism

type CopyCommand

type CopyCommand struct {
	// contains filtered or unexported fields
}

CopyCommand is the command upload, download and copy objects

func (*CopyCommand) GetCommand

func (cc *CopyCommand) GetCommand() *Command

func (*CopyCommand) Init

func (cc *CopyCommand) Init(args []string, options OptionMapType) error

Init simulate inheritance, and polymorphism

func (*CopyCommand) RunCommand

func (cc *CopyCommand) RunCommand() error

RunCommand simulate inheritance, and polymorphism

type CopyError

type CopyError struct {
	// contains filtered or unexported fields
}

func (CopyError) Error

func (e CopyError) Error() string

type CreateSymlinkCommand

type CreateSymlinkCommand struct {
	// contains filtered or unexported fields
}

CreateSymlinkCommand is the command list buckets or objects

func (*CreateSymlinkCommand) GetCommand

func (cc *CreateSymlinkCommand) GetCommand() *Command

func (*CreateSymlinkCommand) Init

func (cc *CreateSymlinkCommand) Init(args []string, options OptionMapType) error

Init simulate inheritance, and polymorphism

func (*CreateSymlinkCommand) RunCommand

func (cc *CreateSymlinkCommand) RunCommand() error

RunCommand simulate inheritance, and polymorphism

type FileError

type FileError struct {
	// contains filtered or unexported fields
}

FileError happens when access file error

func (FileError) Error

func (e FileError) Error() string

type FileURL

type FileURL struct {
	// contains filtered or unexported fields
}

FileURL describes file url

func (*FileURL) Init

func (fu *FileURL) Init(urlStr, encodingType string) error

Init simulate inheritance, and polymorphism

func (FileURL) IsCloudURL

func (fu FileURL) IsCloudURL() bool

IsCloudURL simulate inheritance, and polymorphism

func (FileURL) IsFileURL

func (fu FileURL) IsFileURL() bool

IsFileURL simulate inheritance, and polymorphism

func (FileURL) ToString

func (fu FileURL) ToString() string

ToString simulate inheritance, and polymorphism

type FormatHelper

type FormatHelper interface {
	// contains filtered or unexported methods
}

FormatHelper is the interface for all commands to format spec information

type HashCommand

type HashCommand struct {
	// contains filtered or unexported fields
}

HashCommand is the command to get crc64/md5 of local file

func (*HashCommand) GetCommand

func (hc *HashCommand) GetCommand() *Command

func (*HashCommand) Init

func (hc *HashCommand) Init(args []string, options OptionMapType) error

Init simulate inheritance, and polymorphism

func (*HashCommand) RunCommand

func (hc *HashCommand) RunCommand() error

RunCommand simulate inheritance, and polymorphism

type HelpCommand

type HelpCommand struct {
	// contains filtered or unexported fields
}

HelpCommand is the command format help text

func (*HelpCommand) GetCommand

func (hc *HelpCommand) GetCommand() *Command

func (*HelpCommand) Init

func (hc *HelpCommand) Init(args []string, options OptionMapType) error

Init simulate inheritance, and polymorphism

func (*HelpCommand) RunCommand

func (hc *HelpCommand) RunCommand() error

RunCommand simulate inheritance, and polymorphism

type ListCommand

type ListCommand struct {
	// contains filtered or unexported fields
}

ListCommand is the command list buckets or objects

func (*ListCommand) GetCommand

func (lc *ListCommand) GetCommand() *Command

func (*ListCommand) Init

func (lc *ListCommand) Init(args []string, options OptionMapType) error

Init simulate inheritance, and polymorphism

func (*ListCommand) RunCommand

func (lc *ListCommand) RunCommand() error

RunCommand simulate inheritance, and polymorphism

type MakeBucketCommand

type MakeBucketCommand struct {
	// contains filtered or unexported fields
}

MakeBucketCommand is the command create bucket

func (*MakeBucketCommand) GetCommand

func (mc *MakeBucketCommand) GetCommand() *Command

func (*MakeBucketCommand) Init

func (mc *MakeBucketCommand) Init(args []string, options OptionMapType) error

Init simulate inheritance, and polymorphism

func (*MakeBucketCommand) RunCommand

func (mc *MakeBucketCommand) RunCommand() error

RunCommand simulate inheritance, and polymorphism

type Monitor

type Monitor struct {
	// contains filtered or unexported fields
}

* Put same type variables together to make them 64bits alignment to avoid * atomic.AddInt64() panic * Please guarantee the alignment if you add new filed

type MonitorSnap

type MonitorSnap struct {
	// contains filtered or unexported fields
}

for normal object operation

type Monitorer

type Monitorer interface {
	// contains filtered or unexported methods
}

type ObjectError

type ObjectError struct {
	// contains filtered or unexported fields
}

ObjectError happens when access object error

func (ObjectError) Error

func (e ObjectError) Error() string

type Option

type Option struct {
	// contains filtered or unexported fields
}

Option describe the component of a option

type OptionMapType

type OptionMapType map[string]interface{}

OptionMapType is the type for ossutil got options

func LoadConfig

func LoadConfig(configFile string) (OptionMapType, error)

LoadConfig load the specified config file

func ParseArgOptions

func ParseArgOptions() ([]string, OptionMapType, error)

ParseArgOptions parse command line and returns args and options

type OssProgressListener

type OssProgressListener struct {
	// contains filtered or unexported fields
}

OssProgressListener progress listener

func (*OssProgressListener) ProgressChanged

func (l *OssProgressListener) ProgressChanged(event *oss.ProgressEvent)

ProgressChanged handle progress event

type RMMonitor

type RMMonitor struct {
	// contains filtered or unexported fields
}

* Put same type variables together to make them 64bits alignment to avoid * atomic.AddInt64() panic * Please guarantee the alignment if you add new filed

type RMMonitorSnap

type RMMonitorSnap struct {
	// contains filtered or unexported fields
}

For rm

type ReadSymlinkCommand

type ReadSymlinkCommand struct {
	// contains filtered or unexported fields
}

ReadSymlinkCommand is the command list buckets or objects

func (*ReadSymlinkCommand) GetCommand

func (rc *ReadSymlinkCommand) GetCommand() *Command

func (*ReadSymlinkCommand) Init

func (rc *ReadSymlinkCommand) Init(args []string, options OptionMapType) error

Init simulate inheritance, and polymorphism

func (*ReadSymlinkCommand) RunCommand

func (rc *ReadSymlinkCommand) RunCommand() error

RunCommand simulate inheritance, and polymorphism

type RemoveCommand

type RemoveCommand struct {
	// contains filtered or unexported fields
}

RemoveCommand is the command remove bucket or objects

func (*RemoveCommand) GetCommand

func (rc *RemoveCommand) GetCommand() *Command

func (*RemoveCommand) Init

func (rc *RemoveCommand) Init(args []string, options OptionMapType) error

Init simulate inheritance, and polymorphism

func (*RemoveCommand) RunCommand

func (rc *RemoveCommand) RunCommand() error

RunCommand simulate inheritance, and polymorphism

type Reporter

type Reporter struct {
	// contains filtered or unexported fields
}

func GetReporter

func GetReporter(need bool, outputDir, comment string) (*Reporter, error)

func (*Reporter) Clear

func (re *Reporter) Clear()

func (*Reporter) Comment

func (re *Reporter) Comment()

func (*Reporter) HasPrompt

func (re *Reporter) HasPrompt() bool

func (*Reporter) Init

func (re *Reporter) Init(outputDir, comment string) error

func (*Reporter) Prompt

func (re *Reporter) Prompt(err error)

func (*Reporter) ReportError

func (re *Reporter) ReportError(msg string)

type RestoreCommand

type RestoreCommand struct {
	// contains filtered or unexported fields
}

RestoreCommand is the command list buckets or objects

func (*RestoreCommand) GetCommand

func (rc *RestoreCommand) GetCommand() *Command

func (*RestoreCommand) Init

func (rc *RestoreCommand) Init(args []string, options OptionMapType) error

Init simulate inheritance, and polymorphism

func (*RestoreCommand) RunCommand

func (rc *RestoreCommand) RunCommand() error

RunCommand simulate inheritance, and polymorphism

type RewriteAssembleOptioner

type RewriteAssembleOptioner interface {
	// contains filtered or unexported methods
}

RewriteAssembleOptioner is the interface for those commands, which do not need to assemble options

type RewriteLoadConfiger

type RewriteLoadConfiger interface {
	// contains filtered or unexported methods
}

RewriteLoadConfiger is the interface for those commands, which do not need to load config, or have other action

type SetACLCommand

type SetACLCommand struct {
	// contains filtered or unexported fields
}

SetACLCommand is the command set acl

func (*SetACLCommand) GetCommand

func (sc *SetACLCommand) GetCommand() *Command

func (*SetACLCommand) Init

func (sc *SetACLCommand) Init(args []string, options OptionMapType) error

Init simulate inheritance, and polymorphism

func (*SetACLCommand) RunCommand

func (sc *SetACLCommand) RunCommand() error

RunCommand simulate inheritance, and polymorphism

type SetMetaCommand

type SetMetaCommand struct {
	// contains filtered or unexported fields
}

SetMetaCommand is the command set meta for object

func (*SetMetaCommand) GetCommand

func (sc *SetMetaCommand) GetCommand() *Command

func (*SetMetaCommand) Init

func (sc *SetMetaCommand) Init(args []string, options OptionMapType) error

Init simulate inheritance, and polymorphism

func (*SetMetaCommand) RunCommand

func (sc *SetMetaCommand) RunCommand() error

RunCommand simulate inheritance, and polymorphism

type SignurlCommand

type SignurlCommand struct {
	// contains filtered or unexported fields
}

SignurlCommand definition

func (*SignurlCommand) GetCommand

func (sc *SignurlCommand) GetCommand() *Command

func (*SignurlCommand) Init

func (sc *SignurlCommand) Init(args []string, options OptionMapType) error

Init simulate inheritance, and polymorphism

func (*SignurlCommand) RunCommand

func (sc *SignurlCommand) RunCommand() error

RunCommand simulate inheritance, and polymorphism

type SpecText

type SpecText struct {
	// contains filtered or unexported fields
}

SpecText is the spec text of a command

type StatCommand

type StatCommand struct {
	// contains filtered or unexported fields
}

StatCommand is the command get bucket's or objects' meta information

func (*StatCommand) GetCommand

func (sc *StatCommand) GetCommand() *Command

func (*StatCommand) Init

func (sc *StatCommand) Init(args []string, options OptionMapType) error

Init simulate inheritance, and polymorphism

func (*StatCommand) RunCommand

func (sc *StatCommand) RunCommand() error

RunCommand simulate inheritance, and polymorphism

type StorageURLer

type StorageURLer interface {
	IsCloudURL() bool
	IsFileURL() bool
	ToString() string
}

StorageURLer is the interface for all url

func StorageURLFromString

func StorageURLFromString(urlStr, encodingType string) (StorageURLer, error)

StorageURLFromString analysis input url type and build a storage url from the url

type UpdateCommand

type UpdateCommand struct {
	// contains filtered or unexported fields
}

UpdateCommand is the command update ossutil

func (*UpdateCommand) GetCommand

func (uc *UpdateCommand) GetCommand() *Command

func (*UpdateCommand) Init

func (uc *UpdateCommand) Init(args []string, options OptionMapType) error

Init simulate inheritance, and polymorphism

func (*UpdateCommand) RunCommand

func (uc *UpdateCommand) RunCommand() error

RunCommand simulate inheritance, and polymorphism

Jump to

Keyboard shortcuts

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