ufo 4.6.0 → 4.6.1

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: e191dff1d9d879e6c78eb6062dbdf8440efcc3a1178125af01aaf807e6632e2c
4
- data.tar.gz: 9656eee37d6155be650e7292692db31fe54797c1cf6ea5d9b8f75917ffb0dc7f
3
+ metadata.gz: ed46bcbd9a6677e6a6d8ac6ec6bec143398fe5662aef5833d949c75d604d55c8
4
+ data.tar.gz: 631c1980a669e8fdebb44446246d22683ec0848d0a141f76ca8c1d538acb9710
5
5
  SHA512:
6
- metadata.gz: 3769a6dedd2cb9100c4531a820dd9c1b848acb84a58186d546a7825c4d96765b2a1a8239d6883bfa7e346e2577ed4a0b4d95da29375a266bb13637dbcafd6428
7
- data.tar.gz: b5a48692922794b70328f73153c80f09475c91468e1432f4103d56b80bc5e40f10ef92301e711ee1806e41a1be0987b21b5f1c979371a31ae9b72cc1dbf437e6
6
+ metadata.gz: c1e43ccef253916b2ba63e5202e37297d68d6021cf16c64c679ad7dceee98409c25d8fc2afa80fa115435871ebc36a91d8cf89e9faad7c9a091ca1f9064927ff
7
+ data.tar.gz: e8b6be518ea85b407cb73fba4d1240d38f646ae3c330e4cf6d948d3a496b4e0e98b5aca1112dc3043beb92cb356cf835cc58207fee2753e50bc6a89f685eff6b
@@ -3,6 +3,11 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
5
5
 
6
+ ## [4.6.1]
7
+ - #93 Fix firelens functionality
8
+ - #97 ufo logs --filter-pattern option
9
+ - #98 fix env vars helper to allow surrounding quotes
10
+
6
11
  ## [4.6.0]
7
12
  - #95 Introduce: ufo logs command. Tail logs.
8
13
  - #96 docs and options
@@ -26,14 +26,15 @@ If you have a current service name set.
26
26
  ## Options
27
27
 
28
28
  ```
29
- [--follow], [--no-follow] # Whether to continuously poll for new logs. To exit from this mode, use Control-C.
30
- # Default: true
31
- [--since=SINCE] # From what time to begin displaying logs. By default, logs will be displayed starting from 1 minutes in the past. The value provided can be an ISO 8601 timestamp or a relative time.
32
- [--format=FORMAT] # The format to display the logs. IE: detailed or short. With detailed, the log stream name is also shown.
33
- # Default: simple
34
- [--verbose], [--no-verbose]
35
- [--mute], [--no-mute]
36
- [--noop], [--no-noop]
37
- [--cluster=CLUSTER] # Cluster. Overrides .ufo/settings.yml.
29
+ [--follow], [--no-follow] # Whether to continuously poll for new logs. To exit from this mode, use Control-C.
30
+ # Default: true
31
+ [--since=SINCE] # From what time to begin displaying logs. By default, logs will be displayed starting from 1 minutes in the past. The value provided can be an ISO 8601 timestamp or a relative time.
32
+ [--format=FORMAT] # The format to display the logs. IE: detailed or short. With detailed, the log stream name is also shown.
33
+ # Default: simple
34
+ [--filter-pattern=FILTER_PATTERN] # The filter pattern to use. If not provided, all the events are matched
35
+ [--verbose], [--no-verbose]
36
+ [--mute], [--no-mute]
37
+ [--noop], [--no-noop]
38
+ [--cluster=CLUSTER] # Cluster. Overrides .ufo/settings.yml.
38
39
  ```
39
40
 
@@ -192,6 +192,7 @@ module Ufo
192
192
  option :follow, default: true, type: :boolean, desc: " Whether to continuously poll for new logs. To exit from this mode, use Control-C."
