awspec 0.65.2 → 0.66.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c5a96c7e4a0022412a89fa08c8a6fe1af55ddbef
4
- data.tar.gz: 8bb3a41eb66171da8e6f3cca3096b051fca40d00
3
+ metadata.gz: 0d082c7989d077043be4c2678e8319e2ae1692ad
4
+ data.tar.gz: a8f134cf2076f264a9019b5e04acb2bd41bf4e5d
5
5
  SHA512:
6
- metadata.gz: 8b1e05e3132152c79f0733a6efcaf953025f0666abf0492a7b2fda8cd767d1c105b52346017a4a9dbe279b6a8375ba07ce2cd2678328dbe1e4a9043dd3bcc982
7
- data.tar.gz: 09ac078215b3f60c2d791c1b300f8ae8a32cea0b499ea8c33ffd09a4206833e74b57473848d4d729dfc7bcc5efce27b727246afa6fe4fc5f11dbee3fa5964ba3
6
+ metadata.gz: 6dcce735c2782bd85a0ee42fdb01a7b7e8e4c14cc7ee605aa0006313249ed3741b307c8e0ff64128fd832a2e42d7b07f5fe73d5874d24930e9e55e9d50261d6d
7
+ data.tar.gz: 9f7fecbbf166d249d0ff06d840ec5b50dfe089b2efd00c2120bebb3d3a10f130f904d65f771345a5e51d8165dcec04eac3866ada7c6cff464d026aa791aae7c9
@@ -0,0 +1,23 @@
1
+ ### exist
2
+
3
+ ```ruby
4
+ describe ecs_cluster('my-ecs-cluster') do
5
+ it { should exist }
6
+ end
7
+ ```
8
+
9
+ ### be_active, be_inactive
10
+
11
+ ```ruby
12
+ describe ecs_cluster('my-ecs-cluster') do
13
+ it { should be_active }
14
+ end
15
+ ```
16
+
17
+ ### have_container_instance
18
+
19
+ ```ruby
20
+ describe ecs_cluster('my-ecs-cluster') do
21
+ it { have_container_instance('f2756532-8f13-4d53-87c9-aed50dc94cd7') }
22
+ end
23
+ ```
@@ -0,0 +1,18 @@
1
+ ### exist
2
+
3
+ You can set `cluster` ( default: `default` ).
4
+
5
+ ```ruby
6
+ describe ecs_container_instance('my-container-instance'), cluster: 'my-ecs-cluster' do
7
+ it { should exist }
8
+ end
9
+ ```
10
+
11
+ ### be_active, be_inactive
12
+
13
+ ```ruby
14
+ describe ecs_container_instance('my-container-instance'), cluster: 'my-ecs-cluster' do
15
+ it { should be_active }
16
+ end
17
+ ```
18
+
@@ -0,0 +1,15 @@
1
+ ### exist
2
+
3
+ ```ruby
4
+ describe ecs_service('my-ecs-service') do
5
+ it { should exist }
6
+ end
7
+ ```
8
+
9
+ ### be_active, be_draining, be_inactive
10
+
11
+ ```ruby
12
+ describe ecs_service('my-ecs-service') do
13
+ it { should be_active }
14
+ end
15
+ ```
@@ -0,0 +1,15 @@
1
+ ### exist
2
+
3
+ ```ruby
4
+ describe ecs_task_definition('my-ecs-task-definition') do
5
+ it { should exist }
6
+ end
7
+ ```
8
+
9
+ ### be_active, be_inactive
10
+
11
+ ```ruby
12
+ describe ecs_task_definition('my-ecs-task-definition') do
13
+ it { should be_active }
14
+ end
15
+ ```
@@ -476,52 +476,106 @@ EcrRepository resource type.
476
476
  ### exist
477
477
 
478
478
 
479
- ## <a name="ecs_cluster">ecs_cluster</a>
479
+ ## <a name="ecs cluster">ecs cluster</a>
480
480
 
481
- EcsCluster resource type.
481
+ ECS Cluster resource type.
482
482
 
483
483
  ### exist
484
484
 
