boscli

package
v0.0.0-...-13a05f4 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2020 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BOSCLIENT_RETRY_NUM       = 3
	BOSCLIENT_RETRY_MAX_DELAY = 20000
	BOSCLIENT_RETRY_BASE      = 300
)
View Source
const (
	DEFAULT_STORAGE_CLASS = "STANDARD"

	BCE_CLI_AGENT  = "bce-go-cli"
	HTTP_PROTOCOL  = "http://"
	HTTPS_PROTOCOL = "https://"

	GOOS_WINDOWS_DEF       = "windows"
	BOS_PATH_PREFIX        = "bos:/"
	BOS_PATH_PREFIX_DOUBLE = "bos://"
	BOS_TIME_FORMT         = "2006-01-02T15:04:05Z"
	LOCAL_TIME_FROMT       = "2006-01-02 15:04:05"
	BOS_HTTP_TIME_FORMT    = "Mon, 02 Jan 2006 15:04:05 MST"

	SIGNED_URL_EXPIRE_TIME      = 1800
	GAP_GET_OBJECT_INFO_AGAIN   = 60 //60s
	MAX_PARTS                   = 10000
	MAX_STREAM_UPLOAD_SIZE      = 5 << 30 // 5G
	STREAM_DOWNLOAD_BUF_SIZE    = 2 << 20
	SYNC_COMPARATOR_TIME_OUT    = 36000 * 1000 // 10 hours
	GET_NET_LOCAL_FILE_TIME_OUT = 36000 * 1000 // 10 hours
	MULTI_UPLOAD_MAX_FILE_SIZE  = 5 << 40      // 5T
	MULTI_UPLOAD_THRESHOLD      = 32 << 20     // 32M
	PART_SIZE_BASE              = 10 << 20     // 10M
	MULTI_COPY_THRESHOLD        = 100 << 20    // 100M
	MULTI_COPY_PART_SIZE        = 50 << 20     // 50M

	MULTI_DOWNLOAD_THRESHOLD = 100 << 20 // 32M
)
View Source
const (
	// op type
	OPERATE_CMD_COPY    = "operateCmdCopy"
	OPERATE_CMD_DELETE  = "operateCmdDelete"
	OPERATE_CMD_NOTHING = "operateCmdNothing"

	SYNC_OP_COPY     = "Copy"
	SYNC_OP_DOWNLOAD = "Download"
	SYNC_OP_UPLOAD   = "Upload"
	SYNC_OP_DELETE   = "Delete" // delete local file
	SYNC_OP_REMOVE   = "Remove" // delete bos object
	SYNC_OP_ERROR    = "Error"

	IS_BOS         = "bos"
	IS_LOCAL       = "local"
	BOS_TO_BOS     = "bosbos"
	BOS_TO_LOCAL   = "boslocal"
	LOCAL_TO_LOCAL = "locallocal"
	LOCAL_TO_BOS   = "localbos"
)

sync op constants

