tidy up compilation errors
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381
diff --git a/docs/getting_started_advanced.md b/docs/getting_started_advanced.md
index edfbd1f..6063aac 100644
--- a/docs/getting_started_advanced.md
+++ b/docs/getting_started_advanced.md
@@ -75,6 +75,7 @@ config :ex_ovh,
cloudstorage: [
tenant_id: System.get_env("MY_APP_OVH_CLIENT_CLOUDSTORAGE_TENANT_ID"), # mandatory, corresponds to a project id
user_id: System.get_env("MY_APP_OVH_CLIENT_CLOUDSTORAGE_USER_ID"), # optional, if absent a user will be created using the ovh api.
+ account_temp_url_key: System.get_env("MY_APP_OVH_CLIENT_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/docs/getting_started_basic.md b/docs/getting_started_basic.md
index f0897d5..a764f8d 100644
--- a/docs/getting_started_basic.md
+++ b/docs/getting_started_basic.md
@@ -72,6 +72,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.
+ 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 e0b1ce6..bffeb86 100644
--- a/lib/auth/openstack/swift/cache.ex
+++ b/lib/auth/openstack/swift/cache.ex
@@ -4,7 +4,6 @@ defmodule ExOvh.Auth.Openstack.Swift.Cache do
use Openstex.Cache
alias ExOvh.Auth.Openstack.Swift.Cache.Cloudstorage
alias ExOvh.Auth.Openstack.Swift.Cache.Webstorage
- alias Openstex.Keystone.V2.Helpers, as: Keystone
alias Openstex.Keystone.V2.Helpers.Identity
import ExOvh.Utils, only: [ets_tablename: 1]
@get_identity_retries 5
@@ -22,7 +21,7 @@ defmodule ExOvh.Auth.Openstack.Swift.Cache do
# Pulic Opestex.Cache callbacks (public 'interface' to the Cache module)
def get_swift_public_url(swift_client) do
- public_url = get_identity(swift_client)
+ get_identity(swift_client)
|> Map.get(:service_catalog)
|> Enum.find(fn(%Identity.Service{} = service) -> service.name == "swift" end)
|> Map.get(:endpoints)
@@ -88,7 +87,7 @@ defmodule ExOvh.Auth.Openstack.Swift.Cache do
{:stop, :shutdown, :ok, state}
end
- def terminate(:shutdown, {swift_client, identity}) do
+ def terminate(:shutdown, {swift_client, _identity}) do
Og.context(__ENV__, :debug)
:ets.delete(ets_tablename(swift_client)) # explicilty remove
:ok
@@ -106,7 +105,7 @@ defmodule ExOvh.Auth.Openstack.Swift.Cache do
Og.context(__ENV__, :debug)
Cloudstorage.create_identity({ovh_client, swift_client}, config)
end
- defp create_identity({ovh_client, swift_client}, config, type) do
+ defp create_identity({_ovh_client, _swift_client}, _config, type) do
Og.context(__ENV__, :debug)
raise "create_identity/3 is only supported for the :webstorage and :cloudstorage types, #{inspect(type)}"
end
diff --git a/lib/auth/openstack/swift/cloudstorage.ex b/lib/auth/openstack/swift/cloudstorage.ex
index 6352da3..fd846c6 100644
--- a/lib/auth/openstack/swift/cloudstorage.ex
+++ b/lib/auth/openstack/swift/cloudstorage.ex
@@ -6,12 +6,11 @@ defmodule ExOvh.Auth.Openstack.Swift.Cache.Cloudstorage do
@doc :false
@spec create_identity({atom, atom}, Keyword.t) :: Identity.t | no_return
- def create_identity({ovh_client, swift_client}, config) do
+ def create_identity({ovh_client, _swift_client}, config) do
Og.context(__ENV__, :debug)
tenant_id = Keyword.fetch!(config, :tenant_id)
user_id = Keyword.get(config, :user_id, :nil)
- region = Keyword.get(config, :region, "SBG1")
user_id =
case user_id do
@@ -41,7 +40,7 @@ defmodule ExOvh.Auth.Openstack.Swift.Cache.Cloudstorage do
# make sure the regenerate credentials (in the external ovh api) had a chance to take effect
:timer.sleep(1000)
- identity = Keystone.authenticate!(endpoint, username, password, [tenant_id: tenant_id])
+ Keystone.authenticate!(endpoint, username, password, [tenant_id: tenant_id])
end
diff --git a/lib/auth/openstack/swift/webstorage.ex b/lib/auth/openstack/swift/webstorage.ex
index 005307e..b2cfb33 100644
--- a/lib/auth/openstack/swift/webstorage.ex
+++ b/lib/auth/openstack/swift/webstorage.ex
@@ -20,33 +20,30 @@ defmodule ExOvh.Auth.Openstack.Swift.Cache.Webstorage do
webstorage =
%{
- "domain" => domain,
- "storageLimit" => storage_limit,
- "server" => server,
- "endpoint" => endpoint,
+ "domain" => _domain,
+ "storageLimit" => _storage_limit,
+ "server" => _server,
+ "endpoint" => _endpoint,
"login" => username,
- "password" => password,
+ "password" => _password,
"tenant" => tenant_name
} = Map.merge(properties, credentials)
webstorage = webstorage
|> Map.delete("tenant") |> Map.delete("login")
|> Map.put("username", username) |> Map.put("tenantName", tenant_name)
- webstorage = __MODULE__.new(webstorage)
+ __MODULE__.new(webstorage)
end
@doc :false
@spec create_identity({atom, atom}, Keyword.t) :: Identity.t | no_return
- def create_identity({ovh_client, swift_client}, config) do
+ def create_identity({ovh_client, _swift_client}, config) do
Og.context(__ENV__, :debug)
cdn_name = Keyword.fetch!(config, :cdn_name)
webstorage = webstorage(ovh_client, cdn_name)
- |> Og.log_return(__ENV__, :debug)
%{endpoint: endpoint, username: username, password: password, tenant_name: tenant_name} = webstorage
- |> Og.log_return(__ENV__, :debug)
- identity = Keystone.authenticate!(endpoint, username, password, [tenant_name: tenant_name])
- |> Og.log_return(__ENV__, :debug)
+ Keystone.authenticate!(endpoint, username, password, [tenant_name: tenant_name])
end
diff --git a/lib/auth/ovh/auth.ex b/lib/auth/ovh/auth.ex
index 941604e..957d87e 100644
--- a/lib/auth/ovh/auth.ex
+++ b/lib/auth/ovh/auth.ex
@@ -1,7 +1,6 @@
defimpl Openstex.Auth, for: ExOvh.Ovh.Query do
@moduledoc :false
- alias ExOvh.Utils
alias ExOvh.Ovh.Query
alias ExOvh.Auth.Ovh.Cache
@default_headers [{"Content-Type", "application/json; charset=utf-8"}]
@@ -40,7 +39,7 @@ defimpl Openstex.Auth, for: ExOvh.Ovh.Query do
# Private
- defp headers([app_secret, app_key, consumer_key, method, uri, body] = opts, client) do
+ defp headers([app_secret, app_key, consumer_key, method, uri, body] = _opts, client) do
time = :os.system_time(:seconds) + Cache.get_time_diff(client)
headers = [
{"X-Ovh-Application", app_key},
@@ -53,7 +52,7 @@ defimpl Openstex.Auth, for: ExOvh.Ovh.Query do
end
- defp sign_request([app_secret, consumer_key, method, uri, body, time] = opts) do
+ defp sign_request([_app_secret, _consumer_key, _method, _uri, _body, _time] = opts) do
pre_hash = Enum.join(opts, "+")
post_hash = :crypto.hash(:sha, pre_hash) |> Base.encode16(case: :lower)
"$1$" <> post_hash
diff --git a/lib/auth/ovh/cache.ex b/lib/auth/ovh/cache.ex
index cc43cda..3e03e99 100644
--- a/lib/auth/ovh/cache.ex
+++ b/lib/auth/ovh/cache.ex
@@ -33,7 +33,7 @@ defmodule ExOvh.Auth.Ovh.Cache do
{:reply, diff, diff}
end
- def terminate(:shutdown, state) do
+ def terminate(:shutdown, _state) do
Og.context(__ENV__, :warn)
Og.log_return(__ENV__, "gen_server #{__MODULE__} shutting down", :warn)
:ok
@@ -63,7 +63,7 @@ defmodule ExOvh.Auth.Ovh.Cache do
httpoison_opts = client.httpoison_config()
options = httpoison_opts
resp = HTTPoison.request!(method, uri, body, headers, options)
- api_time = Poison.decode!(resp.body)
+ Poison.decode!(resp.body)
end
diff --git a/lib/client.ex b/lib/client.ex
index 10e256c..e812f87 100644
--- a/lib/client.ex
+++ b/lib/client.ex
@@ -67,6 +67,7 @@ defmodule ExOvh.Client do
cloudstorage: [
tenant_id: System.get_env("MY_APP_MY_CLIENT_CLOUDSTORAGE_TENANT_ID"), # mandatory, corresponds to a project id
user_id: System.get_env("MY_APP_MY_CLIENT_CLOUDSTORAGE_USER_ID"), # optional, if absent a user will be created using the ovh api.
+ account_temp_url_key: System.get_env("MY_APP_MY_CLIENT_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
@@ -129,30 +130,39 @@ defmodule ExOvh.Client do
defmodule Swift.Webstorage do
@moduledoc ExOvh.Client.swift_docs()
use Openstex.Client, client: __MODULE__
+ use Openstex.Swift.V1.Helpers, client: __MODULE__
+
+ @doc :false
def cache(), do: ExOvh.Auth.Openstack.Swift.Cache
+
@doc :false
def config(), do: List.last(__ENV__.context_modules).config() |> Keyword.fetch!(:swift) |> Keyword.fetch!(:webstorage)
- use Openstex.Swift.V1.Helpers, client: __MODULE__
+
@doc "Returns the swift account string."
@spec account() :: String.t
def account(), do: __MODULE__.cache().get_swift_account(__MODULE__)
+
end
defmodule Swift.Cloudstorage do
@moduledoc ExOvh.Client.swift_docs()
use Openstex.Client, client: __MODULE__
+ use Openstex.Swift.V1.Helpers, client: __MODULE__
+
+ @doc :false
def cache(), do: ExOvh.Auth.Openstack.Swift.Cache
+
@doc :false
def config() do
List.last(__ENV__.context_modules).config() |> Keyword.fetch!(:swift) |> Keyword.fetch!(:cloudstorage)
|> Keyword.merge(Defaults.cloudstorage(), fn(_k, v1, v2) -> if v1 == :nil, do: v2, else: v1 end)
end
- use Openstex.Swift.V1.Helpers, client: __MODULE__
+
@doc "Returns the swift account string."
@spec account() :: String.t
def account(), do: __MODULE__.cache().get_swift_account(__MODULE__)
- end
+ end
end
end
diff --git a/lib/mix/tasks/ovh.ex b/lib/mix/tasks/ovh.ex
index 2689828..4660cf4 100644
--- a/lib/mix/tasks/ovh.ex
+++ b/lib/mix/tasks/ovh.ex
@@ -35,7 +35,6 @@ defmodule Mix.Tasks.Ovh do
[mix task advanced](https://hexdocs.pm/ex_ovh/doc/mix_task_advanced.md.html) for practical steps involved in running the hubic mix task.
"""
use Mix.Task
- alias ExOvh.Utils
alias ExOvh.Ovh.Defaults
@default_headers [{"Content-Type", "application/json; charset=utf-8"}]
@default_options [ timeout: 30000, recv_timeout: (60000 * 1) ]
@@ -77,7 +76,7 @@ defmodule Mix.Tasks.Ovh do
defp parse_args(args) do
{opts, _, _} = OptionParser.parse(args)
- {opts, opts_map } = opts
+ {_opts, opts_map} = opts
|> has_required_args()
|> parsers_login()
|> parsers_password()
@@ -112,7 +111,7 @@ defmodule Mix.Tasks.Ovh do
defp parsers_login({opts, acc}), do: {opts, Map.merge(acc, %{login: Keyword.fetch!(opts, :login)}) }
defp parsers_password({opts, acc}), do: {opts, Map.merge(acc, %{ password: Keyword.fetch!(opts, :password)}) }
- defp parsers_app_name({opts, acc}), do: {opts, Map.merge(acc, %{ application_name: Keyword.fetch!(opts, :appname)}) }
+ # defp parsers_app_name({opts, acc}), do: {opts, Map.merge(acc, %{ application_name: Keyword.fetch!(opts, :appname)}) }
defp parsers_endpoint({opts, acc}) do
endpoint = Keyword.get(opts, :endpoint, :nil)
endpoint =
@@ -331,7 +330,7 @@ defmodule Mix.Tasks.Ovh do
inputs = Floki.find(resp_body, "form input") ++
Floki.find(resp_body, "form select")
|> List.flatten()
- |> Enum.filter(fn({type, input, options}) ->
+ |> Enum.filter(fn({_type, input, _options}) ->
:proplists.get_value("name", input) !== "identifiant"
end)
if Enum.any?(inputs, fn(input) -> input === [] end), do: raise "Inputs should not be empty"
@@ -339,11 +338,11 @@ defmodule Mix.Tasks.Ovh do
end
- defp build_ck_binding_request(inputs, %{login: login, password: password} = opts_map) do
+ defp build_ck_binding_request(inputs, %{login: login, password: password} = _opts_map) do
Og.context(__ENV__, :debug)
{acc, _index, _max} =
- Enum.reduce(inputs, {"", 1, Enum.count(inputs)}, fn({type, input, options}, acc) ->
+ Enum.reduce(inputs, {"", 1, Enum.count(inputs)}, fn({type, input, _options}, acc) ->
{name_val, value} =
cond do
type == "input" && {"name", "credentialToken"} in input ->
diff --git a/lib/ovh/v1/cloud/query.ex b/lib/ovh/v1/cloud/query.ex
index 828d6d2..c342932 100644
--- a/lib/ovh/v1/cloud/query.ex
+++ b/lib/ovh/v1/cloud/query.ex
@@ -307,10 +307,13 @@ defmodule ExOvh.Ovh.V1.Cloud.Query do
"""
@spec get_prices(String.t | :nil, String.t | :nil) :: Query.t
def get_prices(region \\ :nil, flavor_id \\ :nil) do
- params = if region == :nil and flavor_id == :nil, do: :nil
- params = if region != :nil and flavor_id == :nil, do: %{ "region" => region }
- params = if region == :nil and flavor_id != :nil, do: %{ "flavorId" => flavor_id }
- params = if region != :nil and flavor_id != :nil, do: %{ "region" => region, "flavorId" => flavor_id }
+ params =
+ cond do
+ region == :nil and flavor_id == :nil -> :nil
+ region != :nil and flavor_id == :nil -> %{"region" => region}
+ region == :nil and flavor_id != :nil -> %{"flavorId" => flavor_id}
+ region != :nil and flavor_id != :nil -> %{ "region" => region, "flavorId" => flavor_id }
+ end
%Query{
method: :get,
uri: "/cloud/createProject",
@@ -494,7 +497,7 @@ defmodule ExOvh.Ovh.V1.Cloud.Query do
@spec project_consumption(String.t, String.t, String.t) :: Query.t
def project_consumption(service_name, date_from \\ :nil, date_to \\ :nil) do
date_from = if date_from == :nil, do: Calendar.DateTime.now_utc!() |> Calendar.DateTime.add!(-(60*60*24*28)) |> Calendar.DateTime.Format.rfc3339(), else: date_from
- date_to = if date_from == :nil, do: Calendar.DateTime.now_utc!() |> Calendar.DateTime.Format.rfc3339(), else: date_from
+ date_to = if date_to == :nil, do: Calendar.DateTime.now_utc!() |> Calendar.DateTime.Format.rfc3339(), else: date_to
%Query{
method: :get,
uri: "/cloud/project/#{service_name}/consumption",
@@ -523,7 +526,7 @@ defmodule ExOvh.Ovh.V1.Cloud.Query do
@spec project_bills(String.t, String.t, String.t) :: Query.t
def project_bills(service_name, date_from \\ :nil, date_to \\ :nil) do
date_from = if date_from == :nil, do: Calendar.DateTime.now_utc!() |> Calendar.DateTime.add!(-(60*60*24*28)) |> Calendar.DateTime.Format.rfc3339(), else: date_from
- date_to = if date_from == :nil, do: Calendar.DateTime.now_utc!() |> Calendar.DateTime.Format.rfc3339(), else: date_from
+ date_to = if date_to == :nil, do: Calendar.DateTime.now_utc!() |> Calendar.DateTime.Format.rfc3339(), else: date_to
%Query{
method: :get,
uri: "/cloud/project/#{service_name}/bill",
diff --git a/lib/supervisor.ex b/lib/supervisor.ex
index a925057..9a176e5 100644
--- a/lib/supervisor.ex
+++ b/lib/supervisor.ex
@@ -11,7 +11,7 @@ defmodule ExOvh.Supervisor do
# Public
- def start_link(client, opts) do
+ def start_link(client, _opts) do
Og.context(__ENV__, :debug)
Supervisor.start_link(__MODULE__, client, [name: client])
end
@@ -38,7 +38,7 @@ defmodule ExOvh.Supervisor do
:nil ->
Og.log("No webstorage config found. Skipping initiation of OVH webstorage cdn service", :debug)
sup_tree
- webstorage_config ->
+ _webstorage_config ->
webstorage_client = Module.concat(client, Swift.Webstorage)
sup_tree ++
[{webstorage_client, {SwiftCache, :start_link, [{ovh_client, webstorage_client}]}, :permanent, 10_000, :worker, [SwiftCache]}]
@@ -49,7 +49,7 @@ defmodule ExOvh.Supervisor do
:nil ->
Og.log("No cloudstorage config found. Skipping initiation of OVH cloudstorage service", :debug)
sup_tree
- cloudstorage_config ->
+ _cloudstorage_config ->
cloudstorage_client = Module.concat(client, Swift.Cloudstorage)
sup_tree ++
[{cloudstorage_client, {SwiftCache, :start_link, [{ovh_client, cloudstorage_client}]}, :permanent, 10_000, :worker, [SwiftCache]}]
diff --git a/lib/utils/utils.ex b/lib/utils/utils.ex
index 9971c5c..ecfa238 100644
--- a/lib/utils/utils.ex
+++ b/lib/utils/utils.ex
@@ -1,9 +1,5 @@
defmodule ExOvh.Utils do
@moduledoc false
- alias ExOvh.Auth.Ovh.Cache, as: OvhCache
- alias ExOvh.Auth.Openstack.Swift.Cache, as: SwiftCache
- alias ExOvh.Ovh.Defaults
-
@doc """
For naming an ets table to incorporate the name of the client.