485
- ### be_active
485
+ ```ruby
486
+ describe ecs_cluster('my-ecs-cluster') do
487
+ it { should exist }
488
+ end
489
+ ```
490
+
491
+
492
+ ### be_active, be_inactive
493
+
494
+ ```ruby
495
+ describe ecs_cluster('my-ecs-cluster') do
496
+ it { should be_active }
497
+ end
498
+ ```
486
499
 
487
- ### be_inactive
488
500
 
501
+ ### have_container_instance
489
502
 
490
- ## <a name="ecs_container_instance">ecs_container_instance</a>
503
+ ```ruby
504
+ describe ecs_cluster('my-ecs-cluster') do
505
+ it { have_container_instance('f2756532-8f13-4d53-87c9-aed50dc94cd7') }
506
+ end
507
+ ```
491
508
 
492
- EcsContainerInstance resource type.
509
+ ### its(:cluster_arn), its(:cluster_name), its(:status), its(:registered_container_instances_count), its(:running_tasks_count), its(:pending_tasks_count), its(:active_services_count)
510
+ ## <a name="ecs container instance">ecs container instance</a>
511
+
512
+ ECS Container Instance resource type.
493
513
 
494
514
  ### exist
495
515
 
496
- ### be_active
516
+ You can set `cluster` ( default: `default` ).
497
517
 
498
- ### be_inactive
518
+ ```ruby
519
+ describe ecs_container_instance('my-container-instance'), cluster: 'my-ecs-cluster' do
520
+ it { should exist }
521
+ end
522
+ ```
499
523
 
500
524
 
501
- ## <a name="ecs_service">ecs_service</a>
525
+ ### be_active, be_inactive
502
526
 
503
- EcsService resource type.
527
+ ```ruby
528
+ describe ecs_container_instance('my-container-instance'), cluster: 'my-ecs-cluster' do
529
+ it { should be_active }
530
+ end
531
+ ```
532
+
533
+
534
+ ### its(:container_instance_arn), its(:ec2_instance_id), its(:version), its(:version_info), its(:status), its(:agent_connected), its(:running_tasks_count), its(:pending_tasks_count), its(:agent_update_status), its(:attributes)
535
+ ## <a name="ecs service">ecs service</a>
536
+
537
+ ECS Service resource type.
504
538
 
505
539
  ### exist
506
540
 
507
- ### be_active
541
+ ```ruby
542
+ describe ecs_service('my-ecs-service') do
543
+ it { should exist }
544
+ end
545
+ ```
508
546
 
509
- ### be_draining
510
547
 
511
- ### be_inactive
548
+ ### be_active, be_draining, be_inactive
512
549
 
550
+ ```ruby
551
+ describe ecs_service('my-ecs-service') do
552
+ it { should be_active }
553
+ end
554
+ ```
513
555
 
514
- ## <a name="ecs_task_definition">ecs_task_definition</a>
556
+ ### its(:service_arn), its(:service_name), its(:cluster_arn), its(:status), its(:desired_count), its(:running_count), its(:pending_count), its(:task_definition), its(:role_arn), its(:created_at), its(:placement_constraints), its(:placement_strategy)
557
+ ## <a name="ecs task definition">ecs task definition</a>
515
558
 
516
- EcsTaskDefinition resource type.
559
+ ECS Task Definition resource type.
517
560
 
518
561
  ### exist
519
562
 
520
- ### be_active
563
+ ```ruby
564
+ describe ecs_task_definition('my-ecs-task-definition') do
565
+ it { should exist }
566
+ end
567
+ ```
568
+
521
569
 
522
- ### be_inactive
570
+ ### be_active, be_inactive
523
571
 
572
+ ```ruby
573
+ describe ecs_task_definition('my-ecs-task-definition') do
574
+ it { should be_active }
575
+ end
576
+ ```
524
577
 
578
+ ### its(:task_definition_arn), its(:family), its(:task_role_arn), its(:network_mode), its(:revision), its(:status), its(:requires_attributes), its(:placement_constraints)
525
579
  ## <a name="efs">efs</a>
526
580
 