View Source
const (
	BOSCLI_OK                                 = "boscliSuccess"
	BOSCLI_EMPTY_CODE                         = ""
	BOSCLI_OPRATION_CANCEL                    = "boscliOperationCancel"
	BOSCLI_UNSUPPORT_METHOD                   = "boscliUnsupportMethod"
	BOSCLI_BUCKETNAME_IS_EMPTY                = "boscliBucketNameIsEmpty"
	BOSCLI_OBJECTKEY_IS_EMPTY                 = "boscliObjectKeyIsEmpty"
	BOSCLI_BOSPATH_IS_INVALID                 = "boscliBosPathIsInvalid"
	BOSCLI_BUCKETNAME_CONTAIN_OBJECTNAME      = "boscliBucketNameContainObjectName"
	BOSCLI_BUCKET_NOT_EMPTY                   = "BucketNotEmpty"
	BOSCLI_INTERNAL_ERROR                     = "boscliInternalError"
	BOSCLI_UNSUPPORT_STORAGE_CLASS            = "boscliUnsupportStorageClass"
	BOSCLI_SRC_BUCKET_IS_EMPTY                = "boscliSrcBucketIsEmpty"
	BOSCLI_DST_BUCKET_IS_EMPTY                = "boscliDstBucketIsEmpty"
	BOSCLI_SRC_BUCKET_DONT_EXIST              = "boscliSrcBucketNotExist"
	BOSCLI_DST_BUCKET_DONT_EXIST              = "boscliSrcBucketNotExist"
	BOSCLI_SRC_OBJECT_IS_EMPTY                = "boscliSrcObjectIsEmpty"
	BOSCLI_BATCH_COPY_DSTOBJECT_END           = "boscliBathcCopyDstObjectEnd"
	BOSCLI_BATCH_COPY_SRCOBJECT_END           = "boscliBathcCopySrcObjectEnd"
	BOSCLI_BATCH_UPLOAD_SRC_PATH_END          = "boscliBatchUploadSrcPathEnd"
	BOSCLI_COVER_SELF                         = "boscliCopyCoverSelf"
	BOSCLI_CANT_DOWNLOAD_FILES_TO_FILE        = "boscliCantDownloadFilesToFile"
	BOSCLI_DIR_IS_NOT_WRITABLE                = "boscliDirIsNotWritable"
	BOSCLI_BATCH_DOWNLOAD_SRCOBJECT_END       = "boscliBatchDownlaodSrcObjectEnd"
	BOSCLI_UPLOAD_SRC_CANNT_BE_DIR            = "boscliUploadSrcCanntBeDir"
	BOSCLI_DST_OBJECT_KEY_IS_EMPTY            = "boscliDstObjectKeyIsEmpty"
	BOSCLI_UPLOAD_STREAM_TO_DIR               = "boscliUploadStreamToDir"
	BOSCLI_RM_DIR_MUST_USE_RECURSIVE          = "boscliRmDirMustUseRecursive"
	BOSCLI_EXPIRE_LESS_NONE                   = "boscliExpireLessNegativeOne"
	BOSCLI_SYNC_EXCLUDE_INCLUDE_TIME_TOG      = "boscliSyncExcludeIncludeTimeTog"
	BOSCLI_SYNC_EXCLUDE_INCLUDE_TOG           = "boscliSyncEcludeIncludeTog"
	BOSCLI_SYNC_UPLOAD_SRC_MUST_DIR           = "boscliSyncUploadSrcMustDir"
	BOSCLI_SYNC_DOWN_DST_MUST_DIR             = "boscliSyncDownDstMustDir"
	BOSCLI_SYNC_LOCAL_TO_LOCAL                = "boscliSyncLocalToLocal"
	BOSCLI_SYNC_PROCESS_NUM_LESS_ZERO         = "boscliSyncProcessNumLessZero"
	BOSCLI_INVALID_SYNY_TYPE                  = "boscliInvalidSyncType"
	BOSCLI_GET_SYNC_PROCESSING_NUM_FAILED     = "boscliGetUploadProcessingNumFailed"
	BOSCLI_GET_UPLOAD_THREAD_NUM_FAILED       = "boscliGetUplaodThreadNumFailed"
	BOSCLI_PUT_LIFECYCLE_NO_CONFIG_AND_BUCKET = "boscliPutLifecycleNoConfigAndBucket"
	BOSCLI_PUT_LOG_NO_TARGET_BUCKET           = "boscliPutLogNoTargetBucket"
	BOSCLI_STORAGE_CLASS_IS_EMPTY             = "boscliStorageClasssIsEmpty"
	BOSCLI_PUT_ACL_CANNED_FILE_SAME_TIME      = "boscliPutAclCannedFileSameTime"
	BOSCLI_PUT_ACL_CANNED_FILE_BOTH_EMPTY     = "boscliPutAclCannedFileBothEmpty"
	BOSCLI_PUT_ACL_CANNED_DONT_SUPPORT        = "boscliPutAclCannedDontSupport"
)
View Source
const (
	SRC_IS_BOS    = "srcIsBos"
	SRC_IS_LOCAL  = "srcIsLocal"
	SRC_IS_STREAM = "srcIsStream"
	MD5_CAlC_SIZE = 1024 * 1024
	FLUSH_PERIOD  = 20 * time.Second
)
View Source
const (
	FILE_AT_BOTH_SIDE existenceType = "fileAtBothSide"
	FILE_NOT_AT_SRC   existenceType = "fileNotAtSrc"
	FILE_NOT_AT_DST   existenceType = "fileNotAtDst"
)
View Source
const (
	BOSCLI_SUGGETION_PROPMT = "提示"
)
View Source
const (
	MAX_DELETE_NUM_EACH_TIME = 500
)

Variables

View Source
var (
	Quiet                 bool
	DisableBar            bool // display or not display progress bar
	IsConcurrentOperation bool
)
View Source
var BosCliSuggetions map[BosCliErrorCode]string

Functions

func ErrIsNotExist

func ErrIsNotExist(err error) bool

check whether the error is because no such file or directory

func FilterPrefixOfBosPath

func FilterPrefixOfBosPath(bosPath string) string

remove prefix of bosPath

func NewObjectListIterator

func NewObjectListIterator(bosClient bosClientInterface, filter *bosFilter, bucketName,
	objectKey, marker string, all, recursive, srcIsDir, showEmptyDir bool,
	maxKeys int) *objectListIterator

all: show all objects recursive: don't show pre full: show full path of object (don't contain bucket name) isObject: represent objectKey point to a single object, just get info of it

Types

type BosApi

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

func NewBosApi

func NewBosApi() *BosApi

Create new BosApi

func (*BosApi) DeleteLifecycle

func (b *BosApi) DeleteLifecycle(bosPath string)

Delete life cycle must have bucket_name

func (*BosApi) DeleteLogging

func (b *BosApi) DeleteLogging(bosPath string)

Delete logging must have bucket_name

func (*BosApi) GetBucketAcl

func (b *BosApi) GetBucketAcl(bosPath string)

Get ACL must have bucket_name

func (*BosApi) GetBucketStorageClass

func (b *BosApi) GetBucketStorageClass(bosPath string)

Get storage class must have bucket-name and storage-class

func (*BosApi) GetLifecycle

