Skip to content

Commit ebf04dc

Browse files
authored
update ossutil 1.6.11 (#269)
1 parent 19058cd commit ebf04dc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+3899
-1113
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
### Master
44

5+
- update: ossutil 1.6.11
56
- fix: Skip https certificate verification
67

78
### 3.0.37

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.12
55
require (
66
github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 // indirect
77
github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20191112024640-6523ede38591
8-
github.com/aliyun/aliyun-oss-go-sdk v2.0.3+incompatible
8+
github.com/aliyun/aliyun-oss-go-sdk v2.0.8+incompatible
99
github.com/aliyun/credentials-go v0.0.0-20190906110604-c03d72db9395
1010
github.com/alyu/configparser v0.0.0-20191103060215-744e9a66e7bc
1111
github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f // indirect
@@ -20,7 +20,7 @@ require (
2020
github.com/onsi/ginkgo v1.10.3
2121
github.com/onsi/gomega v1.7.1
2222
github.com/posener/complete v1.2.2
23-
github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b
23+
github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b // indirect
2424
github.com/smartystreets/assertions v1.0.1 // indirect
2525
github.com/smartystreets/goconvey v1.6.4 // indirect
2626
github.com/stretchr/testify v1.4.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20191112024640-6523ede38591 h1:rbX
44
github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20191112024640-6523ede38591/go.mod h1:mNZkuqaeM5UCiAdkV4r+lrheu8Q5fe/487bRFrGYZ8A=
55
github.com/aliyun/aliyun-oss-go-sdk v2.0.3+incompatible h1:724q2AmQ3m1mrdD9kYqK5+1+Zr77vS21jdQ9iF9t4b8=
66
github.com/aliyun/aliyun-oss-go-sdk v2.0.3+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
7+
github.com/aliyun/aliyun-oss-go-sdk v2.0.8+incompatible h1:WaOAKiuezSaRKAYeSf5IjxuAy/0Gx7ts6qWhKWPZf7s=
8+
github.com/aliyun/aliyun-oss-go-sdk v2.0.8+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
79
github.com/aliyun/credentials-go v0.0.0-20190906110604-c03d72db9395 h1:ey3Xbk1uAgNOlWZAH7KDBxmoa0IcOt+snhA0vN8EA7s=
810
github.com/aliyun/credentials-go v0.0.0-20190906110604-c03d72db9395/go.mod h1:AJeNV4JgJLF+XrTuSe0EPfSs702qFXKNJVOqloWotqs=
911
github.com/alyu/configparser v0.0.0-20191103060215-744e9a66e7bc h1:eN2FUvn4J1A31pICABioDYukoh1Tmlei6L3ImZUin/I=

oss/lib/bucket_encryption.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,10 @@ func (bec *BucketEncryptionCommand) PutBucketEncryption() error {
173173
strAlgorithm, _ := GetString(OptionSSEAlgorithm, bec.command.options)
174174
strKeyId, _ := GetString(OptionKMSMasterKeyID, bec.command.options)
175175

176-
if strAlgorithm != string(oss.KMSAlgorithm) && strAlgorithm != string(oss.AESAlgorithm) {
177-
return fmt.Errorf("value of option --sse-algorithm must be KMS or AES256")
178-
}
176+
// support sm4 algorithm
177+
//if strAlgorithm != string(oss.KMSAlgorithm) && strAlgorithm != string(oss.AESAlgorithm) {
178+
// return fmt.Errorf("value of option --sse-algorithm must be KMS or AES256")
179+
//}
179180

180181
if strAlgorithm == string(oss.AESAlgorithm) && len(strKeyId) > 0 {
181182
return fmt.Errorf("value of option --kms-masterkey-id must be empty if value of option --sse-algorithm is AES256")

oss/lib/bucket_website.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import (
66
"io/ioutil"
77
"os"
88
"strings"
9-
10-
oss "github.com/aliyun/aliyun-oss-go-sdk/oss"
119
)
1210

1311
var specChineseBucketWebSite = SpecText{
@@ -321,19 +319,13 @@ func (bwc *BucketWebSiteCommand) PutBucketWebsite() error {
321319
return err
322320
}
323321

324-
websiteConfig := oss.WebsiteXML{}
325-
err = xml.Unmarshal(text, &websiteConfig)
326-
if err != nil {
327-
return err
328-
}
329-
330322
// put bucket website
331323
client, err := bwc.command.ossClient(bwc.bwOption.bucketName)
332324
if err != nil {
333325
return err
334326
}
335327

336-
return client.SetBucketWebsiteDetail(bwc.bwOption.bucketName, websiteConfig)
328+
return client.SetBucketWebsiteXml(bwc.bwOption.bucketName, string(text))
337329
}
338330

339331
func (bwc *BucketWebSiteCommand) confirm(str string) bool {

oss/lib/command.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ package lib
22

33
import (
44
"fmt"
5+
"net"
56
"net/http"
67
"net/url"
8+
"reflect"
79
"strconv"
810
"strings"
911
"time"
@@ -288,6 +290,7 @@ func (cmd *Command) ossClient(bucket string) (*oss.Client, error) {
288290
proxyUser, _ := GetString(OptionProxyUser, cmd.options)
289291
proxyPwd, _ := GetString(OptionProxyPwd, cmd.options)
290292
ecsUrl, _ := cmd.getEcsRamAkService()
293+
localHost, _ := GetString(OptionLocalHost, cmd.options)
291294

292295
if accessKeyID == "" && ecsUrl == "" {
293296
return nil, fmt.Errorf("accessKeyID and ecsUrl are both empty")
@@ -314,6 +317,15 @@ func (cmd *Command) ossClient(bucket string) (*oss.Client, error) {
314317
}
315318
}
316319

320+
if localHost != "" {
321+
ipAddr, err := net.ResolveIPAddr("ip", localHost)
322+
if err != nil {
323+
return nil, fmt.Errorf("net.ResolveIPAddr error,%s", err.Error())
324+
}
325+
localTCPAddr := &(net.TCPAddr{IP: ipAddr.IP})
326+
options = append(options, oss.SetLocalAddr(localTCPAddr))
327+
}
328+
317329
if logLevel > oss.LogOff {
318330
options = append(options, oss.SetLogLevel(logLevel))
319331
options = append(options, oss.SetLogger(utilLogger))
@@ -590,6 +602,11 @@ func (cmd *Command) filterError(err error, option *batchOptionType) bool {
590602
return false
591603
}
592604

605+
errorTypeName := reflect.TypeOf(err).String()
606+
if !strings.Contains(errorTypeName, "ObjectError") {
607+
return false
608+
}
609+
593610
err = err.(ObjectError).err
594611

595612
switch err.(type) {
@@ -619,6 +636,28 @@ func (cmd *Command) getOSSOptions(hopMap map[string]interface{}, headers map[str
619636
return options, nil
620637
}
621638

639+
func (cmd *Command) getOSSTagging(strTagging string) ([]oss.Tag, error) {
640+
tags := []oss.Tag{}
641+
strKeys := strings.Split(strTagging, "&")
642+
for _, v := range strKeys {
643+
if v == "" {
644+
return tags, fmt.Errorf("tagging value is empty,maybe exist &&")
645+
}
646+
tagNode := strings.Split(v, "=")
647+
if len(tagNode) >= 3 {
648+
return tags, fmt.Errorf("tagging value error %s", v)
649+
}
650+
651+
// value maybe empty
652+
tagNode = append(tagNode, "")
653+
tags = append(tags, oss.Tag{
654+
Key: tagNode[0],
655+
Value: tagNode[1],
656+
})
657+
}
658+
return tags, nil
659+
}
660+
622661
// GetAllCommands returns all commands list
623662
func GetAllCommands() []interface{} {
624663
return []interface{}{

oss/lib/command_test.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"fmt"
55
"io/ioutil"
66
"log"
7-
"math/rand"
87
"os"
98
"os/user"
109
"path/filepath"
@@ -173,17 +172,6 @@ func (s *OssutilCommandSuite) TearDownTest(c *C) {
173172
fmt.Printf("tear down test:%s,cost:%d(ms)\n", c.TestName(), cost)
174173
}
175174

176-
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
177-
178-
func randStr(n int) string {
179-
b := make([]rune, n)
180-
r := rand.New(rand.NewSource(time.Now().UnixNano()))
181-
for i := range b {
182-
b[i] = letters[r.Intn(len(letters))]
183-
}
184-
return string(b)
185-
}
186-
187175
func randLowStr(n int) string {
188176
return strings.ToLower(randStr(n))
189177
}

oss/lib/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,16 +393,16 @@ func (cc *ConfigCommand) runCommandInteractive(configFile, language string) erro
393393

394394
if configFile == "" {
395395
if llanguage == LEnglishLanguage {
396-
fmt.Printf("\nPlease enter the config file path(default " + DecideConfigFile("") + ", carriage return will use the default path. If you specified this option to other path, you should specify --config-file option to the path when you use other commands):")
396+
fmt.Printf("\nPlease enter the config file name,the file name can include path(default " + DecideConfigFile("") + ", carriage return will use the default file. If you specified this option to other file, you should specify --config-file option to the file when you use other commands):")
397397
} else {
398-
fmt.Printf("\n请输入配置文件路径(默认为:" + DecideConfigFile("") + ",回车将使用默认路径。如果用户设置为其它路径,在使用命令时需要将--config-file选项设置为该路径):")
398+
fmt.Printf("\n请输入配置文件名,文件名可以带路径(默认为:" + DecideConfigFile("") + ",回车将使用默认配置文件。如果用户设置为其它文件,在使用命令时需要将--config-file选项设置为该文件):")
399399
}
400400

401401
if _, err := fmt.Scanln(&configFile); err != nil {
402402
if llanguage == LEnglishLanguage {
403403
fmt.Println("No config file entered, will use the default config file " + DecideConfigFile("") + "\n")
404404
} else {
405-
fmt.Println("未输入配置文件路径,将使用默认配置文件:" + DecideConfigFile("") + "。\n")
405+
fmt.Println("未输入配置文件,将使用默认配置文件:" + DecideConfigFile("") + "。\n")
406406
}
407407
}
408408
}

oss/lib/config_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,12 @@ func (s *OssutilConfigSuite) TestConfigNotConfigFile(c *C) {
255255
configCommand.runCommandInteractive("", LEnglishLanguage)
256256
contents, _ := ioutil.ReadFile(logPath)
257257
LogContent := string(contents)
258-
c.Assert(strings.Contains(LogContent, "Please enter the config file path"), Equals, true)
258+
c.Assert(strings.Contains(LogContent, "Please enter the config file name"), Equals, true)
259259

260260
configCommand.runCommandInteractive("", ChineseLanguage)
261261
contents, _ = ioutil.ReadFile(logPath)
262262
LogContent = string(contents)
263-
c.Assert(strings.Contains(LogContent, "请输入配置文件路径"), Equals, true)
263+
c.Assert(strings.Contains(LogContent, "请输入配置文件名"), Equals, true)
264264
}
265265

266266
func (s *OssutilConfigSuite) TestConfigConfigInteractive(c *C) {

oss/lib/const.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ const (
7171
OptionProxyHost = "proxyHost"
7272
OptionProxyUser = "proxyUser"
7373
OptionProxyPwd = "proxyPwd"
74+
OptionLocalHost = "localHost"
75+
OptionEnableSymlinkDir = "enableSymlinkDir"
76+
OptionOnlyCurrentDir = "onlyCurrentDir"
77+
OptionProbeItem = "probeItem"
78+
OptionDisableEncodeSlash = "disableEncodeSlash"
79+
OptionDisableDirObject = "disableDirObject"
80+
OptionRedundancyType = "redundancyType"
81+
OptionDisableAllSymlink = "disableAllSymlink"
82+
OptionDisableIgnoreError = "disableIgnoreError"
83+
OptionTagging = "tagging"
7484
)
7585

7686
// the elements show in stat object
@@ -88,6 +98,7 @@ const (
8898
StatStorageClass = "StorageClass"
8999
StatSSEAlgorithm = "SSEAlgorithm"
90100
StatKMSMasterKeyID = "KMSMasterKeyID"
101+
StatRedundancyType = "RedundancyType"
91102
)
92103

93104
// the elements show in hash file
@@ -114,7 +125,7 @@ const (
114125
const (
115126
Package string = "ossutil"
116127
ChannelBuf int = 1000
117-
Version string = "v1.6.6"
128+
Version string = "v1.6.11"
118129
DefaultEndpoint string = "oss.aliyuncs.com"
119130
ChineseLanguage = "CH"
120131
EnglishLanguage = "EN"

0 commit comments

Comments
 (0)