527
581
  EFS resource type.
@@ -4,9 +4,13 @@ module Awspec::Generator
4
4
  class EcsCluster < Base
5
5
  def initialize
6
6
  super
7
+ @type_name = 'ECS Cluster'
7
8
  @type = Awspec::Type::EcsCluster.new('my-ecs-cluster')
8
- @matchers = []
9
- @ignore_matchers = []
9
+ @ret = @type.resource_via_client
10
+ @matchers = [
11
+ Awspec::Type::EcsCluster::STATES.map { |state| 'be_' + state.downcase }.join(', ')
12
+ ]
13
+ @ignore_matchers = Awspec::Type::EcsCluster::STATES.map { |state| 'be_' + state.downcase }
10
14
  @describes = []
11
15
  end
12
16
  end
@@ -4,9 +4,13 @@ module Awspec::Generator
4
4
  class EcsContainerInstance < Base
5
5
  def initialize
6
6
  super
7
+ @type_name = 'ECS Container Instance'
7
8
  @type = Awspec::Type::EcsContainerInstance.new('my-ecs-container-instance')
8
- @matchers = []
9
- @ignore_matchers = []
9
+ @ret = @type.resource_via_client
10
+ @matchers = [
11
+ Awspec::Type::EcsContainerInstance::STATES.map { |state| 'be_' + state.downcase }.join(', ')
12
+ ]
13
+ @ignore_matchers = Awspec::Type::EcsContainerInstance::STATES.map { |state| 'be_' + state.downcase }
10
14
  @describes = []
11
15
  end
12
16
  end
@@ -4,9 +4,13 @@ module Awspec::Generator
4
4
  class EcsService < Base
5
5
  def initialize
6
6
  super
7
+ @type_name = 'ECS Service'
7
8
  @type = Awspec::Type::EcsService.new('my-ecs-service')
8
- @matchers = []
9
- @ignore_matchers = []
9
+ @ret = @type.resource_via_client
10
+ @matchers = [
11
+ Awspec::Type::EcsService::STATES.map { |state| 'be_' + state.downcase }.join(', ')
12
+ ]
13
+ @ignore_matchers = Awspec::Type::EcsService::STATES.map { |state| 'be_' + state.downcase }
10
14
  @describes = []
11
15
  end
12
16
  end
@@ -4,9 +4,13 @@ module Awspec::Generator
4
4
  class EcsTaskDefinition < Base
5
5
  def initialize
6
6
  super
7
+ @type_name = 'ECS Task Definition'
7
8
  @type = Awspec::Type::EcsTaskDefinition.new('my-ecs-taskdef')
8
- @matchers = []
9
- @ignore_matchers = []
9
+ @ret = @type.resource_via_client
10
+ @matchers = [
11
+ Awspec::Type::EcsTaskDefinition::STATES.map { |state| 'be_' + state.downcase }.join(', ')
12
+ ]
13
+ @ignore_matchers = Awspec::Type::EcsTaskDefinition::STATES.map { |state| 'be_' + state.downcase }
10
14
  @describes = []
11
15
  end
12
16
  end
@@ -1,26 +1,14 @@
1
1
  module Awspec::Helper
2
2
  module Finder
3
3
  module Ecs
4
- def find_ecs_cluster(cluster_name)
5
- res = ecs_client.describe_clusters(clusters: [cluster_name])
6
- res.clusters.first if res.clusters.count == 1
4
+ def find_ecs_cluster(cluster)
5
+ res = ecs_client.describe_clusters(clusters: [cluster])
6
+ res.clusters.single_resource(cluster)
7
7
  end
8
8
 
9
- def list_ecs_container_instances(cluster_name)
10
- req = { cluster: cluster_name }
11
- container_instances = []
12
- loop do
13
- res = ecs_client.list_container_instances(req)
14
- container_instances.push(*res.container_instance_arns)
15
- break if res.next_token.nil?
16
- req[:next_token] = res.next_token
17
- end
18
- container_instances
19
- end
20
-
21
- def find_ecs_container_instances(cluster_name, container_instances)
22
- res = ecs_client.describe_container_instances(cluster: cluster_name, container_instances: container_instances)
23
- res.container_instances if res.container_instances
9
+ def find_ecs_container_instance(cluster, arn_or_uuid)
10
+ res = ecs_client.describe_container_instances(cluster: cluster, container_instances: [arn_or_uuid])
11
+ res.container_instances.single_resource(arn_or_uuid)
24
12
  end
