chopshop-logreader 0.2.2 → 0.2.3
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/Gemfile.lock +1 -1
- data/lib/chopshop/logreader/executor.rb +13 -8
- data/lib/chopshop/logreader/parser.rb +11 -6
- data/lib/chopshop/logreader/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa1d6a0266d4f7ee6fe20dd3a0d0e5042e1f587f5d276ba11a514b811742ff1c
|
4
|
+
data.tar.gz: d90185bece540bbce81b47e31a8346ad976f17ed54688d0234c26a3f277c62bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bd32954bfc925ff2194b51ea5704764152b248134a5e228b30973d5f7c2991fb8cccf540db357193fe76508a2ba03cb54dc271223cf1a4946ed2fc035614045
|
7
|
+
data.tar.gz: a993a805d2f281005b75b64cbc94deae2fc1401ec19d29a5f08370e6f426cc28c13664349050c21703b6394afefd34d21a286b33b2939537afd5ca01bdc6bf36
|
data/Gemfile.lock
CHANGED
@@ -27,20 +27,25 @@ module Chopshop
|
|
27
27
|
profile = options.profile || ENV["AWS_PROFILE"] || ENV["PROFILE"]
|
28
28
|
tenant = options.tenant || ENV["DEFAULT_TENANT"]
|
29
29
|
region = options.region || ENV["AWS_REGION"] || "us-east-1"
|
30
|
+
container = options.container
|
30
31
|
|
31
|
-
|
32
|
-
|
32
|
+
service = nil
|
33
|
+
service_name = ARGV[0]
|
33
34
|
`rally-kubectl -a #{region} -e #{profile} -t #{tenant}`
|
34
|
-
puts "looking for valid container"
|
35
|
-
while !
|
36
|
-
|
37
|
-
|
35
|
+
puts "looking for valid service container"
|
36
|
+
while !service
|
37
|
+
services = `kubectl get pods --namespace #{options.namespace} | grep #{service_name}`
|
38
|
+
service = services.split("\n").map {|line| line.split(" ") }.each do |line|
|
38
39
|
match_data = REGEX.match(line[4])
|
39
40
|
line[5] = TIME_CALCULATOR[match_data.captures[1].downcase] * match_data.captures[0].to_i + TIME_CALCULATOR[match_data.captures[3].downcase] * match_data.captures[2].to_i
|
40
41
|
end.select{|line| line[2] == options.status }.sort_by {|line| line[5] }.first
|
41
42
|
|
42
|
-
if
|
43
|
-
|
43
|
+
if service
|
44
|
+
if container
|
45
|
+
exec "kubectl logs --follow=#{options.follow} --tail=#{options.lines} --namespace connect --container=#{container} #{service[0]}"
|
46
|
+
else
|
47
|
+
exec "kubectl logs --follow=#{options.follow} --tail=#{options.lines} --namespace connect #{service[0]}"
|
48
|
+
end
|
44
49
|
end
|
45
50
|
|
46
51
|
print "."
|
@@ -8,16 +8,17 @@ module Chopshop
|
|
8
8
|
options = OpenStruct.new(
|
9
9
|
follow: true, # follow output from log file
|
10
10
|
lines: -1, # whole file always,
|
11
|
-
status: "Running", # look for a currently running
|
11
|
+
status: "Running", # look for a currently running service
|
12
12
|
namespace: "connect",
|
13
13
|
tenant: nil,
|
14
14
|
profile: nil,
|
15
|
-
region: nil
|
15
|
+
region: nil,
|
16
|
+
container: nil
|
16
17
|
)
|
17
18
|
|
18
19
|
|
19
20
|
OptionParser.new do |opts|
|
20
|
-
opts.banner = "Usage:
|
21
|
+
opts.banner = "Usage: chopshop-logreader SERVICE [options]"
|
21
22
|
|
22
23
|
opts.on("-f [FOLLOW]", "--follow [FOLLOW]", "boolean true/false on whether to follow output from the file. default: true", TrueClass) do |follow|
|
23
24
|
options[:follow] = follow
|
@@ -27,11 +28,11 @@ module Chopshop
|
|
27
28
|
options[:lines] = lines
|
28
29
|
end
|
29
30
|
|
30
|
-
opts.on("-s [STATUS]", "--status [STATUS]", "valid values: Completed|Running|Error. will only look for
|
31
|
+
opts.on("-s [STATUS]", "--status [STATUS]", "valid values: Completed|Running|Error. will only look for services/jobs with the given status. default: Running", String) do |status|
|
31
32
|
options[:status] = status
|
32
33
|
end
|
33
34
|
|
34
|
-
opts.on("-n [NAMESPACE]", "--namespace [NAMESPACE]", "sets the kubernetes namespace to look for
|
35
|
+
opts.on("-n [NAMESPACE]", "--namespace [NAMESPACE]", "sets the kubernetes namespace to look for service/job in. default: connect", String) do |status|
|
35
36
|
options[:status] = status
|
36
37
|
end
|
37
38
|
|
@@ -43,7 +44,11 @@ module Chopshop
|
|
43
44
|
options[:region] = region
|
44
45
|
end
|
45
46
|
|
46
|
-
opts.on("-
|
47
|
+
opts.on("-c [CONTAINER]", "--container [CONTAINER]", "sets the kubernetes tenant to look for containers in. default: nil. Often not needed", String) do |container|
|
48
|
+
options[:container] = container
|
49
|
+
end
|
50
|
+
|
51
|
+
opts.on("-t [TENANT]", "--tenant [TENANT]", "sets the kubernetes tenant to look for the service/job in. default: nil. You must provide this value or set the ENV VAR DEFAULT_TENANT'", String) do |tenant|
|
47
52
|
options[:tenant] = tenant
|
48
53
|
end
|
49
54
|
|