bceconf

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: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BCE_VERSION                 = "0.3.0"
	EMPTY_STRING                = "none"
	DEFAULT_FOLDER_IN_USER_HOME = ".go-bcecli"
)
View Source
const (
	DEFAULT_AK  = ""
	DEFAULT_SK  = ""
	DEFAULT_STS = ""
)
View Source
const (
	SERVER_SECTION_NAME                    = "defaults"
	DOMAIN_OPTION_NAME                     = "domain"
	REGION_OPTION_NAME                     = "region"
	USE_AUTO_SWITCH_DOMAIN_OPTION_NAME     = "auto_switch_domain"
	BREAKPIONT_FILE_EXPIRATION_OPTION_NAME = "breakpoint_file_expiration"
	USE_HTTPS_OPTION_NAME                  = "https"
	MULTI_UPLOAD_THREAD_NUM_NAME           = "multi_upload_thread_num"
	DEFAULT_DOMAIN_SUFFIX                  = ".bcebos.com"
	DEFAULT_REGION                         = "bj"
	DEFAULT_USE_AUTO_SWITCH_DOMAIN         = "yes"
	DEFAULT_BREAKPIONT_FILE_EXPIRATION     = "7"
	DEFAULT_USE_HTTPS_PROTOCOL             = "no"
	DEFAULT_MULTI_UPLOAD_THREAD_NUM        = "10"
	DEFAULT_MULTI_UPLOAD_PART_SIZE         = "10"
	DEFAULT_SYNC_PROCESSING_NUM            = "10"
	WILL_USE_AUTO_SWTICH_DOMAIN            = "yes"
	DOMAINS_SECTION_NAME                   = "domains"
)
View Source
const (
	BUCKET_CACHE_EXPIRE = 3600
)

Variables

View Source
var (
	MultiuploadFolder string

	CredentialProvider *ChainCredentialProvider

	ServerConfigProvider        *ChainServerConfigProvider
	BucketEndpointCacheProvider *BucketToEndpointCacheProvider
)
View Source
var (
	AOLLOWED_CONFIRM_OPTIONS = map[string]bool{
		"y":   true,
		"yes": true,
		"Yes": true,
		"YES": true,
		"n":   false,
		"no":  false,
		"No":  false,
		"NO":  false,
	}
	BOOL_TO_STRING = map[bool]string{
					// contains filtered or unexported fields
	}

	DEFAULT_DOMAINS = map[string]string{
		"bj":   "bj.bcebos.com",
		"gz":   "gz.bcebos.com",
		"su":   "su.bcebos.com",
		"hk02": "hk-2.bcebos.com",
		"hkg":  "hkg.bcebos.com",
		"yq":   "bos.yq.baidubce.com",
	}
)

Functions

func ConfigInteractive

func ConfigInteractive(configDirPath string)

Provide interactive configuration with user

func DestructConfFolder

func DestructConfFolder()

If the conf of cache and config are changed. We do not save the change to file, when run time. We save the change into file when exit!

func InitConfig

func InitConfig(configDirPath string) error

func LoadConfig

func LoadConfig(confPath string, cfg interface{}) error

*Loading configure from file. * Use gcfg loading configure from file. *PARAMS: * confPath: the path of configure file. * cfg : the config struct *RETURN: * error: nil or error.

func ReloadConfAction

func ReloadConfAction(configDirPath string)

users can use --conf-path to reload configuration from specified path.

func SetDebug

func SetDebug()

func WriteConfig

func WriteConfig(confPath string, cfg interface{}) error

* Writing configure into File. * PARAMS: * confPath: the path of configure file. * cfg: a interface, which must be a point of struct, and the fields of it must be struct * or map, where map must have string keys and pointer-to-struct values! * RETURN: * error: nil or error.

Types

type BucketToEndpointCache

type BucketToEndpointCache struct {
	Buckets map[string]*BucketToEndpointInfo
}

type BucketToEndpointCacheProvider

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

func NewBucketToEndpointCacheProvider

func NewBucketToEndpointCacheProvider(cachePath string) (*BucketToEndpointCacheProvider, error)