193
193
  option :since, desc: "From what time to begin displaying logs. By default, logs will be displayed starting from 1 minutes in the past. The value provided can be an ISO 8601 timestamp or a relative time."
194
194
  option :format, default: "simple", desc: "The format to display the logs. IE: detailed or short. With detailed, the log stream name is also shown."
195
+ option :filter_pattern, desc: "The filter pattern to use. If not provided, all the events are matched"
195
196
  def logs(service=:current)
196
197
  Logs.new(service, options).run
197
198
  end
@@ -30,7 +30,9 @@ module Ufo
30
30
  def env_vars(text)
31
31
  lines = filtered_lines(text)
32
32
  lines.map do |line|
33
- key,*value = line.strip.split("=").map {|x| x.strip}
33
+ key,*value = line.strip.split("=").map do |x|
34
+ remove_surrounding_quotes(x.strip)
35
+ end
34
36
  value = value.join('=')
35
37
  {
36
38
  name: key,
@@ -39,6 +41,16 @@ module Ufo
39
41
  end
40
42
  end
41
43
 
44
+ def remove_surrounding_quotes(s)
45
+ if s =~ /^"/ && s =~ /"$/
46
+ s.sub(/^["]/, '').gsub(/["]$/,'') # remove surrounding double quotes
47
+ elsif s =~ /^'/ && s =~ /'$/
48
+ s.sub(/^[']/, '').gsub(/[']$/,'') # remove surrounding single quotes
49
+ else
50
+ s
51
+ end
52
+ end
53
+
42
54
  def filtered_lines(text)
43
55
  lines = text.split("\n")
44
56
  # remove comment at the end of the line
@@ -41,14 +41,15 @@ module Ufo
41
41
  end
42
42
 
43
43
  def cloudwatch_tail(log={})
44
- since = @options[:since] || "10m" # by default, search only 10 mins in the past
45
- cw_tail = AwsLogs::Tail.new(
44
+ o = {
46
45
  log_group_name: log["awslogs-group"],
47
46
  log_stream_name_prefix: log["awslogs-stream-prefix"],
48
- since: since,
47
+ since: @options[:since] || "10m", # by default, search only 10 mins in the past
49
48
  follow: @options[:follow],
50
49
  format: @options[:format],
51
- )
50
+ }
51
+ o[:filter_pattern] = @options[:filter_pattern] if @options[:filter_pattern]
52
+ cw_tail = AwsLogs::Tail.new(o)
52
53
  cw_tail.run
53
54
  end
54
55
  end
@@ -70,15 +70,18 @@ module Ufo
70
70
 
71
71
  definitions = data[:container_definitions]
72
72
  definitions.each_with_index do |definition, i|
73
- next unless definition[:log_configuration]
74
- options = definition[:log_configuration][:options]
75
- next unless options
73
+ next unless definition[:log_configuration] || definition[:firelens_configuration]
74
+ { log_configuration: 'logConfiguration',
75
+ firelens_configuration: 'firelensConfiguration' }.each_pair do |key, value|
76
76
 
77
- # LogConfiguration options do not get transformed and keep their original
78
- # structure:
79
- # https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/ECS/Types/ContainerDefinition.html
80
- original_definition = original_data["containerDefinitions"][i]
81
- definition[:log_configuration][:options] = original_definition["logConfiguration"]["options"]
77
+ next unless definition.dig(key, :options)
78
+
79
+ # LogConfiguration and firelensConfiguration options do not get transformed and
80
+ # keep their original structure:
81
+ # https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/ECS/Types/ContainerDefinition.html
82
+ original_definition = original_data["containerDefinitions"][i]
83
+ definition[key][:options] = original_definition[value]["options"]
84
+ end
82
85
  end
83
86
 
84
87
  data
@@ -1,3 +1,3 @@
1
1
  module Ufo
2
- VERSION = "4.6.0"
2
+ VERSION = "4.6.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ufo
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.6.0
4
+ version: 4.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-17 00:00:00.000000000 Z
11
+ date: 2020-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-logs