25
13
 
26
14
  def find_ecs_task_definition(taskdef)
@@ -30,8 +18,28 @@ module Awspec::Helper
30
18
 
31
19
  def find_ecs_service(service)
32
20
  res = ecs_client.describe_services(services: [service])
33
- res.services.first if res.services.count == 1
21
+ res.services.single_resource(service)
34
22
  end
23
+
24
+ def select_ecs_container_instance_arn_by_cluster_name(cluster)
25
+ req = { cluster: cluster }
26
+ arns = []
27
+ loop do
28
+ res = ecs_client.list_container_instances(req)
29
+ arns.push(*res.container_instance_arns)
30
+ break if res.next_token.nil?
31
+ req[:next_token] = res.next_token
32
+ end
33
+ arns
34
+ end
35
+
36
+ # deprecated method
37
+ def find_ecs_container_instances(cluster, container_instances)
38
+ res = ecs_client.describe_container_instances(cluster: cluster, container_instances: container_instances)
39
+ res.container_instances if res.container_instances
40
+ end
41
+
42
+ alias_method :list_ecs_container_instances, :select_ecs_container_instance_arn_by_cluster_name # deprecated method
35
43
  end
36
44
  end
37
45
  end
@@ -35,13 +35,14 @@ module Awspec::Helper
35
35
  def get_id_by_name_tag(name)
36
36
  # takes a name tag and iterates inventory and returns file_system obj
37
37
  inventory = efs_client.describe_file_systems
38
- inventory.file_systems.each do |fs|
38
+ file_systems = inventory.file_systems.select do |fs|
39
39
  tag_query = efs_client.describe_tags({
40
40
  file_system_id: fs.file_system_id
41
41
  })
42
- name_tag = tag_query.find { |tag| tag.key == 'Name' }
43
- return fs.file_system_id if name_tag.value == name
42
+ name_tag = tag_query.tags.find { |tag| tag.key == 'Name' } if tag_query.tags
43
+ name_tag && name_tag.value == name
44
44
  end
45
+ file_systems.single_resource(name).file_system_id
45
46
  end
46
47
 
47
48
  def get_name_by_id(id)
@@ -9,3 +9,9 @@ shared_context 'region', :region do
9
9
  Aws.config[:region] = @_region
10
10
  end
11
11
  end