New bucket to endpoint cahce provider

func (*BucketToEndpointCacheProvider) Delete

func (b *BucketToEndpointCacheProvider) Delete(bucketName string) error

Delete the endpoint of bucket from cache

func (*BucketToEndpointCacheProvider) Get

func (b *BucketToEndpointCacheProvider) Get(bucketName string) (string, bool)

Get the endpoint of bucket from cache. when endpoint is expired, delete the bucket from cache

func (*BucketToEndpointCacheProvider) Write

func (b *BucketToEndpointCacheProvider) Write(bucketName, endpoint string, expireTime int64) bool

Write the endpoint of bucket to cache

type BucketToEndpointInfo

type BucketToEndpointInfo struct {
	Endpoint string
}

type ChainCredentialProvider

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

func NewChainCredentialProvider

func NewChainCredentialProvider(chain []CredentialProviderInterface) *ChainCredentialProvider

func (*ChainCredentialProvider) GetAccessKey

func (c *ChainCredentialProvider) GetAccessKey() (string, bool)

func (*ChainCredentialProvider) GetSecretKey

func (c *ChainCredentialProvider) GetSecretKey() (string, bool)

func (*ChainCredentialProvider) GetSecurityToken

func (c *ChainCredentialProvider) GetSecurityToken() (string, bool)

type ChainServerConfigProvider

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

func (*ChainServerConfigProvider) GetBreakpointFileExpiration

func (c *ChainServerConfigProvider) GetBreakpointFileExpiration() (int, bool)

Get breakpoint file expiration

func (*ChainServerConfigProvider) GetDomain

func (c *ChainServerConfigProvider) GetDomain() (string, bool)

Get default domain

func (*ChainServerConfigProvider) GetDomainByRegion

func (c *ChainServerConfigProvider) GetDomainByRegion(region string) (string, bool)

Get default domain of region

func (*ChainServerConfigProvider) GetMultiUploadPartSize

func (c *ChainServerConfigProvider) GetMultiUploadPartSize() (int64, bool)

Get sever multi upload part size

func (*ChainServerConfigProvider) GetMultiUploadThreadNum

func (c *ChainServerConfigProvider) GetMultiUploadThreadNum() (int64, bool)

Get sever multi upload thread number

func (*ChainServerConfigProvider) GetRegion

func (c *ChainServerConfigProvider) GetRegion() (string, bool)

Get default region

func (*ChainServerConfigProvider) GetSyncProcessingNum

func (c *ChainServerConfigProvider) GetSyncProcessingNum() (int, bool)

Get sync processing num number

func (*ChainServerConfigProvider) GetUseAutoSwitchDomain

func (c *ChainServerConfigProvider) GetUseAutoSwitchDomain() (bool, bool)

Get wheather use auto siwitch domain

func (*ChainServerConfigProvider) GetUseHttpsProtocol

func (c *ChainServerConfigProvider) GetUseHttpsProtocol() (bool, bool)

Get wheather use https protocol

type CredentialCfg

type CredentialCfg struct {
	Defaults CredentialDefaultsCfg
}

type CredentialDefaultsCfg

type CredentialDefaultsCfg struct {
	Ak  string // access key
	Sk  string // secret key
	Sts string // Security Token
}

type CredentialProviderInterface

type CredentialProviderInterface interface {
	GetAccessKey() (string, bool)
	GetSecretKey() (string, bool)
	GetSecurityToken() (string, bool)
}

type DefaultCredentialProvider

type DefaultCredentialProvider struct{}

func NewDefaultCredentialProvider

func NewDefaultCredentialProvider() (*DefaultCredentialProvider, error)

func (*DefaultCredentialProvider) GetAccessKey

func (n *DefaultCredentialProvider) GetAccessKey() (string, bool)

func (*DefaultCredentialProvider) GetSecretKey

func (n *DefaultCredentialProvider) GetSecretKey() (string, bool)

func (*DefaultCredentialProvider) GetSecurityToken

func (n *DefaultCredentialProvider) GetSecurityToken() (string, bool)

type DefaultServerConfigProvider

type DefaultServerConfigProvider struct{}