func (b *BosApi) GetLifecycle(bosPath string)

Get life cycle must have bucket_name

func (*BosApi) GetLogging

func (b *BosApi) GetLogging(bosPath string)

Get logging must have bucket_name

func (*BosApi) GetObjectMeta

func (b *BosApi) GetObjectMeta(bucketName string, objectName string) (*api.GetObjectMetaResult, error)

func (*BosApi) PutBucketAcl

func (b *BosApi) PutBucketAcl(aclConfigPath, bosPath string, canned string)

Put ACL

func (*BosApi) PutBucketStorageClass

func (b *BosApi) PutBucketStorageClass(bosPath, storageClass string)

Put storage class must have bucket-name and storage-class

func (*BosApi) PutLifecycle

func (b *BosApi) PutLifecycle(lifecycleConfigPath, bosPath string, template bool)

Put life cycle must have bucket_name

func (*BosApi) PutLogging

func (b *BosApi) PutLogging(targetBosPath, targetPrefix, bosPath string)

Put logging must have bucket_name

type BosCli

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

func NewBosCli

func NewBosCli() *BosCli

Create new BosCli

func (*BosCli) Copy

func (b *BosCli) Copy(srcPath, dstPath, storageClass, downLoadTmp string, recursive, restart, quiet,
	yes, disableBar bool)

cp : upload, download or copy param args: Parsed args, must have SRC, DST, force, no_override exception: Both SRC and DST are local path or stream

func (*BosCli) GenSignedUrl

func (b *BosCli) GenSignedUrl(bosPath string, expires int, haveSetExpires bool)

generate signed url for bospath

func (*BosCli) List

func (b *BosCli) List(bosPath string, all bool, recursive bool, summary bool)

List buckets or objects param: must have BOS_PATH attribute.

func (*BosCli) MakeBucket

func (b *BosCli) MakeBucket(bucketName, region string, quiet bool)

Make bucket

func (*BosCli) RemoveBucket

func (b *BosCli) RemoveBucket(bucketName string, force, yes, quiet bool)

rb: Command remove bucket from bos. param must have BUCKET_NAME force: delete bucket and ALL objects in it. yes: delete bucket without any prompt

func (*BosCli) RemoveObject

func (b *BosCli) RemoveObject(bosPath string, yes, recursive, quiet bool)

rm: remove object from bucekt, must have bos_path PARAMS:

bosPath   : bos path
yes       : delete object without prompts.
recursive : delete objects under subdirs.
quit      : do not display the operations performed from the specified command

func (*BosCli) Sync

func (b *BosCli) Sync(srcPath, dstPath, storageClass, downLoadTmp, syncType string, exclude, include, excludeTime,
	includeTime, excludeDelete []string, concurrency int, del, dryrun, yes, quiet, disableBar, restart bool)

sync local folder to bos 1. list all src 2. list all dst 3. compare and gen file list of src to be put to dst, and src to delete, if delete is defined 4. if dryrun is defined, show list to be processed param args: parsed args, must have SRC and DST explicitly defined

type BosCliErrorCode

type BosCliErrorCode string

type BreakPointRecord

type BreakPointRecord struct {
	Md5Val              string             `json:"md5"`
	UploadId            string             `json:"uploadId"`
	SrcFileSize         int64              `json:"fileSize"`
	SrcFileLastModified int64              `json:"fileModifyTime"`
	PartsNum            int64              `json:"partsNum"`
	PartSize            int64              `json:"partSize"`
	CompltePartList     []CompletePartInfo `json:"completePartList"`
	RecordTime          int64              `json:"recordTime"`
}

type Comparator

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

func NewComparator

func NewComparator(atBothSide, notAtDst, notAtSrc syncStrategyInfterface,
	args *syncArgs, srcFilesIterator, dstFilesIterator fileListIterator) *Comparator

generate new comparator PARAM:

atBothSide, sync strategy of both side have file
notAtDst, sync strategy of dst don't have file
notAtSrc, sync strategy of src don't have file
args, sync information

type CompletePartInfo

type CompletePartInfo struct {
	PartNumberId int64  `json:"partNumberId"`
	ETag         string `json:"eTag"`
}

type LocalFileIterator

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

func NewLocalFileIterator

func NewLocalFileIterator(localPath string, filter *bosFilter,
	followSymlinks bool) *LocalFileIterator

list local directory (only list files) localPath must be absolute path file name is sorted by lexicographical ordeor NOTICE: when sort file names, os separator is replace to bos separator

type MultiTaskContent

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

func (*MultiTaskContent) Exit

func (m *MultiTaskContent) Exit() error

flush the record of breakpoint transmission to disk when bcecmd non-mormal exit

func (*MultiTaskContent) Flush

func (m *MultiTaskContent) Flush() error

flush the record of breakpoint transmission to disk

func (*MultiTaskContent) GetFinshPartNum

func (m *MultiTaskContent) GetFinshPartNum() int

func (*MultiTaskContent) GetId

func (m *MultiTaskContent) GetId() (string, error)

func (*MultiTaskContent) Remove

func (m *MultiTaskContent) Remove() error

delete

Jump to

Keyboard shortcuts

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