12
+
13
+ shared_context 'cluster', :cluster do
14
+ before do |example|
15
+ example.metadata[:described_class].cluster = example.metadata[:cluster]
16
+ end
17
+ end
@@ -6,7 +6,7 @@ Aws.config[:ecs] = {
6
6
  cluster_arn: 'arn:aws:ecs:us-east-1:123456789012:cluster/my-ecs-cluster',
7
7
  cluster_name: 'my-ecs-cluster',
8
8
  status: 'ACTIVE',
9
- registered_container_instances_count: 0,
9
+ registered_container_instances_count: 2,
10
10
  pending_tasks_count: 0,
11
11
  running_tasks_count: 0,
12
12
  active_services_count: 0
@@ -17,7 +17,82 @@ Aws.config[:ecs] = {
17
17
  },
18
18
  list_container_instances: {
19
19
  container_instance_arns: [
20
- 'arn:aws:ecs:us-east-1:123456789012:container-instance/f2756532-8f13-4d53-87c9-aed50dc94cd7'
20
+ 'arn:aws:ecs:us-east-1:123456789012:container-instance/f2756532-8f13-4d53-87c9-aed50dc94cd7',
21
+ 'arn:aws:ecs:us-east-1:123456789012:container-instance/abcdr578-9di3-4c87-8h59-abcdei8fjkd9'
22
+ ]
23
+ },
24
+ describe_container_instances: {
25
+ container_instances: [
26
+ {
27
+ agent_connected: true,
28
+ container_instance_arn:
29
+ 'arn:aws:ecs:us-east-1:123456789012:container-instance/f2756532-8f13-4d53-87c9-aed50dc94cd7',
30
+ ec2_instance_id: 'i-01234567',
31
+ pending_tasks_count: 0,
32
+ registered_resources: [
33
+ {
34
+ name: 'CPU',
35
+ type: 'INTEGER',
36
+ double_value: 0.0,
37
+ integer_value: 2048,
38
+ long_value: 0
39
+ },
40
+ {
41
+ name: 'MEMORY',
42
+ type: 'INTEGER',
43
+ double_value: 0.0,
44
+ integer_value: 3768,
45
+ long_value: 0
46
+ },
47
+ {
48
+ name: 'PORTS',
49
+ type: 'STRINGSET',
50
+ double_value: 0.0,
51
+ integer_value: 0,
52
+ long_value: 0,
53
+ string_set_value: %w[
54
+ '2376',
55
+ '22',
56
+ '51678',
57
+ '2375'
58
+ ]
59
+ }
60
+ ],
61
+ remaining_resources: [
62
+ {
63
+ name: 'CPU',
64
+ type: 'INTEGER',
65
+ double_value: 0.0,
66
+ integer_value: 1948,
67
+ long_value: 0
68
+ },
69
+ {
70
+ name: 'MEMORY',
71
+ type: 'INTEGER',
72
+ double_value: 0.0,
73
+ integer_value: 3668,
74
+ long_value: 0
75
+ },
76
+ {
77
+ name: 'PORTS',
78
+ type: 'STRINGSET',
79
+ double_value: 0.0,
80
+ integer_value: 0,
81
+ long_value: 0,
82
+ string_set_value: %w[
83
+ '2376',
84
+ '22',
85
+ '80',
86
+ '51678',
87
+ '2375'
88
+ ]
89
+ }
90
+ ],
91
+ running_tasks_count: 1,
92
+ status: 'ACTIVE'
93
+ }
94
+ ],
95
+ failures: [
21
96
  ]
22
97
  }
23
98
  }
@@ -1,7 +1,5 @@
1
1
  module Awspec::Type
2
2
  class EcsCluster < Base
3
- aws_resource Aws::ECS::Types::Cluster
4
-
5
3
  def initialize(name)
6
4
  super
7
5
  @display_name = name
@@ -15,19 +13,30 @@ module Awspec::Type
15
13
  @id ||= resource_via_client.cluster_name if resource_via_client
16
14
  end
17
15
 
18
- def active?
19
- resource_via_client.status == 'ACTIVE'
16
+ STATES = %w(ACTIVE INACTIVE)
17
+
18
+ STATES.each do |state|
19
+ define_method state.downcase + '?' do
20
+ resource_via_client.status == state
21
+ end
20
22
  end
21
23
 
22
- def inactive?
23
- resource_via_client.status == 'INACTIVE'
24
+ def has_container_instance?(uuid)
25
+ uuid = arn_or_uuid.split('/').last
26
+ find_ecs_container_instance(id, uuid)
24
27
  end
25
28
 
29
+ # deprecated method
26
30
  def container_instance_arns
27
- @container_instance_arns ||= list_ecs_container_instances(id)
31
+ puts ''
32
+ warn Color.on_red(Color.white("!!! `#{__method__}` is deprecated. awspec don't provide complex result !!!"))
33
+ @container_instance_arns ||= select_ecs_container_instance_arn_by_cluster_name(id)
28
34
  end
29
35
 
36
+ # deprecated method
30
37
  def container_instances
38
+ puts ''
39
+ warn Color.on_red(Color.white("!!! `#{__method__}` is deprecated. awspec don't provide complex result !!!"))
31
40
  return @container_instances if @container_instances
32
41
  arns = container_instance_arns
33
42
  @container_instances ||=
@@ -1,8 +1,6 @@
1
1
  module Awspec::Type
2
2
  class EcsContainerInstance < Base
