ecs_helper 0.0.33 → 0.0.34

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: 871394ee1f21e808a91e123a5affccb713a0e7f44fcbb1d308bcc849eb97e992
4
- data.tar.gz: bd42356f7c7984047d85e41810fd12a9aa5a0ef95e63fdab370c38ff20278117
3
+ metadata.gz: 6a88fdb1673cb2abe2e271e6004fd278b0c5d92bf630ab70fcf7a94c5e0730ce
4
+ data.tar.gz: '0278428fd13fc8bc2dcca2b054041787f85c06b1adb94523b09db83a8c160bfe'
5
5
  SHA512:
6
- metadata.gz: 709ccc270f6143206e63d4f55b2ea68b556f8929407e0a44cf9bfd626595b39973a76ade7376072371bb17b965ee56e8340650fc44f22467c15fe4dbd28512c8
7
- data.tar.gz: d7a5f1635642a612a3abe7c3c85887a91475c37fbe3f2bb2d15e8b793d39f7dff29018a55b85e12db43ca5a31ad36fcb3fdd539909bdc0ddce84a95c22eaa7d9
6
+ metadata.gz: 52bb0aba871028e742a3ff98323d807f136ce19c2c55d3451ed429b31f32cc64d13b6e88bf4c0b8aa3cbfb61ea41a36b4014ae11a3bbae54ea4af5a223d069a3
7
+ data.tar.gz: be2a51106a033db704cc57f44539670616e55e12ba6a3f1a62ae1220708d296e6c3e671687889a559c75841788cdb543aaaffce07d432524a5e89e6988534846
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ecs_helper (0.0.33)
4
+ ecs_helper (0.0.34)
5
5
  aws-sdk-ecr (~> 1.42, >= 1.42)
6
6
  aws-sdk-ecrpublic (~> 1.3, >= 1.3)
7
7
  aws-sdk-ecs (~> 1.80, >= 1.80)
@@ -18,7 +18,7 @@ GEM
18
18
  ast (2.4.2)
19
19
  awesome_print (1.9.2)
20
20
  aws-eventstream (1.2.0)
21
- aws-partitions (1.515.0)
21
+ aws-partitions (1.516.0)
22
22
  aws-sdk-core (3.121.1)
23
23
  aws-eventstream (~> 1, >= 1.0.2)
24
24
  aws-partitions (~> 1, >= 1.239.0)
@@ -24,7 +24,6 @@ class ECSHelper::Command::BuildAndPush < ECSHelper::Command::Base
24
24
  end
25
25
  opts.on('-c', '--cache', 'Cache image before build, default false') { options[:cache] = true }
26
26
  opts.on('--build-arg=VALUE', 'Pass --build-arg to the build command') { |o| options[:build_args] << o }
27
- opts.on('-e', '--env-prefix', 'Add environment name as a prefix to the version tag, default false') { options[:env_prefix] = true }
28
27
  end
29
28
  [parser, options]
30
29
  end
@@ -91,11 +90,7 @@ class ECSHelper::Command::BuildAndPush < ECSHelper::Command::Base
91
90
  end
92
91
 
93
92
  def version_tag
94
- if options[:env_prefix]
95
- "#{repository}:#{helper.environment}-#{helper.version}"
96
- else
97
- "#{repository}:#{helper.version}"
98
- end
93
+ "#{repository}:#{helper.version}"
99
94
  end
100
95
 
101
96
  def project
@@ -70,10 +70,10 @@ class ECSHelper::Command::Deploy < ECSHelper::Command::Base
70
70
  end
71
71
 
72
72
  def timeout
73
- options[:timeout] || DEFAULT_TIMEOUT
73
+ (options[:timeout] || DEFAULT_TIMEOUT).to_i
74
74
  end
75
75
 
76
76
  def service
77
77
  helper.client.describe_service(cluster_arn, service_arn)
78
78
  end
79
- end
79
+ end
@@ -124,7 +124,7 @@ class ECSHelper::Command::RunCommand < ECSHelper::Command::Base
124
124
  end
125
125
 
126
126
  def timeout
127
- options[:timeout] || DEFAULT_TIMEOUT
127
+ (options[:timeout] || DEFAULT_TIMEOUT).to_i
128
128
  end
129
129
 
130
130
  def service
@@ -142,4 +142,4 @@ class ECSHelper::Command::RunCommand < ECSHelper::Command::Base
142
142
  def container_name
143
143
  options[:container_name]
144
144
  end
145
- end
145
+ end
@@ -8,6 +8,7 @@ BRANCH_TO_ENV_MAPPING = {
8
8
 
9
9
  class ECSHelper::CommonHelper
10
10
  attr_accessor :helper, :branch, :version, :env
11
+
11
12
  def initialize(helper)
12
13
  @helper = helper
13
14
  end
@@ -17,11 +18,18 @@ class ECSHelper::CommonHelper
17
18
  end
18
19
 
19
20
  def version
20
- @version ||= ENV["CI_COMMIT_SHA"] || `git rev-parse HEAD`.strip
21
+ @version ||=
22
+ begin
23
+ if deployable_branch? && use_image_tag_env_prefix?
24
+ "#{environment}-#{commit_sha}"
25
+ else
26
+ commit_sha
27
+ end
28
+ end
21
29
  end
22
30
 
23
31
  def environment
24
- @env ||= helper.options[:environment] || ENV["ENVIRONMENT"] || BRANCH_TO_ENV_MAPPING[branch.to_sym] || raise(StandardError.new("Environment not detected"))
32
+ @env ||= helper.options[:environment] || ENV["ENVIRONMENT"] || env_from_branch || raise(StandardError.new("Environment not detected"))
25
33
  end
26
34
 
27
35
  def project
@@ -31,4 +39,23 @@ class ECSHelper::CommonHelper
31
39
  def application
32
40
  ENV["APPLICATION"]
33
41
  end
34
- end
42
+
43
+ private
44
+
45
+ def env_from_branch
46
+ BRANCH_TO_ENV_MAPPING[branch.to_sym]
47
+ end
48
+
49
+ def deployable_branch?
50
+ !env_from_branch.nil?
51
+ end
52
+
53
+ def commit_sha
54
+ ENV["CI_COMMIT_SHA"] || `git rev-parse HEAD`.strip
55
+ end
56
+
57
+ def use_image_tag_env_prefix?
58
+ !ENV['USE_IMAGE_TAG_ENV_PREFIX'].nil?
59
+ end
60
+
61
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ECSHelper
4
- VERSION = '0.0.33'
4
+ VERSION = '0.0.34'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecs_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.33
4
+ version: 0.0.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artem Petrov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-14 00:00:00.000000000 Z
11
+ date: 2021-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print