changes for account_tempurl_key
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
diff --git a/config/dev.exs b/config/dev.exs
index f1d9cab..69a7f3d 100644
--- a/config/dev.exs
+++ b/config/dev.exs
@@ -29,7 +29,7 @@ config :ex_ovh,
cloudstorage: [
tenant_id: System.get_env("EX_OVH_CLOUDSTORAGE_TENANT_ID"), # mandatory, corresponds to a project id
user_id: System.get_env("EX_OVH_CLOUDSTORAGE_USER_ID"), # optional, if absent a user will be created using the ovh api.
- temp_url_key: System.get_env("EX_OVH_CLOUDSTORAGE_TEMP_URL_KEY"), # defaults to :nil if absent and won't be added if == :nil.
+ account_temp_url_key: System.get_env("EX_OVH_CLOUDSTORAGE_TEMP_URL_KEY"), # defaults to :nil if absent and won't be added if == :nil.
keystone_endpoint: "https://auth.cloud.ovh.net/v2.0", # default endpoint for keystone (identity) auth
region: :nil, # defaults to "SBG1" if set to :nil
type: :cloudstorage
diff --git a/lib/auth/openstack/swift/cache.ex b/lib/auth/openstack/swift/cache.ex
index 66cc9ca..e0b1ce6 100644
--- a/lib/auth/openstack/swift/cache.ex
+++ b/lib/auth/openstack/swift/cache.ex
@@ -30,13 +30,17 @@ defmodule ExOvh.Auth.Openstack.Swift.Cache do
|> Map.get(:public_url)
end
- # get_swift_endpoint/1-- use default implementation for `use Openstex.Cache`.
- # get_swift_account/1 -- use default implementation for `use Openstex.Cache`.
-
def get_xauth_token(swift_client) do
get_identity(swift_client) |> Map.get(:token) |> Map.get(:id)
end
+ def get_account_tempurl_key(swift_client) do
+ swift_client.config() |> Keyword.fetch!(:account_temp_url_key)
+ end
+
+ # get_swift_endpoint/1-- use default implementation for `use Openstex.Cache`.
+ # get_swift_account/1 -- use default implementation for `use Openstex.Cache`.
+
# Genserver Callbacks
@@ -109,9 +113,8 @@ defmodule ExOvh.Auth.Openstack.Swift.Cache do
defp try_to_set_temp_url_key(swift_client) do
- if Keyword.has_key?(swift_client.config(), :temp_url_key) do
- temp_key = Keyword.get(swift_client.config() |> Og.log_return(__ENV__), :temp_url_key, :nil)
- |> Og.log_return(__ENV__)
+ if Keyword.has_key?(swift_client.config(), :account_temp_url_key) do
+ temp_key = Keyword.get(swift_client.config(), :account_temp_url_key, :nil)
account = swift_client.account()
if temp_key != :nil do
resp = Openstex.Swift.V1.Query.account_info(account) |> swift_client.request!()