gitlab-fog-azure-rm 1.7.0 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +12 -0
- data/.rubocop_todo.yml +1 -1
- data/CHANGELOG.md +4 -0
- data/gitlab-fog-azure-rm.gemspec +3 -3
- data/lib/fog/azurerm/constants.rb +0 -6
- data/lib/fog/azurerm/custom_fog_errors.rb +0 -41
- data/lib/fog/azurerm/docs/storage.md +1 -1
- data/lib/fog/azurerm/identity_encoding_filter.rb +12 -0
- data/lib/fog/azurerm/models/storage/directories.rb +6 -6
- data/lib/fog/azurerm/models/storage/directory.rb +4 -4
- data/lib/fog/azurerm/models/storage/file.rb +6 -3
- data/lib/fog/azurerm/models/storage/files.rb +8 -8
- data/lib/fog/azurerm/models/storage/storage_account.rb +4 -4
- data/lib/fog/azurerm/models/storage/storage_accounts.rb +6 -6
- data/lib/fog/azurerm/requests/storage/acquire_blob_lease.rb +2 -2
- data/lib/fog/azurerm/requests/storage/acquire_container_lease.rb +2 -2
- data/lib/fog/azurerm/requests/storage/check_container_exists.rb +2 -2
- data/lib/fog/azurerm/requests/storage/commit_blob_blocks.rb +2 -2
- data/lib/fog/azurerm/requests/storage/compare_container_blobs.rb +2 -2
- data/lib/fog/azurerm/requests/storage/copy_blob.rb +2 -2
- data/lib/fog/azurerm/requests/storage/copy_blob_from_uri.rb +2 -2
- data/lib/fog/azurerm/requests/storage/copy_object.rb +2 -2
- data/lib/fog/azurerm/requests/storage/create_block_blob.rb +2 -2
- data/lib/fog/azurerm/requests/storage/create_container.rb +2 -2
- data/lib/fog/azurerm/requests/storage/create_page_blob.rb +2 -2
- data/lib/fog/azurerm/requests/storage/delete_blob.rb +2 -2
- data/lib/fog/azurerm/requests/storage/delete_blob_https_url.rb +4 -4
- data/lib/fog/azurerm/requests/storage/delete_container.rb +2 -2
- data/lib/fog/azurerm/requests/storage/delete_object.rb +2 -2
- data/lib/fog/azurerm/requests/storage/delete_object_url.rb +2 -2
- data/lib/fog/azurerm/requests/storage/get_blob.rb +2 -2
- data/lib/fog/azurerm/requests/storage/get_blob_http_url.rb +5 -5
- data/lib/fog/azurerm/requests/storage/get_blob_https_url.rb +6 -5
- data/lib/fog/azurerm/requests/storage/get_blob_properties.rb +2 -2
- data/lib/fog/azurerm/requests/storage/get_blob_url.rb +4 -4
- data/lib/fog/azurerm/requests/storage/get_container_acl.rb +2 -2
- data/lib/fog/azurerm/requests/storage/get_container_properties.rb +2 -2
- data/lib/fog/azurerm/requests/storage/get_container_url.rb +4 -4
- data/lib/fog/azurerm/requests/storage/get_object.rb +2 -2
- data/lib/fog/azurerm/requests/storage/get_object_url.rb +2 -2
- data/lib/fog/azurerm/requests/storage/list_blobs.rb +2 -2
- data/lib/fog/azurerm/requests/storage/list_containers.rb +2 -2
- data/lib/fog/azurerm/requests/storage/put_blob_block.rb +2 -2
- data/lib/fog/azurerm/requests/storage/put_blob_http_url.rb +39 -0
- data/lib/fog/azurerm/requests/storage/put_blob_https_url.rb +4 -4
- data/lib/fog/azurerm/requests/storage/put_blob_metadata.rb +2 -2
- data/lib/fog/azurerm/requests/storage/put_blob_pages.rb +2 -2
- data/lib/fog/azurerm/requests/storage/put_blob_properties.rb +2 -2
- data/lib/fog/azurerm/requests/storage/put_container_acl.rb +2 -2
- data/lib/fog/azurerm/requests/storage/put_container_metadata.rb +2 -2
- data/lib/fog/azurerm/requests/storage/put_object_url.rb +2 -2
- data/lib/fog/azurerm/requests/storage/release_blob_lease.rb +2 -2
- data/lib/fog/azurerm/requests/storage/release_container_lease.rb +2 -2
- data/lib/fog/azurerm/requests/storage/save_page_blob.rb +2 -2
- data/lib/fog/azurerm/requests/storage/wait_blob_copy_operation_to_finish.rb +2 -2
- data/lib/fog/azurerm/storage.rb +62 -27
- data/lib/fog/azurerm/utilities/general.rb +2 -58
- data/lib/fog/azurerm/version.rb +1 -1
- data/lib/fog/azurerm.rb +4 -11
- data/rakefile +4 -5
- data/test/api_stub/models/storage/directory.rb +1 -1
- data/test/api_stub/models/storage/file.rb +1 -1
- data/test/api_stub/requests/storage/directory.rb +1 -1
- data/test/api_stub/requests/storage/file.rb +4 -4
- data/test/integration/README.md +5 -7
- data/test/integration/blob.rb +28 -36
- data/test/integration/container.rb +8 -39
- data/test/integration/credentials/azure.yml +4 -5
- data/test/models/storage/test_directories.rb +5 -5
- data/test/models/storage/test_directory.rb +2 -2
- data/test/models/storage/test_file.rb +16 -4
- data/test/models/storage/test_files.rb +8 -8
- data/test/requests/storage/test_acquire_blob_lease.rb +2 -2
- data/test/requests/storage/test_acquire_container_lease.rb +2 -2
- data/test/requests/storage/test_check_container_exists.rb +1 -1
- data/test/requests/storage/test_commit_blob_blocks.rb +2 -2
- data/test/requests/storage/test_compare_container_blobs.rb +2 -2
- data/test/requests/storage/test_copy_blob.rb +2 -2
- data/test/requests/storage/test_copy_blob_from_uri.rb +2 -2
- data/test/requests/storage/test_create_block_blob.rb +2 -2
- data/test/requests/storage/test_create_container.rb +2 -2
- data/test/requests/storage/test_create_page_blob.rb +2 -2
- data/test/requests/storage/test_delete_blob.rb +2 -2
- data/test/requests/storage/test_delete_blob_https_url.rb +7 -10
- data/test/requests/storage/test_delete_container.rb +2 -2
- data/test/requests/storage/test_delete_object.rb +2 -2
- data/test/requests/storage/test_get_blob.rb +2 -2
- data/test/requests/storage/test_get_blob_encoding.rb +45 -0
- data/test/requests/storage/test_get_blob_http_url.rb +13 -9
- data/test/requests/storage/test_get_blob_https_url.rb +95 -13
- data/test/requests/storage/test_get_blob_properties.rb +2 -2
- data/test/requests/storage/test_get_blob_url.rb +15 -24
- data/test/requests/storage/test_get_container_acl.rb +2 -2
- data/test/requests/storage/test_get_container_properties.rb +2 -2
- data/test/requests/storage/test_get_container_url.rb +5 -8
- data/test/requests/storage/test_get_object.rb +2 -2
- data/test/requests/storage/test_list_blobs.rb +2 -2
- data/test/requests/storage/test_list_containers.rb +2 -2
- data/test/requests/storage/test_put_blob_block.rb +2 -2
- data/test/requests/storage/test_put_blob_http_url.rb +33 -0
- data/test/requests/storage/test_put_blob_https_url.rb +8 -11
- data/test/requests/storage/test_put_blob_metadata.rb +2 -2
- data/test/requests/storage/test_put_blob_pages.rb +2 -2
- data/test/requests/storage/test_put_blob_properties.rb +2 -2
- data/test/requests/storage/test_put_container_acl.rb +2 -2
- data/test/requests/storage/test_put_container_metadata.rb +2 -2
- data/test/requests/storage/test_release_blob_lease.rb +2 -2
- data/test/requests/storage/test_release_container_lease.rb +2 -2
- data/test/requests/storage/test_save_page_blob.rb +2 -2
- data/test/requests/storage/test_wait_blob_copy_operation_to_finish.rb +15 -6
- data/test/test_helper.rb +38 -698
- metadata +27 -36
- data/lib/fog/azurerm/credentials.rb +0 -44
- data/lib/fog/azurerm/models/resources/azure_resource.rb +0 -25
- data/lib/fog/azurerm/models/resources/azure_resources.rb +0 -40
- data/lib/fog/azurerm/models/resources/dependency.rb +0 -27
- data/lib/fog/azurerm/models/resources/deployment.rb +0 -65
- data/lib/fog/azurerm/models/resources/deployments.rb +0 -30
- data/lib/fog/azurerm/models/resources/provider.rb +0 -27
- data/lib/fog/azurerm/models/resources/provider_resource_type.rb +0 -22
- data/lib/fog/azurerm/models/resources/resource_group.rb +0 -34
- data/lib/fog/azurerm/models/resources/resource_groups.rb +0 -29
- data/test/integration/storage_account.rb +0 -135
- data/test/smoke_tests/compute/test_resource_group_smoke.rb +0 -37
- data/test/test_credentials.rb +0 -63
@@ -1,6 +1,6 @@
|
|
1
1
|
module Fog
|
2
|
-
module
|
3
|
-
class
|
2
|
+
module AzureRM
|
3
|
+
class Storage
|
4
4
|
# This class provides the actual implemention for service calls.
|
5
5
|
class Real
|
6
6
|
# Get a public blob url from Azure blob storage
|
@@ -18,8 +18,8 @@ module Fog
|
|
18
18
|
# This class provides the mock implementation for unit tests.
|
19
19
|
class Mock
|
20
20
|
def get_blob_url(_container_name, _blob_name, options = {})
|
21
|
-
url = 'https://
|
22
|
-
url.
|
21
|
+
url = 'https://mockaccount.blob.core.windows.net/test_container/test_blob'
|
22
|
+
url.sub!('https:', 'http:') if options[:scheme] == 'http'
|
23
23
|
url
|
24
24
|
end
|
25
25
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Fog
|
2
|
-
module
|
3
|
-
class
|
2
|
+
module AzureRM
|
3
|
+
class Storage
|
4
4
|
# This class provides the actual implemention for service calls.
|
5
5
|
class Real
|
6
6
|
# Get a public container url from Azure storage container
|
@@ -24,8 +24,8 @@ module Fog
|
|
24
24
|
# This class provides the mock implementation for unit tests.
|
25
25
|
class Mock
|
26
26
|
def get_container_url(_container_name, options = {})
|
27
|
-
url = 'https://
|
28
|
-
url.
|
27
|
+
url = 'https://mockaccount.blob.core.windows.net/test_container?comp=list&restype=container'
|
28
|
+
url.sub!('https:', 'http:') if options[:scheme] == 'http'
|
29
29
|
url
|
30
30
|
end
|
31
31
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Fog
|
2
|
+
module AzureRM
|
3
|
+
class Storage
|
4
|
+
# This class provides the actual implemention for service calls.
|
5
|
+
class Real
|
6
|
+
# Generate a pre-signed URL for create an object in an Azure blob storage
|
7
|
+
#
|
8
|
+
# @param container_name [String] Name of container containing blob
|
9
|
+
# @param blob_name [String] Name of blob to get expiring url for
|
10
|
+
# @param expires [Time] An expiry time for this url
|
11
|
+
#
|
12
|
+
# @return [String] - https url for blob
|
13
|
+
#
|
14
|
+
# @see https://docs.microsoft.com/en-us/rest/api/storageservices/put-blob
|
15
|
+
#
|
16
|
+
def put_blob_http_url(container_name, blob_name, expires)
|
17
|
+
relative_path = "#{container_name}/#{blob_name}"
|
18
|
+
params = {
|
19
|
+
service: 'b',
|
20
|
+
resource: 'b',
|
21
|
+
permissions: 'c',
|
22
|
+
expiry: expires.utc.iso8601
|
23
|
+
}
|
24
|
+
token = signature_client(expires).generate_service_sas_token(relative_path, params)
|
25
|
+
uri = @blob_client.generate_uri(relative_path, {}, { encode: true })
|
26
|
+
url = "#{uri}?#{token}"
|
27
|
+
url.sub('https:', 'http:')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# This class provides the mock implementation for unit tests.
|
32
|
+
class Mock
|
33
|
+
def put_blob_http_url(*)
|
34
|
+
'http://mockaccount.blob.core.windows.net/test_container/test_blob?token'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Fog
|
2
|
-
module
|
3
|
-
class
|
2
|
+
module AzureRM
|
3
|
+
class Storage
|
4
4
|
# This class provides the actual implemention for service calls.
|
5
5
|
class Real
|
6
6
|
# Generate a pre-signed URL for create an object in an Azure blob storage
|
@@ -22,7 +22,7 @@ module Fog
|
|
22
22
|
expiry: expires.utc.iso8601,
|
23
23
|
protocol: 'https'
|
24
24
|
}
|
25
|
-
token =
|
25
|
+
token = signature_client(expires).generate_service_sas_token(relative_path, params)
|
26
26
|
uri = @blob_client.generate_uri(relative_path, {}, { encode: true })
|
27
27
|
"#{uri}?#{token}"
|
28
28
|
end
|
@@ -31,7 +31,7 @@ module Fog
|
|
31
31
|
# This class provides the mock implementation for unit tests.
|
32
32
|
class Mock
|
33
33
|
def put_blob_https_url(*)
|
34
|
-
'https://
|
34
|
+
'https://mockaccount.blob.core.windows.net/test_container/test_blob?token'
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
data/lib/fog/azurerm/storage.rb
CHANGED
@@ -1,18 +1,14 @@
|
|
1
1
|
module Fog
|
2
|
-
module
|
2
|
+
module AzureRM
|
3
3
|
# This class registers models, requests and collections
|
4
|
-
class
|
5
|
-
# Recognizes when creating management client
|
6
|
-
recognizes :tenant_id
|
7
|
-
recognizes :client_id
|
8
|
-
recognizes :client_secret
|
9
|
-
recognizes :subscription_id
|
10
|
-
recognizes :environment
|
11
|
-
|
4
|
+
class Storage < Fog::Service
|
12
5
|
# Recognizes when creating data client
|
13
6
|
recognizes :azure_storage_account_name
|
14
7
|
recognizes :azure_storage_access_key
|
8
|
+
recognizes :azure_storage_token_signer
|
9
|
+
recognizes :azure_storage_endpoint
|
15
10
|
recognizes :azure_storage_domain
|
11
|
+
recognizes :environment
|
16
12
|
|
17
13
|
recognizes :debug
|
18
14
|
|
@@ -48,6 +44,7 @@ module Fog
|
|
48
44
|
request :get_blob_https_url
|
49
45
|
request :create_block_blob
|
50
46
|
request :put_blob_block
|
47
|
+
request :put_blob_http_url
|
51
48
|
request :put_blob_https_url
|
52
49
|
request :put_object_url
|
53
50
|
request :delete_blob
|
@@ -90,44 +87,82 @@ module Fog
|
|
90
87
|
require 'securerandom'
|
91
88
|
@debug = ENV['DEBUG'] || options[:debug]
|
92
89
|
require 'azure/core/http/debug_filter' if @debug
|
90
|
+
require 'fog/azurerm/identity_encoding_filter'
|
93
91
|
rescue LoadError => e
|
94
92
|
retry if require('rubygems')
|
95
93
|
raise e.message
|
96
94
|
end
|
97
95
|
|
98
|
-
options[:environment] = 'AzureCloud' if options[:environment].nil?
|
99
|
-
|
100
|
-
@tenant_id = options[:tenant_id]
|
101
|
-
@client_id = options[:client_id]
|
102
|
-
@client_secret = options[:client_secret]
|
103
|
-
@subscription_id = options[:subscription_id]
|
104
|
-
@environment = options[:environment]
|
105
|
-
|
106
|
-
credentials = Fog::Credentials::AzureRM.get_credentials(@tenant_id, @client_id, @client_secret, @environment)
|
107
|
-
telemetry = "gitlab-fog-azure-rm/#{Fog::AzureRM::VERSION}"
|
108
|
-
|
109
96
|
return unless @azure_storage_account_name != options[:azure_storage_account_name] ||
|
110
|
-
@azure_storage_access_key != options[:azure_storage_access_key]
|
97
|
+
@azure_storage_access_key != options[:azure_storage_access_key] ||
|
98
|
+
@azure_storage_token_signer != options[:azure_storage_token_signer]
|
111
99
|
|
112
100
|
@azure_storage_account_name = options[:azure_storage_account_name]
|
113
101
|
@azure_storage_access_key = options[:azure_storage_access_key]
|
102
|
+
@azure_storage_token_signer = options[:azure_storage_token_signer]
|
103
|
+
@azure_storage_endpoint = options[:azure_storage_endpoint]
|
114
104
|
@azure_storage_domain = options[:azure_storage_domain]
|
115
105
|
|
116
|
-
|
106
|
+
options[:environment] = 'AzureCloud' if options[:environment].nil?
|
107
|
+
@environment = options[:environment]
|
108
|
+
|
109
|
+
storage_blob_host =
|
110
|
+
@azure_storage_endpoint ||
|
117
111
|
if @azure_storage_domain.nil? || @azure_storage_domain.empty?
|
118
112
|
get_blob_endpoint(@azure_storage_account_name, true, @environment)
|
119
113
|
else
|
120
114
|
get_blob_endpoint_with_domain(@azure_storage_account_name, true, @azure_storage_domain)
|
121
115
|
end
|
122
116
|
|
123
|
-
azure_client = Azure::Storage::Common::Client.create(
|
124
|
-
|
125
|
-
|
117
|
+
azure_client = Azure::Storage::Common::Client.create({
|
118
|
+
storage_account_name: @azure_storage_account_name,
|
119
|
+
storage_access_key: @azure_storage_access_key,
|
120
|
+
signer: @azure_storage_token_signer
|
121
|
+
}.compact)
|
122
|
+
azure_client.storage_blob_host = storage_blob_host
|
126
123
|
@blob_client = Azure::Storage::Blob::BlobService.new(client: azure_client)
|
124
|
+
@blob_client.with_filter(Fog::AzureRM::IdentityEncodingFilter.new)
|
127
125
|
@blob_client.with_filter(Azure::Storage::Common::Core::Filter::ExponentialRetryPolicyFilter.new)
|
128
126
|
@blob_client.with_filter(Azure::Core::Http::DebugFilter.new) if @debug
|
129
|
-
|
130
|
-
|
127
|
+
end
|
128
|
+
|
129
|
+
private
|
130
|
+
|
131
|
+
def signature_client(requested_expiry)
|
132
|
+
access_key = @azure_storage_access_key.to_s
|
133
|
+
user_delegation_key = user_delegation_key(requested_expiry)
|
134
|
+
|
135
|
+
# invalidate cache when the delegation key changes
|
136
|
+
unless @signature_client_delegation_key == user_delegation_key
|
137
|
+
@signature_client_delegation_key = user_delegation_key
|
138
|
+
@signature_client = nil
|
139
|
+
end
|
140
|
+
|
141
|
+
@signature_client ||= Azure::Storage::Common::Core::Auth::SharedAccessSignature.new(
|
142
|
+
@azure_storage_account_name,
|
143
|
+
access_key,
|
144
|
+
user_delegation_key
|
145
|
+
)
|
146
|
+
end
|
147
|
+
|
148
|
+
def user_delegation_key(requested_expiry)
|
149
|
+
return nil unless @azure_storage_token_signer
|
150
|
+
|
151
|
+
@user_delegation_key_mutex ||= Mutex.new
|
152
|
+
@user_delegation_key_mutex.synchronize do
|
153
|
+
if @user_delegation_key_expiry.nil? || @user_delegation_key_expiry < requested_expiry
|
154
|
+
start = Time.now
|
155
|
+
expiry = start + Azure::Storage::Blob::BlobConstants::MAX_USER_DELEGATION_KEY_SECONDS
|
156
|
+
|
157
|
+
@user_delegation_key = @blob_client.get_user_delegation_key(
|
158
|
+
start,
|
159
|
+
expiry
|
160
|
+
)
|
161
|
+
@user_delegation_key_expiry = expiry
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
@user_delegation_key
|
131
166
|
end
|
132
167
|
end
|
133
168
|
end
|
@@ -53,13 +53,9 @@ module Fog
|
|
53
53
|
type.split('/').last
|
54
54
|
end
|
55
55
|
|
56
|
-
def raise_azure_exception(exception,
|
56
|
+
def raise_azure_exception(exception, _msg)
|
57
57
|
raise Fog::AzureRM::CustomAzureCoreHttpError.new(exception) if exception.is_a?(Azure::Core::Http::HTTPError)
|
58
|
-
raise exception
|
59
|
-
|
60
|
-
azure_operation_error = Fog::AzureRM::CustomAzureOperationError.new(msg, exception)
|
61
|
-
azure_operation_error.print_subscription_limits_information if !azure_operation_error.request.nil? && !azure_operation_error.response.nil?
|
62
|
-
raise azure_operation_error
|
58
|
+
raise exception
|
63
59
|
end
|
64
60
|
|
65
61
|
# Make sure if input_params(Hash) contains all keys present in required_params(Array)
|
@@ -80,47 +76,15 @@ module Fog
|
|
80
76
|
(0...length).map { ('a'..'z').to_a[rand(26)] }.join
|
81
77
|
end
|
82
78
|
|
83
|
-
def active_directory_service_settings(environment = ENVIRONMENT_AZURE_CLOUD)
|
84
|
-
case environment
|
85
|
-
when ENVIRONMENT_AZURE_CHINA_CLOUD
|
86
|
-
MsRestAzure::ActiveDirectoryServiceSettings.get_azure_china_settings
|
87
|
-
when ENVIRONMENT_AZURE_US_GOVERNMENT
|
88
|
-
MsRestAzure::ActiveDirectoryServiceSettings.get_azure_us_government_settings
|
89
|
-
when ENVIRONMENT_AZURE_GERMAN_CLOUD
|
90
|
-
MsRestAzure::ActiveDirectoryServiceSettings.get_azure_german_settings
|
91
|
-
else
|
92
|
-
MsRestAzure::ActiveDirectoryServiceSettings.get_azure_settings
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def resource_manager_endpoint_url(environment = ENVIRONMENT_AZURE_CLOUD)
|
97
|
-
case environment
|
98
|
-
when ENVIRONMENT_AZURE_CHINA_CLOUD
|
99
|
-
MsRestAzure::AzureEnvironments::ChinaCloud.resource_manager_endpoint_url
|
100
|
-
when ENVIRONMENT_AZURE_US_GOVERNMENT
|
101
|
-
MsRestAzure::AzureEnvironments::USGovernment.resource_manager_endpoint_url
|
102
|
-
when ENVIRONMENT_AZURE_GERMAN_CLOUD
|
103
|
-
MsRestAzure::AzureEnvironments::GermanCloud.resource_manager_endpoint_url
|
104
|
-
else
|
105
|
-
MsRestAzure::AzureEnvironments::AzureCloud.resource_manager_endpoint_url
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
# storage_endpoint_suffix is nil in ms_rest_azure 0.6.2
|
110
|
-
# Reference the issue: https://github.com/Azure/azure-sdk-for-ruby/issues/603
|
111
79
|
def storage_endpoint_suffix(environment = ENVIRONMENT_AZURE_CLOUD)
|
112
80
|
case environment
|
113
81
|
when ENVIRONMENT_AZURE_CHINA_CLOUD
|
114
|
-
# MsRestAzure::AzureEnvironments::AzureChina.storage_endpoint_suffix
|
115
82
|
'.core.chinacloudapi.cn'
|
116
83
|
when ENVIRONMENT_AZURE_US_GOVERNMENT
|
117
|
-
# MsRestAzure::AzureEnvironments::AzureUSGovernment.storage_endpoint_suffix
|
118
84
|
'.core.usgovcloudapi.net'
|
119
85
|
when ENVIRONMENT_AZURE_GERMAN_CLOUD
|
120
|
-
# MsRestAzure::AzureEnvironments::AzureGermanCloud.storage_endpoint_suffix
|
121
86
|
'.core.cloudapi.de'
|
122
87
|
else
|
123
|
-
# MsRestAzure::AzureEnvironments::Azure.storage_endpoint_suffix
|
124
88
|
'.core.windows.net'
|
125
89
|
end
|
126
90
|
end
|
@@ -135,11 +99,6 @@ module Fog
|
|
135
99
|
"#{protocol}://#{storage_account_name}.#{domain}"
|
136
100
|
end
|
137
101
|
|
138
|
-
def current_time
|
139
|
-
time = Time.now.to_f.to_s
|
140
|
-
time.split(/\W+/).join
|
141
|
-
end
|
142
|
-
|
143
102
|
# Parse storage blob/container to a hash
|
144
103
|
def parse_storage_object(object)
|
145
104
|
data = {}
|
@@ -172,21 +131,6 @@ module Fog
|
|
172
131
|
data
|
173
132
|
end
|
174
133
|
|
175
|
-
def resource_not_found?(azure_operation_error)
|
176
|
-
is_found = false
|
177
|
-
if azure_operation_error.response.status == HTTP_NOT_FOUND
|
178
|
-
if azure_operation_error.body['code']
|
179
|
-
is_found = azure_operation_error.body['code'] == ERROR_CODE_NOT_FOUND
|
180
|
-
elsif azure_operation_error.body['error']
|
181
|
-
is_found = azure_operation_error.body['error']['code'] == ERROR_CODE_NOT_FOUND ||
|
182
|
-
azure_operation_error.body['error']['code'] == ERROR_CODE_RESOURCE_GROUP_NOT_FOUND ||
|
183
|
-
azure_operation_error.body['error']['code'] == ERROR_CODE_RESOURCE_NOT_FOUND ||
|
184
|
-
azure_operation_error.body['error']['code'] == ERROR_CODE_PARENT_RESOURCE_NOT_FOUND
|
185
|
-
end
|
186
|
-
end
|
187
|
-
is_found
|
188
|
-
end
|
189
|
-
|
190
134
|
def get_image_name(id)
|
191
135
|
id.split('/').last
|
192
136
|
end
|
data/lib/fog/azurerm/version.rb
CHANGED
data/lib/fog/azurerm.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'ms_rest_azure'
|
2
1
|
require 'azure/core/http/http_error'
|
3
2
|
require 'erb'
|
4
3
|
require 'fog/azurerm/config'
|
@@ -12,19 +11,13 @@ require 'fog/azurerm/models/storage/sku_tier'
|
|
12
11
|
require 'fog/azurerm/models/storage/kind'
|
13
12
|
|
14
13
|
module Fog
|
15
|
-
# Autoload Module for Credentials
|
16
|
-
module Credentials
|
17
|
-
autoload :AzureRM, File.expand_path('azurerm/credentials', __dir__)
|
18
|
-
end
|
19
|
-
|
20
|
-
# Autoload Module for Storage
|
21
|
-
module Storage
|
22
|
-
autoload :AzureRM, File.expand_path('azurerm/storage', __dir__)
|
23
|
-
end
|
24
|
-
|
25
14
|
# Main AzureRM fog Provider Module
|
26
15
|
module AzureRM
|
27
16
|
extend Fog::Provider
|
17
|
+
|
18
|
+
# Autoload Module for Storage
|
19
|
+
autoload :Storage, File.expand_path('azurerm/storage', __dir__)
|
20
|
+
|
28
21
|
service(:storage, 'Storage')
|
29
22
|
end
|
30
23
|
end
|
data/rakefile
CHANGED
@@ -10,6 +10,10 @@ task :test do
|
|
10
10
|
Dir.glob('test/requests/**/test_*.rb').each { |file| require File.expand_path file, __dir__ }
|
11
11
|
end
|
12
12
|
|
13
|
+
task :integration do
|
14
|
+
Dir.glob('test/integration/*.rb').each { |file| require File.expand_path file, __dir__ }
|
15
|
+
end
|
16
|
+
|
13
17
|
desc 'Generates a coverage report for minitest-cases using simple-cov'
|
14
18
|
task :coverage do
|
15
19
|
ENV['CODECLIMATE_REPO_TOKEN'] = nil
|
@@ -27,8 +31,3 @@ task :cc_coverage do
|
|
27
31
|
Dir.glob('test/models/**/test_*.rb').each { |file| require File.expand_path file, __dir__ }
|
28
32
|
Dir.glob('test/requests/**/test_*.rb').each { |file| require File.expand_path file, __dir__ }
|
29
33
|
end
|
30
|
-
|
31
|
-
desc 'Generates a coverage report for integration tests'
|
32
|
-
task :integration_tests do
|
33
|
-
Dir.glob('test/smoke_tests/**/test_*.rb').each { |file| require File.expand_path file, __dir__ }
|
34
|
-
end
|
@@ -22,7 +22,7 @@ module ApiStub
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.container_https_url
|
25
|
-
'https://
|
25
|
+
'https://mockaccount.blob.core.windows.net/test_container?comp=list&restype=container'
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.container_list
|
@@ -37,7 +37,7 @@ module ApiStub
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def self.container_https_url
|
40
|
-
'https://
|
40
|
+
'https://mockaccount.blob.core.windows.net/test_container?comp=list&restype=container'
|
41
41
|
end
|
42
42
|
|
43
43
|
def self.container_metadata
|
@@ -46,13 +46,13 @@ module ApiStub
|
|
46
46
|
def self.blob_https_url(environment = Fog::AzureRM::ENVIRONMENT_AZURE_CLOUD)
|
47
47
|
case environment
|
48
48
|
when Fog::AzureRM::ENVIRONMENT_AZURE_CHINA_CLOUD
|
49
|
-
'https://
|
49
|
+
'https://mockaccount.blob.core.chinacloudapi.cn/test_container/test_blob'
|
50
50
|
when Fog::AzureRM::ENVIRONMENT_AZURE_US_GOVERNMENT
|
51
|
-
'https://
|
51
|
+
'https://mockaccount.blob.core.usgovcloudapi.net/test_container/test_blob'
|
52
52
|
when Fog::AzureRM::ENVIRONMENT_AZURE_GERMAN_CLOUD
|
53
|
-
'https://
|
53
|
+
'https://mockaccount.blob.core.cloudapi.de/test_container/test_blob'
|
54
54
|
else
|
55
|
-
'https://
|
55
|
+
'https://mockaccount.blob.core.windows.net/test_container/test_blob'
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
data/test/integration/README.md
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
# Integration Tests
|
2
2
|
|
3
|
-
To run Integration Tests, first enter following information
|
3
|
+
To run Integration Tests, first enter the following information for your test storage account into **credentials\azure.yml** file:
|
4
4
|
|
5
|
-
-
|
6
|
-
-
|
7
|
-
- client_secret
|
8
|
-
- subscription_id
|
5
|
+
- `azure_storage_account_name`
|
6
|
+
- `azure_storage_access_key`
|
9
7
|
|
10
|
-
Then run **ruby file_name.rb** to run integration test for a specific service e.g. For integration tests
|
8
|
+
Then run **bundle exec ruby file_name.rb** to run integration test for a specific service e.g. For integration tests for blobs, run:
|
11
9
|
|
12
|
-
**ruby
|
10
|
+
**bundle exec ruby test/integration/blob.rb**
|
13
11
|
|
14
12
|
Also make sure the **DEBUG** flag is set in your fog environment to see proper logging.
|