akamai_ccu 1.5.3 → 1.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/akamai_ccu/cli.rb +3 -3
- data/lib/akamai_ccu/secret.rb +10 -12
- data/lib/akamai_ccu/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 590edfc04540966643fb8dcb26d61b1bc1fd472d
|
4
|
+
data.tar.gz: 786b909ccd366835593fd460dc590d6d2d2b6edd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e08562da9ceb7f72beb90ed9bd38fdae72b23088f28f3c7c47ce964f1dbc5940b85f61d9a805e4632c365fe5529cd202c8e154b3648e5bbe76f04ce7b21543d
|
7
|
+
data.tar.gz: 27796fd0c26becf2f80a1bfdeba91b5d3b5b8586da1248576e24c3854e9462150234029683a5e66c86ce36faae9e26598612fcd96c512aec20d8d10f90b45e83
|
data/lib/akamai_ccu/cli.rb
CHANGED
@@ -18,13 +18,13 @@ module AkamaiCCU
|
|
18
18
|
@wrapper_klass = wrapper_klass
|
19
19
|
@secret_klass = secret_klass
|
20
20
|
@endpoint_klass = endpoint_klass
|
21
|
+
@secret = File.expand_path("~/.edgerc")
|
21
22
|
@network = Endpoint::Network::STAGING
|
22
23
|
end
|
23
24
|
|
24
25
|
def call
|
25
26
|
parser.parse!(@args)
|
26
27
|
return @logger.warn("specify contents to purge by bulk, CP codes or urls") if Array(@objects).empty?
|
27
|
-
return @logger.warn("specify path to the secret file either by edgerc or by txt") unless @secret
|
28
28
|
return @logger.warn("specified secret file does not exist") unless File.exist?(@secret)
|
29
29
|
@wrapper_klass.setup(@secret_klass.by_file(@secret), Client, @logger)
|
30
30
|
wrapper = @wrapper_klass.new(endpoint: endpoint, headers: Array(@headers))
|
@@ -51,7 +51,7 @@ module AkamaiCCU
|
|
51
51
|
OptionParser.new do |opts|
|
52
52
|
opts.banner = "Usage: ccu_#{@action} --secret=~/.edgerc --production --cp=12345,98765"
|
53
53
|
|
54
|
-
opts.on("-sSECRET", "--secret=SECRET", "Load secret
|
54
|
+
opts.on("-sSECRET", "--secret=SECRET", "Load secret by file (default to ~/.edgerc)") do |secret|
|
55
55
|
@secret = File.expand_path(secret)
|
56
56
|
end
|
57
57
|
|
@@ -67,7 +67,7 @@ module AkamaiCCU
|
|
67
67
|
@objects = bulk_objects(File.expand_path(bulk))
|
68
68
|
end
|
69
69
|
|
70
|
-
opts.on("--headers=HEADERS", "Specify HTTP headers to sign") do |headers|
|
70
|
+
opts.on("--headers=HEADERS", "Specify any HTTP headers to sign") do |headers|
|
71
71
|
@headers = headers.split(",").map(&:strip)
|
72
72
|
end
|
73
73
|
|
data/lib/akamai_ccu/secret.rb
CHANGED
@@ -9,19 +9,17 @@ module AkamaiCCU
|
|
9
9
|
|
10
10
|
class FileContentError < ArgumentError; end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
acc
|
20
|
-
end
|
21
|
-
new(client_secret: opts.fetch("client_secret"), host: opts.fetch("host"), access_token: opts.fetch("access_token"), client_token: opts.fetch("client_token"), max_body: opts.fetch("max-body", BODY_SIZE), time: time)
|
22
|
-
rescue KeyError => e
|
23
|
-
raise FileContentError, "bad file content, #{e.message}", e.backtrace
|
12
|
+
def self.by_file(name = "~/.edgerc", time = Time.now)
|
13
|
+
path = File.expand_path(name)
|
14
|
+
return unless File.exist?(path)
|
15
|
+
opts = File.readlines(path).reduce({}) do |acc, entry|
|
16
|
+
_, k, v = Array(entry.match(ENTRY_REGEX))
|
17
|
+
acc[k] = v if k && v
|
18
|
+
acc
|
24
19
|
end
|
20
|
+
new(client_secret: opts.fetch("client_secret"), host: opts.fetch("host"), access_token: opts.fetch("access_token"), client_token: opts.fetch("client_token"), max_body: opts.fetch("max-body", BODY_SIZE), time: time)
|
21
|
+
rescue KeyError => e
|
22
|
+
raise FileContentError, "bad file content, #{e.message}", e.backtrace
|
25
23
|
end
|
26
24
|
|
27
25
|
attr_reader :host, :max_body, :nonce, :timestamp
|
data/lib/akamai_ccu/version.rb
CHANGED