ecs_deploy_cli 0.2.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'aws-sdk-cloudwatchevents'
5
+ require 'aws-sdk-cloudwatchlogs'
6
+ require 'aws-sdk-ec2'
7
+ require 'aws-sdk-ssm'
8
+ require 'aws-sdk-cloudformation'
9
+
10
+ describe EcsDeployCli::Runners::Base do
11
+ let(:parser) { EcsDeployCli::DSL::Parser.load('spec/support/ECSFile') }
12
+ subject { described_class.new(parser) }
13
+ let(:mock_cf_client) { Aws::CloudFormation::Client.new(stub_responses: true) }
14
+ let(:mock_ssm_client) { Aws::SSM::Client.new(stub_responses: true) }
15
+ let(:mock_ecs_client) { Aws::ECS::Client.new(stub_responses: true) }
16
+ let(:mock_ec2_client) { Aws::EC2::Client.new(stub_responses: true) }
17
+ let(:mock_cwl_client) { Aws::CloudWatchLogs::Client.new(stub_responses: true) }
18
+ let(:mock_cwe_client) do
19
+ Aws::CloudWatchEvents::Client.new(stub_responses: true)
20
+ end
21
+
22
+ around(:each) do |example|
23
+ ENV['AWS_PROFILE_ID'] = '123123123'
24
+ ENV['AWS_REGION'] = 'us-east-1'
25
+ example.run
26
+ ENV['AWS_PROFILE_ID'] = nil
27
+ ENV['AWS_REGION'] = nil
28
+ end
29
+
30
+ context '#update_task' do
31
+ it 'creates cloud watch logs if missing' do
32
+ _, tasks, = parser.resolve
33
+
34
+ expect(mock_cwl_client).to receive(:describe_log_groups).at_least(:once).and_return({ log_groups: [] })
35
+ expect(mock_cwl_client).to receive(:create_log_group).at_least(:once)
36
+ expect(mock_ecs_client).to receive(:register_task_definition).at_least(:once).and_return({ task_definition: { family: 'some', revision: '1' } })
37
+
38
+ expect_any_instance_of(EcsDeployCli::Runners::Base).to receive(:cwl_client).at_least(:once).and_return(mock_cwl_client)
39
+ expect_any_instance_of(EcsDeployCli::Runners::Base).to receive(:ecs_client).at_least(:once).and_return(mock_ecs_client)
40
+
41
+ subject.update_task(tasks.values.first)
42
+ end
43
+
44
+ it 'creates no cloudwatch log group if is already there' do
45
+ _, tasks, = parser.resolve
46
+
47
+ expect(mock_cwl_client).to receive(:describe_log_groups).at_least(:once).and_return({ log_groups: [{}] })
48
+ expect(mock_cwl_client).not_to receive(:create_log_group)
49
+ expect(mock_ecs_client).to receive(:register_task_definition).at_least(:once).and_return({ task_definition: { family: 'some', revision: '1' } })
50
+
51
+ expect_any_instance_of(EcsDeployCli::Runners::Base).to receive(:cwl_client).at_least(:once).and_return(mock_cwl_client)
52
+ expect_any_instance_of(EcsDeployCli::Runners::Base).to receive(:ecs_client).at_least(:once).and_return(mock_ecs_client)
53
+
54
+ subject.update_task(tasks.values.first)
55
+ end
56
+ end
57
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support'
2
4
  require 'rspec'
3
5
  require 'ecs_deploy_cli'
4
- # require 'kaminari-activerecord'
5
6
 
6
7
  I18n.enforce_available_locales = false
7
8
  RSpec::Expectations.configuration.warn_about_potential_false_positives = false
@@ -11,5 +12,3 @@ Dir[File.expand_path('../support/*.rb', __FILE__)].each { |f| require f }
11
12
  RSpec.configure do |config|
12
13
 
13
14
  end
14
-
15
-
data/spec/support/ECSFile CHANGED
@@ -4,7 +4,14 @@ aws_region ENV.fetch('AWS_REGION', 'eu-central-1')
4
4
  aws_profile_id ENV['AWS_PROFILE_ID']
5
5
 
6
6
  # Defining the cluster name
7
- cluster 'yourproject-cluster'
7
+ cluster 'yourproject-cluster' do
8
+ instance_type 't3.small'
9
+ keypair_name 'test'
10
+
11
+ vpc do
12
+ availability_zones 'eu-central-1a', 'eu-central-1b', 'eu-central-1c'
13
+ end
14
+ end
8
15
 
9
16
  # This is used as a template for the next two containers, it will not be used inside a task
10
17
  container :base_container do
@@ -49,6 +56,11 @@ end
49
56
  # The main service
50
57
  service :'yourproject-service' do
51
58
  task :yourproject
59
+ load_balancer :'yourproject-load-balancer' do
60
+ target_group_arn 'loader-target-group/123abc'
61
+ container_name :web
62
+ container_port 80
63
+ end
52
64
  end
53
65
 
54
66
  # A task for cron jobs
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecs_deploy_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mònade
8
8
  - ProGM
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
  date: 2021-03-31 00:00:00.000000000 Z
@@ -31,6 +31,20 @@ dependencies:
31
31
  - - "<"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '7'
34
+ - !ruby/object:Gem::Dependency
35
+ name: aws-sdk-cloudformation
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1'
41
+ type: :runtime
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1'
34
48
  - !ruby/object:Gem::Dependency
