ufo 3.4.1 → 3.4.2

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: 52f0ef8e22102e9fc1ae63ae8074d39678bc575a457a94d04ffd0ec07e6c6938
4
- data.tar.gz: aa281a52edbafa042a7005e8b7dd8ae687126c201197f7dbee220c30b239af88
3
+ metadata.gz: 577e905ee782f5880d9d9e5bc69ee622e65b7ded641ea3bbcc48e022bd409a07
4
+ data.tar.gz: b47e630a786fa437df2662879fc2697605a01b1523346ca5718da276db1c20c8
5
5
  SHA512:
6
- metadata.gz: '09506b8a70f79e4cb98292d5783ea875220eb02efb15098148b81a080a67820acf65926d1fe96ae50c9c1f41637a10fa4d4c20bb563af5948624f3a9f52378d2'
7
- data.tar.gz: 370f8cf93cfa5010d90ef92bb5fd2a2b43828ee31e4bd211ccf14221ba34b90cc51f46eaf2f58b31b28a7f7df37793b8d9e1fdf94429331bc31dd61e3e3138f2
6
+ metadata.gz: c10fb1658f61cb08b868dc2d7adc473fd618e0e9a8556567908ae7e4745651c33bc25d4ac92046ddf6113ef05a633a10dfdbe88751fab4e45405ef043c8fda76
7
+ data.tar.gz: e322a656ae5e18b423af595a80b111b706c804975f8f0a8adb1ad9e8be4fae9b1972ad994500d8a97e4f0ab24dad712605fe0e286a0992bd9842e2db56cb2239
@@ -3,6 +3,10 @@
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
+ ## [3.4.2]
7
+ - Merge pull request #33 from tongueroo/rubyize_format
8
+ - improve rubyize_format so that original log configuration options are kept
9
+
6
10
  ## [3.4.1]
7
11
  - Merge pull request #32 from tongueroo/fix-log-configuration
8
12
  - fix log configuration dasherization
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ufo (3.4.1)
4
+ ufo (3.4.2)
5
5
  aws-sdk-cloudwatchlogs
6
6
  aws-sdk-ec2
7
7
  aws-sdk-ecr
@@ -22,10 +22,10 @@ module Ufo
22
22
 
23
23
  # aws ecs register-task-definition --cli-input-json file://.ufo/output/hi-web-prod.json
24
24
  def register
25
- data = JSON.parse(IO.read(@template_definition_path), symbolize_names: true)
26
- data = data.to_snake_keys
27
- data = dasherize_log_configuation_option(data)
28
- message = "#{data[:family]} task definition registered."
25
+ data = JSON.parse(IO.read(@template_definition_path))
26
+ puts "@template_definition_path #{@template_definition_path.inspect}"
27
+ data = rubyize_format(data)
28
+ message = "#{data[:family]} task definition registered."
29
29
  if @options[:noop]
30
30
  message = "NOOP: #{message}"
31
31
  else
@@ -53,19 +53,28 @@ module Ufo
53
53
  end
54
54
  end
55
55
 
56
- # LogConfiguration requires a string with dashes as the keys
57
- # https://docs.aws.amazon.com/sdkforruby/api/Aws/ECS/Client.html
58
- def dasherize_log_configuation_option(data)
56
+ # The ruby aws-sdk expects symbols for keys and AWS docs for the task
57
+ # definition uses json camelCase for the keys. This method transforms
58
+ # the keys to the expected ruby aws-sdk format.
59
+ #
60
+ # One quirk is that the logConfiguration options casing should not be
61
+ # transformed.
62
+ def rubyize_format(original_data)
63
+ data = original_data.to_snake_keys.deep_symbolize_keys
64
+
59
65
  definitions = data[:container_definitions]
60
- definitions.each do |definition|
66
+ definitions.each_with_index do |definition, i|
61
67
  next unless definition[:log_configuration]
62
68
  options = definition[:log_configuration][:options]
63
69
  next unless options
64
70
 
65
- options["awslogs-group"] = options.delete(:awslogs_group)
66
- options["awslogs-region"] = options.delete(:awslogs_region)
67
- options["awslogs-stream-prefix"] = options.delete(:awslogs_stream_prefix)
71
+ # LogConfiguration options do not get transformed and keep their original
72
+ # structure:
73
+ # https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/ECS/Types/ContainerDefinition.html
74
+ original_definition = original_data["containerDefinitions"][i]
75
+ definition[:log_configuration][:options] = original_definition["logConfiguration"]["options"]
68
76
  end
77
+
69
78
  data
70
79
  end
71
80
  end
@@ -1,3 +1,3 @@
1
1
  module Ufo
2
- VERSION = "3.4.1"
2
+ VERSION = "3.4.2"
3
3
  end
@@ -18,6 +18,14 @@ describe Ufo::CLI do
18
18
  end
19
19
 
20
20
  context "tasks" do
21
+ before(:each) do
22
+ FileUtils.mkdir_p("#{Ufo.root}/.ufo/data/")
23
+ FileUtils.touch("#{Ufo.root}/.ufo/data/docker_image_name_ufo.txt")
24
+ end
25
+ after(:each) do
26
+ FileUtils.rm_f("#{Ufo.root}/.ufo/data/docker_image_name_ufo.txt")
27
+ end
28
+
21
29
  it "build builds task definition" do
22
30
  out = execute("exe/ufo tasks build #{@args}")
23
31
  expect(out).to include("Task Definitions built")
@@ -8,16 +8,16 @@ describe Ufo::Tasks::Register do
8
8
  context "syslog" do
9
9
  let(:data) do
10
10
  {
11
- "container_definitions": [{
12
- "logConfiguration": {
13
- "logDriver": "syslog"
11
+ "containerDefinitions" => [{
12
+ "logConfiguration" => {
13
+ "logDriver" => "syslog"
14
14
  }
15
15
  }]
16
- }.to_snake_keys.deep_symbolize_keys
16
+ }
17
17
  end
18
18
 
19
- it "dasherizes log configuration option" do
20
- result = register.dasherize_log_configuation_option(data)
19
+ it "#rubyize_format" do
20
+ result = register.rubyize_format(data)
21
21
  driver = result[:container_definitions][0][:log_configuration][:log_driver]
22
22
  expect(driver).to eq "syslog"
23
23
  end
@@ -26,21 +26,21 @@ describe Ufo::Tasks::Register do
26
26
  context "awslogs" do
27
27
  let(:data) do
28
28
  {
29
- "container_definitions": [{
30
- "logConfiguration": {
31
- "logDriver": "awslogs",
32
- "options": {
33
- "awslogs-group": "mygroup",
34
- "awslogs-region": "us-east-1",
35
- "awslogs-stream-prefix": "mystream"
29
+ "containerDefinitions" => [{
30
+ "logConfiguration" => {
31
+ "logDriver" => "awslogs",
32
+ "options" => {
33
+ "awslogs-group" => "mygroup",
34
+ "awslogs-region" => "us-east-1",
35
+ "awslogs-stream-prefix" => "mystream"
36
36
  }
37
37
  }
38
38
  }]
39
- }.to_snake_keys.deep_symbolize_keys
39
+ }
40
40
  end
41
41
 
42
- it "dasherizes log configuration option" do
43
- result = register.dasherize_log_configuation_option(data)
42
+ it "rubyize_format" do
43
+ result = register.rubyize_format(data)
44
44
  log_configuration = result[:container_definitions][0][:log_configuration]
45
45
  expect(log_configuration[:log_driver]).to eq "awslogs"
46
46
  expect(log_configuration[:options].keys).to include("awslogs-group")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ufo
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.1
4
+ version: 3.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen