MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / newClient

Function newClient

agent/app/service/backup.go:509–539  ·  view source on GitHub ↗
(account *model.BackupAccount, isEncrypt bool)

Source from the content-addressed store, hash-verified

507}
508
509func newClient(account *model.BackupAccount, isEncrypt bool) (cloud_storage.CloudStorageClient, error) {
510 varMap := make(map[string]interface{})
511 if len(account.Vars) != 0 {
512 if err := json.Unmarshal([]byte(account.Vars), &varMap); err != nil {
513 return nil, err
514 }
515 }
516 varMap["bucket"] = account.Bucket
517 varMap["backupPath"] = account.BackupPath
518 if isEncrypt {
519 account.AccessKey, _ = encrypt.StringDecrypt(account.AccessKey)
520 account.Credential, _ = encrypt.StringDecrypt(account.Credential)
521 }
522 switch account.Type {
523 case constant.Sftp, constant.WebDAV:
524 varMap["username"] = account.AccessKey
525 varMap["password"] = account.Credential
526 case constant.OSS, constant.S3, constant.MinIo, constant.Cos, constant.Kodo:
527 varMap["accessKey"] = account.AccessKey
528 varMap["secretKey"] = account.Credential
529 case constant.UPYUN:
530 varMap["operator"] = account.AccessKey
531 varMap["password"] = account.Credential
532 }
533
534 client, err := cloud_storage.NewCloudStorageClient(account.Type, varMap)
535 if err != nil {
536 return nil, err
537 }
538 return client, nil
539}
540
541func loadRefreshTokenByCode(backup *model.BackupAccount) (string, error) {
542 varMap := make(map[string]interface{})

Callers 3

checkBackupConnMethod · 0.85
NewBackupClientWithIDFunction · 0.85
NewBackupClientMapFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected