fog-aliyun 0.3.17 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +35 -2
- data/fog-aliyun.gemspec +4 -3
- data/lib/fog/aliyun/compute.rb +7 -5
- data/lib/fog/aliyun/models/storage/directories.rb +30 -53
- data/lib/fog/aliyun/models/storage/directory.rb +96 -17
- data/lib/fog/aliyun/models/storage/file.rb +127 -126
- data/lib/fog/aliyun/models/storage/files.rb +43 -124
- data/lib/fog/aliyun/requests/compute/attach_disk.rb +3 -1
- data/lib/fog/aliyun/requests/compute/create_security_group_egress_ip_rule.rb +4 -2
- data/lib/fog/aliyun/requests/compute/create_security_group_egress_sg_rule.rb +3 -1
- data/lib/fog/aliyun/requests/compute/create_security_group_ip_rule.rb +4 -2
- data/lib/fog/aliyun/requests/compute/create_security_group_sg_rule.rb +3 -1
- data/lib/fog/aliyun/requests/compute/create_vpc.rb +3 -1
- data/lib/fog/aliyun/requests/compute/create_vswitch.rb +3 -1
- data/lib/fog/aliyun/requests/compute/delete_security_group_egress_ip_rule.rb +4 -2
- data/lib/fog/aliyun/requests/compute/delete_security_group_egress_sg_rule.rb +3 -1
- data/lib/fog/aliyun/requests/compute/delete_security_group_ip_rule.rb +4 -2
- data/lib/fog/aliyun/requests/compute/delete_security_group_sg_rule.rb +3 -1
- data/lib/fog/aliyun/requests/compute/detach_disk.rb +3 -1
- data/lib/fog/aliyun/requests/compute/modify_vpc.rb +3 -1
- data/lib/fog/aliyun/requests/compute/modify_vswitch.rb +3 -1
- data/lib/fog/aliyun/requests/storage/abort_multipart_upload.rb +22 -0
- data/lib/fog/aliyun/requests/storage/complete_multipart_upload.rb +21 -0
- data/lib/fog/aliyun/requests/storage/copy_object.rb +14 -18
- data/lib/fog/aliyun/requests/storage/delete_bucket.rb +3 -9
- data/lib/fog/aliyun/requests/storage/delete_multiple_objects.rb +20 -0
- data/lib/fog/aliyun/requests/storage/delete_object.rb +10 -11
- data/lib/fog/aliyun/requests/storage/get_bucket.rb +22 -99
- data/lib/fog/aliyun/requests/storage/get_bucket_location.rb +33 -0
- data/lib/fog/aliyun/requests/storage/get_object.rb +20 -12
- data/lib/fog/aliyun/requests/storage/get_object_acl.rb +30 -0
- data/lib/fog/aliyun/requests/storage/get_object_http_url.rb +9 -10
- data/lib/fog/aliyun/requests/storage/get_object_https_url.rb +9 -10
- data/lib/fog/aliyun/requests/storage/get_service.rb +13 -0
- data/lib/fog/aliyun/requests/storage/head_object.rb +25 -13
- data/lib/fog/aliyun/requests/storage/initiate_multipart_upload.rb +19 -0
- data/lib/fog/aliyun/requests/storage/list_buckets.rb +5 -25
- data/lib/fog/aliyun/requests/storage/list_objects.rb +10 -62
- data/lib/fog/aliyun/requests/storage/put_bucket.rb +2 -8
- data/lib/fog/aliyun/requests/storage/put_object.rb +16 -122
- data/lib/fog/aliyun/requests/storage/upload_part.rb +24 -0
- data/lib/fog/aliyun/storage.rb +20 -4
- data/lib/fog/aliyun/version.rb +1 -1
- metadata +31 -19
- data/lib/fog/aliyun/requests/storage/delete_container.rb +0 -30
- data/lib/fog/aliyun/requests/storage/get_container.rb +0 -57
- data/lib/fog/aliyun/requests/storage/get_containers.rb +0 -61
- data/lib/fog/aliyun/requests/storage/put_container.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 902530b35b7b3b8213965642cb9994b53399a02e65cf75270fc30f9f4a662ad2
|
4
|
+
data.tar.gz: 9a413e6577adbed08130870c7e7aa751ceb80aec8bb53d42eb43f694cff56a0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d8a867a2cd5be94ec813a8ee11371eed34530aff2554227590c5fdcae9b0ebb197f421ecd7716c38fd9cc930f91f5b2390b28b247fd9dca2cc87f08c4d3311f
|
7
|
+
data.tar.gz: dc7c248af9cb3388bf2453f8c4096935dafa3ca251c86d75da251c61feda0980d36fd01241a53b4bbff97f0460df609e9634062bc73df851e8510b6368d6e653
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.0.4
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,37 @@
|
|
1
|
-
## 0.
|
1
|
+
## 0.4.1 (Unreleased)
|
2
|
+
## 0.4.0 (August 17, 2022)
|
3
|
+
|
4
|
+
IMPROVEMENTS:
|
5
|
+
- Ruby 3 [GH-158](https://github.com/fog/fog-aliyun/pull/158)
|
6
|
+
|
7
|
+
## 0.3.19 (August 17, 2020)
|
8
|
+
|
9
|
+
IMPROVEMENTS:
|
10
|
+
|
11
|
+
- Upgrade oss ruby sdk to support setting log level [GH-152](https://github.com/fog/fog-aliyun/pull/152)
|
12
|
+
|
13
|
+
## 0.3.18 (August 03, 2020)
|
14
|
+
|
15
|
+
IMPROVEMENTS:
|
16
|
+
|
17
|
+
- reconstruct perform test [GH-148](https://github.com/fog/fog-aliyun/pull/148)
|
18
|
+
- Reconstruct fog-aliyun by using oss [GH-147](https://github.com/fog/fog-aliyun/pull/147)
|
19
|
+
- reconstruct cover case test [GH-146](https://github.com/fog/fog-aliyun/pull/146)
|
20
|
+
- reconstruct case test [GH-144](https://github.com/fog/fog-aliyun/pull/144)
|
21
|
+
- reconstruct parts two of file [GH-143](https://github.com/fog/fog-aliyun/pull/143)
|
22
|
+
- implement blobstore for cloud_controller_ng [GH-142](https://github.com/fog/fog-aliyun/pull/142)
|
23
|
+
- reconstruct parts of file [GH-141](https://github.com/fog/fog-aliyun/pull/141)
|
24
|
+
- reconstruct the files [GH-140](https://github.com/fog/fog-aliyun/pull/140)
|
25
|
+
- reconstruct the directory [GH-139](https://github.com/fog/fog-aliyun/pull/139)
|
26
|
+
- reconstruct the directories [GH-138](https://github.com/fog/fog-aliyun/pull/138)
|
27
|
+
- improve files.get code [GH-137](https://github.com/fog/fog-aliyun/pull/137)
|
28
|
+
- add testcase for testing head notexistfile [GH-136](https://github.com/fog/fog-aliyun/pull/136)
|
29
|
+
- improve head_object using oss sdk [GH-135](https://github.com/fog/fog-aliyun/pull/135)
|
30
|
+
|
31
|
+
BUG FIXES:
|
32
|
+
|
33
|
+
- fix files all options problem [GH-149](https://github.com/fog/fog-aliyun/pull/149)
|
34
|
+
|
2
35
|
## 0.3.17 (July 06, 2020)
|
3
36
|
|
4
37
|
IMPROVEMENTS:
|
@@ -78,4 +111,4 @@ IMPROVEMENTS:
|
|
78
111
|
## 0.3.9 (May 07, 2020)
|
79
112
|
|
80
113
|
BUG FIXES:
|
81
|
-
- diectories.get supports options to filter the specified objects [GH-62](https://github.com/fog/fog-aliyun/pull/62)
|
114
|
+
- diectories.get supports options to filter the specified objects [GH-62](https://github.com/fog/fog-aliyun/pull/62)
|
data/fog-aliyun.gemspec
CHANGED
@@ -21,16 +21,17 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.require_paths = ['lib']
|
22
22
|
|
23
23
|
spec.add_development_dependency 'bundler'
|
24
|
-
spec.add_development_dependency 'mime-types', '~>
|
24
|
+
spec.add_development_dependency 'mime-types', '~> 3.4'
|
25
25
|
spec.add_development_dependency 'pry-nav'
|
26
26
|
spec.add_development_dependency 'rake'
|
27
27
|
spec.add_development_dependency 'rspec'
|
28
28
|
spec.add_development_dependency 'rubocop'
|
29
29
|
spec.add_development_dependency 'simplecov'
|
30
30
|
spec.add_development_dependency 'memory_profiler'
|
31
|
-
spec.add_development_dependency 'aliyun-sdk', '~> 0.
|
31
|
+
spec.add_development_dependency 'aliyun-sdk', '~> 0.8.0'
|
32
32
|
|
33
|
-
spec.add_dependency '
|
33
|
+
spec.add_dependency 'addressable', '~> 2.8.0'
|
34
|
+
spec.add_dependency 'aliyun-sdk', '~> 0.8.0'
|
34
35
|
spec.add_dependency 'fog-core'
|
35
36
|
spec.add_dependency 'fog-json'
|
36
37
|
spec.add_dependency 'ipaddress', '~> 0.8'
|
data/lib/fog/aliyun/compute.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'addressable'
|
4
|
+
|
3
5
|
module Fog
|
4
6
|
module Compute
|
5
7
|
class Aliyun < Fog::Service
|
@@ -350,7 +352,7 @@ module Fog
|
|
350
352
|
# operation compute-- default URL
|
351
353
|
def defaultAliyunUri(action, sigNonce, time)
|
352
354
|
parTimeFormat = time.strftime('%Y-%m-%dT%H:%M:%SZ')
|
353
|
-
urlTimeFormat = URI.
|
355
|
+
urlTimeFormat = Addressable::URI.encode_component(parTimeFormat, Addressable::URI::CharacterClasses::UNRESERVED + '|')
|
354
356
|
'?Format=JSON&AccessKeyId=' + @aliyun_accesskey_id + '&Action=' + action + '&SignatureMethod=HMAC-SHA1&RegionId=' + @aliyun_region_id + '&SignatureNonce=' + sigNonce + '&SignatureVersion=1.0&Version=2014-05-26&Timestamp=' + urlTimeFormat
|
355
357
|
end
|
356
358
|
|
@@ -370,7 +372,7 @@ module Fog
|
|
370
372
|
|
371
373
|
def defaultAliyunVPCUri(action, sigNonce, time)
|
372
374
|
parTimeFormat = time.strftime('%Y-%m-%dT%H:%M:%SZ')
|
373
|
-
urlTimeFormat = URI.
|
375
|
+
urlTimeFormat = Addressable::URI.encode_component(parTimeFormat, Addressable::URI::CharacterClasses::UNRESERVED + '|')
|
374
376
|
'?Format=JSON&AccessKeyId=' + @aliyun_accesskey_id + '&Action=' + action + '&SignatureMethod=HMAC-SHA1&RegionId=' + @aliyun_region_id + '&SignatureNonce=' + sigNonce + '&SignatureVersion=1.0&Version=2016-04-28&Timestamp=' + urlTimeFormat
|
375
377
|
end
|
376
378
|
|
@@ -420,18 +422,18 @@ module Fog
|
|
420
422
|
# building querystrings with string concatination.
|
421
423
|
def sign(accessKeySecret, parameters)
|
422
424
|
signature = sign_without_encoding(accessKeySecret, parameters)
|
423
|
-
URI.
|
425
|
+
Addressable::URI.encode_component(signature, Addressable::URI::CharacterClasses::UNRESERVED + '|')
|
424
426
|
end
|
425
427
|
|
426
428
|
def sign_without_encoding(accessKeySecret, parameters)
|
427
429
|
sortedParameters = parameters.sort
|
428
430
|
canonicalizedQueryString = ''
|
429
431
|
sortedParameters.each do |k, v|
|
430
|
-
canonicalizedQueryString += '&' + URI.
|
432
|
+
canonicalizedQueryString += '&' + Addressable::URI.encode_component(k, Addressable::URI::CharacterClasses::UNRESERVED + '|') + '=' + Addressable::URI.encode_component(v, Addressable::URI::CharacterClasses::UNRESERVED + '|')
|
431
433
|
end
|
432
434
|
|
433
435
|
canonicalizedQueryString[0] = ''
|
434
|
-
stringToSign = 'GET&%2F&' + URI.
|
436
|
+
stringToSign = 'GET&%2F&' + Addressable::URI.encode_component(canonicalizedQueryString, Addressable::URI::CharacterClasses::UNRESERVED + '|')
|
435
437
|
key = accessKeySecret + '&'
|
436
438
|
|
437
439
|
digVer = OpenSSL::Digest.new('sha1')
|
@@ -10,70 +10,47 @@ module Fog
|
|
10
10
|
model Fog::Aliyun::Storage::Directory
|
11
11
|
|
12
12
|
def all
|
13
|
-
|
14
|
-
return nil if
|
13
|
+
buckets = service.get_service[0]
|
14
|
+
return nil if buckets.size < 1
|
15
15
|
data = []
|
16
16
|
i = 0
|
17
|
-
|
18
|
-
|
19
|
-
key[-1] = ''
|
20
|
-
data[i] = { key: key }
|
17
|
+
buckets.each do |b|
|
18
|
+
data[i] = { key: b.name }
|
21
19
|
i += 1
|
22
20
|
end
|
23
|
-
|
24
21
|
load(data)
|
25
22
|
end
|
26
23
|
|
27
|
-
|
28
|
-
# If the directory is not exist, this method will create a new with 'key'
|
29
|
-
# In order to support multi-buckets scenario which making bucket as a solo directory, it have been expanded.
|
30
|
-
# If key is a directory(including /), return an existed or a new one;
|
31
|
-
# If key does not contain /, if bucket, return '', else return an existed or a new one directory;
|
24
|
+
|
32
25
|
def get(key, options = {})
|
33
|
-
|
34
|
-
|
26
|
+
data = service.get_bucket(key, options)
|
27
|
+
|
28
|
+
directory = new(:key => key, :is_persisted => true)
|
29
|
+
|
30
|
+
options = data[1]
|
31
|
+
options[:max_keys] = options[:limit]
|
32
|
+
directory.files.merge_attributes(options)
|
33
|
+
|
34
|
+
objects = []
|
35
|
+
i = 0
|
36
|
+
data[0].each do |o|
|
37
|
+
objects[i] = {
|
38
|
+
'Key' => o.key,
|
39
|
+
'Type' => o.type,
|
40
|
+
'Size' => o.size,
|
41
|
+
'ETag' => o.etag,
|
42
|
+
'LastModified' => o.last_modified
|
43
|
+
}
|
44
|
+
i += 1
|
35
45
|
end
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
new(key: key) if ret.data[:status] == 200
|
42
|
-
else
|
43
|
-
remap_attributes(options, {
|
44
|
-
:delimiter => 'delimiter',
|
45
|
-
:marker => 'marker',
|
46
|
-
:max_keys => 'max-keys',
|
47
|
-
:prefix => 'prefix'
|
48
|
-
})
|
49
|
-
data = service.get_bucket(key, options)
|
50
|
-
directory = new(:key => data['Name'], :is_persisted => true)
|
51
|
-
options = {}
|
52
|
-
for k, v in data
|
53
|
-
if ['CommonPrefixes', 'Delimiter', 'IsTruncated', 'Marker', 'MaxKeys', 'Prefix'].include?(k)
|
54
|
-
# Sometimes, the v will be a Array, like "Name"=>["blobstore-droplet1"], "Prefix"=>[{}], "Marker"=>[{}], "MaxKeys"=>["100"], "Delimiter"=>[{}], "IsTruncated"=>["false"]
|
55
|
-
# and there needs to parse them
|
56
|
-
if !v.nil? && (v.is_a? Array) && (v.size > 0)
|
57
|
-
if v[0].is_a? Hash
|
58
|
-
v = nil
|
59
|
-
else
|
60
|
-
v = v[0]
|
61
|
-
end
|
62
|
-
end
|
63
|
-
options[k] = v
|
64
|
-
end
|
65
|
-
end
|
66
|
-
directory.files.merge_attributes(options)
|
67
|
-
if data.key?('Contents') && !data['Contents'].nil?
|
68
|
-
directory.files.load(data['Contents'])
|
69
|
-
end
|
70
|
-
directory
|
71
|
-
end
|
46
|
+
directory.files.load(objects)
|
47
|
+
directory
|
48
|
+
rescue AliyunOssSdk::ServerError => error
|
49
|
+
if error.error_code == "NoSuchBucket"
|
50
|
+
nil
|
72
51
|
else
|
73
|
-
|
52
|
+
raise(error)
|
74
53
|
end
|
75
|
-
rescue Fog::Aliyun::Storage::NotFound
|
76
|
-
nil
|
77
54
|
end
|
78
55
|
end
|
79
56
|
end
|
@@ -7,24 +7,62 @@ module Fog
|
|
7
7
|
module Aliyun
|
8
8
|
class Storage
|
9
9
|
class Directory < Fog::Model
|
10
|
+
VALID_ACLS = ['private', 'public-read', 'public-read-write']
|
11
|
+
|
12
|
+
attr_reader :acl
|
10
13
|
identity :key, :aliases => ['Key', 'Name', 'name']
|
11
14
|
|
15
|
+
attribute :creation_date, :aliases => 'CreationDate', :type => 'time'
|
16
|
+
|
17
|
+
def acl=(new_acl)
|
18
|
+
unless VALID_ACLS.include?(new_acl)
|
19
|
+
raise ArgumentError.new("acl must be one of [#{VALID_ACLS.join(', ')}]")
|
20
|
+
else
|
21
|
+
@acl = new_acl
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
12
25
|
def destroy
|
13
26
|
requires :key
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
if
|
27
|
+
service.delete_bucket(key)
|
28
|
+
true
|
29
|
+
rescue AliyunOssSdk::ServerError => error
|
30
|
+
if error.error_code == "NoSuchBucket"
|
18
31
|
false
|
19
|
-
elsif ret.size == 1
|
20
|
-
service.delete_container(key)
|
21
|
-
true
|
22
32
|
else
|
23
|
-
raise
|
33
|
+
raise(error)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def destroy!(options = {})
|
38
|
+
requires :key
|
39
|
+
options = {
|
40
|
+
timeout: Fog.timeout,
|
41
|
+
interval: Fog.interval,
|
42
|
+
}.merge(options)
|
43
|
+
|
44
|
+
begin
|
45
|
+
clear!
|
46
|
+
Fog.wait_for(options[:timeout], options[:interval]) { objects_keys.size == 0 }
|
47
|
+
service.delete_bucket(key)
|
48
|
+
true
|
49
|
+
rescue AliyunOssSdk::ServerError
|
24
50
|
false
|
25
51
|
end
|
26
52
|
end
|
27
53
|
|
54
|
+
def location
|
55
|
+
region = @aliyun_region_id
|
56
|
+
region ||= Storage::DEFAULT_REGION
|
57
|
+
@location = (bucket_location || 'oss-' + region)
|
58
|
+
end
|
59
|
+
|
60
|
+
# NOTE: you can't change the region once the bucket is created
|
61
|
+
def location=(new_location)
|
62
|
+
new_location = 'oss-' + new_location unless new_location.start_with?('oss-')
|
63
|
+
@location = new_location
|
64
|
+
end
|
65
|
+
|
28
66
|
def files
|
29
67
|
@files ||= begin
|
30
68
|
Fog::Aliyun::Storage::Files.new(
|
@@ -34,6 +72,12 @@ module Fog
|
|
34
72
|
end
|
35
73
|
end
|
36
74
|
|
75
|
+
# TODO
|
76
|
+
def public=(new_public)
|
77
|
+
nil
|
78
|
+
end
|
79
|
+
|
80
|
+
# TODO
|
37
81
|
def public_url
|
38
82
|
nil
|
39
83
|
end
|
@@ -41,18 +85,53 @@ module Fog
|
|
41
85
|
def save
|
42
86
|
requires :key
|
43
87
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
88
|
+
options = {}
|
89
|
+
|
90
|
+
options['x-oss-acl'] = acl if acl
|
91
|
+
|
92
|
+
# https://help.aliyun.com/document_detail/31959.html
|
93
|
+
# if !persisted?
|
94
|
+
# # There is a sdk bug that location can not be set
|
95
|
+
# options[:location] = location
|
96
|
+
# end
|
97
|
+
|
98
|
+
service.put_bucket(key, options)
|
99
|
+
attributes[:is_persisted] = true
|
53
100
|
|
54
101
|
true
|
55
102
|
end
|
103
|
+
|
104
|
+
def persisted?
|
105
|
+
# is_persisted is true in case of directories.get or after #save
|
106
|
+
# creation_date is set in case of directories.all
|
107
|
+
attributes[:is_persisted] || !!attributes[:creation_date]
|
108
|
+
end
|
109
|
+
|
110
|
+
private
|
111
|
+
|
112
|
+
def bucket_location
|
113
|
+
requires :key
|
114
|
+
return nil unless persisted?
|
115
|
+
service.get_bucket_location(key)
|
116
|
+
end
|
117
|
+
|
118
|
+
def objects_keys
|
119
|
+
requires :key
|
120
|
+
bucket_query = service.get_bucket(key)
|
121
|
+
|
122
|
+
object_keys = []
|
123
|
+
i = 0
|
124
|
+
bucket_query[0].each do |o|
|
125
|
+
object_keys[i] = o.key
|
126
|
+
i += 1
|
127
|
+
end
|
128
|
+
object_keys
|
129
|
+
end
|
130
|
+
|
131
|
+
def clear!
|
132
|
+
requires :key
|
133
|
+
service.delete_multiple_objects(key, objects_keys) if objects_keys.size > 0
|
134
|
+
end
|
56
135
|
end
|
57
136
|
end
|
58
137
|
end
|