ECSD 1.0.1 → 1.1.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: 85921421f89d6887512a3a5d71d84872afd6d0edd5cb5a06c60587bc419ac14e
4
- data.tar.gz: 76d1c4978c067f94d239d6991c126e7c2383ed26dba00cd246357d7e1c48fb9e
3
+ metadata.gz: 0f19066645944c5f7ecff8ea1f68a7155a2aab15d9f8a818bd72823aeed8f4de
4
+ data.tar.gz: 3a1d043775d82bd332530f3f390a65d4e96d77249bca1865a3840693e5ad8261
5
5
  SHA512:
6
- metadata.gz: 27abc6484c4c5d1a921338c9e942dabd735cd7294e7ca653a979b8ef1d9645194932c06a601af66e60a7204dd86c56f22aceeac10cf0e5331fafa5bcc065b3b7
7
- data.tar.gz: af3fc571207e37fe660b4abfb558857892fcb2ef8cd0234d31ace182b0269b845202597a3be351afd7dbad4406cd22d90028435d74598e5c69f45056716a9570
6
+ metadata.gz: 504a3ce9d65b4a6a84d5f7ae83ea67cc9160df44bdcb4ae6521846cd88b8efbd2fb1bf5be40f589d95cc31b8012dae22eed512b951fb5114bc0b83fc0825b1bd
7
+ data.tar.gz: 4a63c8319d9a9f6997d35158843e8160819205b6a8a06039ac9ca3da841911ca541562b16e24791c159f296d7759b1a64a51e5377db95a5c59386d41f8d5c87c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # 1.1.1
2
+
3
+ - fix task_revision value type
4
+
5
+ # 1.1.0
6
+
7
+ - add json export file format support
8
+
1
9
  # 1.0.1
2
10
 
3
11
  - fix mapped response instead of 'each'
data/README.md CHANGED
@@ -12,7 +12,7 @@ First create AWS IAM user with roles for describe and list.
12
12
 
13
13
  Then add gem to your service:
14
14
  ```ruby
15
- gem 'ECSD', '~> 1.0'
15
+ gem 'ECSD', '~> 1.1.0'
16
16
  ```
17
17
  Or install directly:
18
18
  ```
data/lib/ecsd/config.rb CHANGED
@@ -24,6 +24,10 @@ module ECSD
24
24
  # @param payload [Hash] { export_path: 'path/to/folder', timeout: 0 }
25
25
  def options=(payload)
26
26
  payload[:export_path] ||= ECSD::DEFAULT_EXPORT_PATH
27
+ payload[:export_format] ||= ECSD::Constants::DEFAULT_EXPORT_FORMAT
28
+ unless [Constants::FORMATS[:json], Constants::FORMATS[:yml]].include?(payload[:export_format])
29
+ raise UnknownExportFormatError, "Invalid export format: #{payload[:export_format]}"
30
+ end
27
31
  payload[:timeout] ||= 0
28
32
  super(payload)
29
33
  end
@@ -2,6 +2,8 @@ module ECSD
2
2
  module Constants
3
3
  DEFAULT_METRICS_PATH = '/metrics'.freeze
4
4
  DEFAULT_EXPORT_PATH = (File.expand_path('../..', __dir__) << '/export').freeze
5
+ FORMATS = { json: 'json', yml: 'yml' }.freeze
6
+ DEFAULT_EXPORT_FORMAT = FORMATS[:yml]
5
7
  LAUNCH_TYPE = 'EC2'.freeze
6
8
  CONNECTIVITY = {
7
9
  connected: 'CONNECTED'
data/lib/ecsd/errors.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  module ECSD
2
2
  class BaseError < RuntimeError; end
3
3
 
4
+ class UnknownExportFormatError < BaseError; end
5
+
4
6
  class Config
5
7
  class ValidationError < BaseError; end
6
8
  end
@@ -2,8 +2,15 @@ module ECSD
2
2
  module Helpers
3
3
  module Common
4
4
  def write_to_file(cluster, data, path = ECSD.config.options[:export_path] || DEFAULT_EXPORT_PATH)
5
- File.open("#{path}/#{cluster.downcase}.yml", 'w') do |f|
6
- f.write(data.join)
5
+ format = ECSD.config.options[:export_format]
6
+ content = case format
7
+ when ECSD::Constants::FORMATS[:yml]
8
+ YAML.dump(data)
9
+ when ECSD::Constants::FORMATS[:json]
10
+ data.to_json
11
+ end
12
+ File.open("#{path}/#{cluster.downcase}.#{format}", 'w') do |f|
13
+ f.write(content)
7
14
  end
8
15
  end
9
16
 
data/lib/ecsd/template.rb CHANGED
@@ -10,17 +10,17 @@ module ECSD
10
10
  container_name:,
11
11
  instance_id:,
12
12
  metrics_path: DEFAULT_METRICS_PATH|
13
- <<~TEXT
14
- - targets:
15
- - #{ip_addr}:#{dyn_port}
16
- labels:
17
- task_id: #{task_id}
18
- task_definition_name: #{task_definition_name}
19
- task_revision: #{task_revision}
20
- cluster_name: #{cluster_name}
21
- container_name: #{container_name}
22
- instance_id: #{instance_id}
23
- __metrics_path__: #{metrics_path}
24
- TEXT
13
+ {
14
+ "targets" => ["#{ip_addr}:#{dyn_port}"],
15
+ "labels" => {
16
+ "task_id" => task_id,
17
+ "task_definition_name" => task_definition_name,
18
+ "task_revision" => task_revision,
19
+ "cluster_name" => cluster_name,
20
+ "container_name" => container_name,
21
+ "instance_id" => instance_id,
22
+ "__metrics_path__" => metrics_path
23
+ }
24
+ }
25
25
  end
26
26
  end
data/lib/ecsd/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ECSD
2
- VERSION = '1.0.1'.freeze
2
+ VERSION = '1.1.1'.freeze
3
3
  end
data/lib/ecsd.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  # frozen_string_literal: true
2
+ require 'json'
3
+ require 'yaml'
2
4
 
3
5
  require 'aws-sdk-ecs'
4
6
  require 'aws-sdk-ec2'
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ECSD
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Shevtsov
8
+ - Anton Kotenko
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2022-08-02 00:00:00.000000000 Z
12
+ date: 2025-02-27 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: aws-sdk-ec2