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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4643ced8d7e2c59fbf952f664830b153535e759faec0808a0929fa468e6a527
4
- data.tar.gz: b3297dd87e662429b8a7fb8eb8319572d58bddc08dedb8bfc182732b1816bb64
3
+ metadata.gz: aa1d6a0266d4f7ee6fe20dd3a0d0e5042e1f587f5d276ba11a514b811742ff1c
4
+ data.tar.gz: d90185bece540bbce81b47e31a8346ad976f17ed54688d0234c26a3f277c62bf
5
5
  SHA512:
6
- metadata.gz: 6914d2d72ed31d866a8db404d3593e5a8440f4982df84b88a8d012828b2b08d74987337b1f31a97153facff046a6bb3cee4d58af9822bc145556628ca983c127
7
- data.tar.gz: 29f0107c67bc1360c89c5f60ea56919b99daa5bc71b1269a694a11b37d74cb2d5be28bef2304251d6776ab8aee6387e150c0b16fd74c19ff1a6491d8258cade6
6
+ metadata.gz: 3bd32954bfc925ff2194b51ea5704764152b248134a5e228b30973d5f7c2991fb8cccf540db357193fe76508a2ba03cb54dc271223cf1a4946ed2fc035614045
7
+ data.tar.gz: a993a805d2f281005b75b64cbc94deae2fc1401ec19d29a5f08370e6f426cc28c13664349050c21703b6394afefd34d21a286b33b2939537afd5ca01bdc6bf36
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- chopshop-logreader (0.2.2)
4
+ chopshop-logreader (0.2.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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
- container = nil
32
- service = ARGV[0]
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 !container
36
- containers = `kubectl get pods --namespace #{options.namespace} | grep #{service}`
37
- container = containers.split("\n").map {|line| line.split(" ") }.each do |line|
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 container
43
- exec "kubectl logs --follow=#{options.follow} --tail=#{options.lines} --namespace connect #{container[0]}"
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 container
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: ruby log-reader.rb SERVICE [options]"
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 containers with the given status. default: Running", String) do |status|
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 containers in. default: connect", String) do |status|
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("-t [TENANT]", "--tenant [TENANT]", "sets the kubernetes tenant to look for containers in. default: nil. You must provide this value or set the ENV VAR DEFAULT_TENANT'", String) do |tenant|
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
 
@@ -1,5 +1,5 @@
1
1
  module Chopshop
2
2
  module Logreader
3
- VERSION = "0.2.2"
3
+ VERSION = "0.2.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chopshop-logreader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Travis Perdue