3
- aws_resource Aws::ECS::Types::ContainerInstance
4
-
5
- attr_accessor :cluster_name
3
+ attr_accessor :cluster
6
4
 
7
5
  def initialize(container_instance)
8
6
  super
@@ -10,23 +8,23 @@ module Awspec::Type
10
8
  end
11
9
 
12
10
  def resource_via_client
13
- @resource_via_client ||= find_ecs_container_instances(@cluster_name, [@display_name]).first
11
+ @resource_via_client ||= find_ecs_container_instance(cluster, @display_name)
14
12
  end
15
13
 
16
14
  def id
17
15
  @id ||= resource_via_client.container_instance_arn if resource_via_client
18
16
  end
19
17
 
20
- def cluster_name
21
- @cluster_name || 'default'
18
+ def cluster
19
+ @cluster || 'default'
22
20
  end
23
21
 
24
- def active?
25
- resource_via_client.status == 'ACTIVE'
26
- end
22
+ STATES = %w(ACTIVE INACTIVE)
27
23
 
28
- def inactive?
29
- resource_via_client.status == 'INACTIVE'
24
+ STATES.each do |state|
25
+ define_method state.downcase + '?' do
26
+ resource_via_client.status == state
27
+ end
30
28
  end
31
29
  end
32
30
  end
@@ -1,7 +1,5 @@
1
1
  module Awspec::Type
2
2
  class EcsService < Base
3
- aws_resource Aws::ECS::Types::Service
4
-
5
3
  def initialize(service)
6
4
  super
7
5
  @display_name = service
@@ -15,16 +13,12 @@ module Awspec::Type
15
13
  @id ||= resource_via_client.service_name if resource_via_client
16
14
  end
17
15
 
18
- def active?
19
- resource_via_client.status == 'ACTIVE'
20
- end
21
-
22
- def draining?
23
- resource_via_client.status == 'DRAINING'
24
- end
16
+ STATES = %w(ACTIVE DRAINING INACTIVE)
25
17
 
26
- def inactive?
27
- resource_via_client.status == 'INACTIVE'
18
+ STATES.each do |state|
19
+ define_method state.downcase + '?' do
20
+ resource_via_client.status == state
21
+ end
28
22
  end
29
23
  end
30
24
  end
@@ -1,7 +1,5 @@
1
1
  module Awspec::Type
2
2
  class EcsTaskDefinition < Base
3
- aws_resource Aws::ECS::Types::TaskDefinition
4
-
5
3
  def initialize(taskdef)
6
4
  super
7
5
  @display_name = taskdef
@@ -15,12 +13,12 @@ module Awspec::Type
15
13
  @id ||= "#{resource_via_client.family}:#{resource_via_client.revision}" if resource_via_client
16
14
  end
17
15
 
18
- def active?
19
- resource_via_client.status == 'ACTIVE'
20
- end
16
+ STATES = %w(ACTIVE INACTIVE)
21
17
 
22
- def inactive?
23
- resource_via_client.status == 'INACTIVE'
18
+ STATES.each do |state|
19
+ define_method state.downcase + '?' do
20
+ resource_via_client.status == state
21
+ end
24
22
  end
25
23
  end
26
24
  end
@@ -1,3 +1,3 @@
1
1
  module Awspec
2
- VERSION = '0.65.2'
2
+ VERSION = '0.66.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.65.2
4
+ version: 0.66.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - k1LoW
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-09 00:00:00.000000000 Z
11
+ date: 2017-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -216,6 +216,10 @@ files:
216
216
  - doc/_resource_types/directconnect_virtual_interface.md
217
217
  - doc/_resource_types/ebs.md
218
218
  - doc/_resource_types/ec2.md
219
+ - doc/_resource_types/ecs_cluster.md
220
+ - doc/_resource_types/ecs_container_instance.md
221
+ - doc/_resource_types/ecs_service.md
222
+ - doc/_resource_types/ecs_task_definition.md
219
223
  - doc/_resource_types/efs.md
220
224
  - doc/_resource_types/elasticache.md
221
225
  - doc/_resource_types/elasticache_cache_parameter_group.md