35
49
  name: aws-sdk-cloudwatchevents
36
50
  requirement: !ruby/object:Gem::Requirement
@@ -45,6 +59,20 @@ dependencies:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
61
  version: '1'
62
+ - !ruby/object:Gem::Dependency
63
+ name: aws-sdk-cloudwatchlogs
64
+ requirement: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1'
69
+ type: :runtime
70
+ prerelease: false
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1'
48
76
  - !ruby/object:Gem::Dependency
49
77
  name: aws-sdk-ec2
50
78
  requirement: !ruby/object:Gem::Requirement
@@ -73,6 +101,34 @@ dependencies:
73
101
  - - "~>"
74
102
  - !ruby/object:Gem::Version
75
103
  version: '1'
104
+ - !ruby/object:Gem::Dependency
105
+ name: aws-sdk-ssm
106
+ requirement: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1'
111
+ type: :runtime
112
+ prerelease: false
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1'
118
+ - !ruby/object:Gem::Dependency
119
+ name: aws-sdk-iam
120
+ requirement: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1'
125
+ type: :runtime
126
+ prerelease: false
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1'
76
132
  - !ruby/object:Gem::Dependency
77
133
  name: colorize
78
134
  requirement: !ruby/object:Gem::Requirement
@@ -155,7 +211,9 @@ files:
155
211
  - lib/ecs-deploy-cli.rb
156
212
  - lib/ecs_deploy_cli.rb
157
213
  - lib/ecs_deploy_cli/cli.rb
214
+ - lib/ecs_deploy_cli/cloudformation/default.yml
158
215
  - lib/ecs_deploy_cli/dsl/auto_options.rb
216
+ - lib/ecs_deploy_cli/dsl/cluster.rb
159
217
  - lib/ecs_deploy_cli/dsl/container.rb
160
218
  - lib/ecs_deploy_cli/dsl/cron.rb
161
219
  - lib/ecs_deploy_cli/dsl/parser.rb
@@ -164,18 +222,24 @@ files:
164
222
  - lib/ecs_deploy_cli/runner.rb
165
223
  - lib/ecs_deploy_cli/runners/base.rb
166
224
  - lib/ecs_deploy_cli/runners/diff.rb
225
+ - lib/ecs_deploy_cli/runners/logs.rb
167
226
  - lib/ecs_deploy_cli/runners/run_task.rb
227
+ - lib/ecs_deploy_cli/runners/setup.rb
168
228
  - lib/ecs_deploy_cli/runners/ssh.rb
229
+ - lib/ecs_deploy_cli/runners/status.rb
169
230
  - lib/ecs_deploy_cli/runners/update_crons.rb
170
231
  - lib/ecs_deploy_cli/runners/update_services.rb
171
232
  - lib/ecs_deploy_cli/runners/validate.rb
172
233
  - lib/ecs_deploy_cli/version.rb
173
234
  - spec/ecs_deploy_cli/cli_spec.rb
235
+ - spec/ecs_deploy_cli/dsl/cluster_spec.rb
174
236
  - spec/ecs_deploy_cli/dsl/container_spec.rb
175
237
  - spec/ecs_deploy_cli/dsl/cron_spec.rb
176
238
  - spec/ecs_deploy_cli/dsl/parser_spec.rb
239
+ - spec/ecs_deploy_cli/dsl/service_spec.rb
177
240
  - spec/ecs_deploy_cli/dsl/task_spec.rb
178
241
  - spec/ecs_deploy_cli/runner_spec.rb
242
+ - spec/ecs_deploy_cli/runners/base_spec.rb
179
243
  - spec/spec_helper.rb
180
244
  - spec/support/ECSFile
181
245
  - spec/support/ECSFile.minimal
@@ -186,7 +250,7 @@ licenses:
186
250
  - MIT
187
251
  metadata:
188
252
  source_code_uri: https://github.com/monade/ecs-deploy-cli
189
- post_install_message:
253
+ post_install_message:
190
254
  rdoc_options: []
191
255
  require_paths:
192
256
  - lib
@@ -201,8 +265,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
265
  - !ruby/object:Gem::Version
202
266
  version: '0'
203
267
  requirements: []
204
- rubygems_version: 3.1.4
205
- signing_key:
268
+ rubygems_version: 3.2.7
269
+ signing_key:
206
270
  specification_version: 4
207
271
  summary: A command line interface to make ECS deployments easier
208
272
  test_files:
@@ -213,7 +277,10 @@ test_files:
213
277
  - spec/support/env_file.ext.yml
214
278
  - spec/ecs_deploy_cli/runner_spec.rb
215
279
  - spec/ecs_deploy_cli/cli_spec.rb
280
+ - spec/ecs_deploy_cli/runners/base_spec.rb
216
281
  - spec/ecs_deploy_cli/dsl/task_spec.rb
217
282
  - spec/ecs_deploy_cli/dsl/parser_spec.rb
283
+ - spec/ecs_deploy_cli/dsl/service_spec.rb
218
284
  - spec/ecs_deploy_cli/dsl/cron_spec.rb
285
+ - spec/ecs_deploy_cli/dsl/cluster_spec.rb
219
286
  - spec/ecs_deploy_cli/dsl/container_spec.rb