Provide default value for serve configuration

func NewDefaultServerConfigProvider

func NewDefaultServerConfigProvider() (*DefaultServerConfigProvider, error)

func (*DefaultServerConfigProvider) GetBreakpointFileExpiration

func (d *DefaultServerConfigProvider) GetBreakpointFileExpiration() (int, bool)

Get breakpoint file expiration

func (*DefaultServerConfigProvider) GetDomain

func (d *DefaultServerConfigProvider) GetDomain() (string, bool)

Get default domain default domain is region + ".bcebos.com"

func (*DefaultServerConfigProvider) GetDomainByRegion

func (d *DefaultServerConfigProvider) GetDomainByRegion(region string) (string, bool)

Get default domain of region if region is empty, return defalut-region + ".bcebos.com" else find the domian of region in DEFAULT_DOMAINS

func (*DefaultServerConfigProvider) GetMultiUploadPartSize

func (d *DefaultServerConfigProvider) GetMultiUploadPartSize() (int64, bool)

Get sync processing num number

func (*DefaultServerConfigProvider) GetMultiUploadThreadNum

func (d *DefaultServerConfigProvider) GetMultiUploadThreadNum() (int64, bool)

Get sever multi upload thread number

func (*DefaultServerConfigProvider) GetRegion

func (d *DefaultServerConfigProvider) GetRegion() (string, bool)

Get default region

func (*DefaultServerConfigProvider) GetSyncProcessingNum

func (d *DefaultServerConfigProvider) GetSyncProcessingNum() (int, bool)

Get sync processing num number

func (*DefaultServerConfigProvider) GetUseAutoSwitchDomain

func (d *DefaultServerConfigProvider) GetUseAutoSwitchDomain() (bool, bool)

Get wheather use auto siwitch domain

func (*DefaultServerConfigProvider) GetUseHttpsProtocol

func (d *DefaultServerConfigProvider) GetUseHttpsProtocol() (bool, bool)

Get wheather use https protocol

type EndpointCfg

type EndpointCfg struct {
	Endpoint string
}

Store region => domain

type FileCredentialProvider

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

Provide ak and sk for cli

func NewFileCredentialProvider

func NewFileCredentialProvider(cofingPath string) (*FileCredentialProvider, error)

New credential configuration provider

func (*FileCredentialProvider) GetAccessKey

func (f *FileCredentialProvider) GetAccessKey() (string, bool)

Get Access Key.

func (*FileCredentialProvider) GetSecretKey

func (f *FileCredentialProvider) GetSecretKey() (string, bool)

Get Secret Key.

func (*FileCredentialProvider) GetSecurityToken

func (f *FileCredentialProvider) GetSecurityToken() (string, bool)

func (*FileCredentialProvider) SetAccessKey

func (f *FileCredentialProvider) SetAccessKey(ak string)

Set Access key.

func (*FileCredentialProvider) SetSecretKey

func (f *FileCredentialProvider) SetSecretKey(sk string)

Set Secret key.

func (*FileCredentialProvider) SetSecurityToken

func (f *FileCredentialProvider) SetSecurityToken(sts string)

type FileServerConfigProvider

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

Read server configuration from a file

func NewFileServerConfigProvider

func NewFileServerConfigProvider(cofingPath string) (*FileServerConfigProvider, error)

New file configuration provider

func (*FileServerConfigProvider) DelDomainInDomains

func (f *FileServerConfigProvider) DelDomainInDomains(region string)

Delete a domain from domains, return nothing

func (*FileServerConfigProvider) GetBreakpointFileExpiration

func (f *FileServerConfigProvider) GetBreakpointFileExpiration() (int, bool)

return: Breakpoint file expiration

func (*FileServerConfigProvider) GetDomain

func (f *FileServerConfigProvider) GetDomain() (string, bool)

Get server domain address

func (*FileServerConfigProvider) GetDomainByRegion

func (f *FileServerConfigProvider) GetDomainByRegion(region string) (string, bool)

Get server domain by region return: The domian of region

func (*FileServerConfigProvider) GetMultiUploadPartSize

func (f *FileServerConfigProvider) GetMultiUploadPartSize() (int64, bool)

Get sync processing num number

func (*FileServerConfigProvider) GetMultiUploadThreadNum

func (f *FileServerConfigProvider) GetMultiUploadThreadNum() (int64, bool)

return: Server is multi upload thread num

func (*FileServerConfigProvider) GetRegion

func (f *FileServerConfigProvider) GetRegion() (string, bool)

Return server region.

func (*FileServerConfigProvider) GetSyncProcessingNum

func (f *FileServerConfigProvider) GetSyncProcessingNum() (int, bool)

Get sync processing num number

func (*FileServerConfigProvider) GetUseAutoSwitchDomain

func (f *FileServerConfigProvider) GetUseAutoSwitchDomain() (bool, bool)

return use auto siwitch domain ('yes' or 'no' or empty)

func (*FileServerConfigProvider) GetUseHttpsProtocol

func (f *FileServerConfigProvider) GetUseHttpsProtocol() (bool, bool)

Get wheather use https RETURN: true or false

func (*FileServerConfigProvider) InsertDomainIntoDomains

func (f *FileServerConfigProvider) InsertDomainIntoDomains(region, domain string) bool

param region: Set server domain by region return:false or true

func (*FileServerConfigProvider) SetBreakpointFileExpiration

func (f *FileServerConfigProvider) SetBreakpointFileExpiration(num string) bool

param breakpoint_file_expiration: Set breakpoint file expiration num can be empty

func (*FileServerConfigProvider) SetDomain

func (f *FileServerConfigProvider) SetDomain(domain string)

param domain: Set server domain address domain can be empty

func (*FileServerConfigProvider) SetDomains

func (f *FileServerConfigProvider) SetDomains(domains map[string]*EndpointCfg)

Set server domains address. domains is {region1: domain1, region2: domain2 } domains can be empty

func (*FileServerConfigProvider) SetMultiUploadPartSize

func (f *FileServerConfigProvider) SetMultiUploadPartSize(multiUploadPartSize string) bool

set mulit upload part size

func (*FileServerConfigProvider) SetMultiUploadThreadNum

func (f *FileServerConfigProvider) SetMultiUploadThreadNum(multiUploadThreadNum string) bool

set multi uplaod thread number

func (*FileServerConfigProvider) SetRegion

func (f *FileServerConfigProvider) SetRegion(region string) bool

Set server region

func (*FileServerConfigProvider) SetSyncProcessingNum

func (f *FileServerConfigProvider) SetSyncProcessingNum(syncProcessingNum string) bool

set sync processing number

func (*FileServerConfigProvider) SetUseAutoSwitchDomain

func (f *FileServerConfigProvider) SetUseAutoSwitchDomain(useAutoSwitchDomain string) bool

Set use auto siwitch domain ("yes" or "no")

func (*FileServerConfigProvider) SetUseHttpsProtocol

func (f *FileServerConfigProvider) SetUseHttpsProtocol(useHttpsProtocol string) bool

set use https protocol

type ServerConfig

type ServerConfig struct {
	Defaults ServerDefaultsCfg
	Domains  map[string]*EndpointCfg
}

type ServerConfigProviderInterface

type ServerConfigProviderInterface interface {
	GetDomain() (string, bool)
	GetDomainByRegion(string) (string, bool)
	GetRegion() (string, bool)
	GetUseAutoSwitchDomain() (bool, bool)
	GetBreakpointFileExpiration() (int, bool)
	GetUseHttpsProtocol() (bool, bool)
	GetMultiUploadThreadNum() (int64, bool)
	GetSyncProcessingNum() (int, bool)
	GetMultiUploadPartSize() (int64, bool)
}

type ServerDefaultsCfg

type ServerDefaultsCfg struct {
	Domain                   string
	Region                   string
	AutoSwitchDomain         string
	BreakpointFileExpiration string
	Https                    string
	MultiUploadThreadNum     string
	SyncProcessingNum        string
	MultiUploadPartSize      string
}

Store the default configuration. The default value of int is zero, therefore each parameter is special as string .

Jump to

Keyboard shortcuts

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