Skip to content

Commit 6493b44

Browse files
authored
Merge pull request #592 from alpineriveredge/add-type-codepipeline
Add codepipeline resource
2 parents e713481 + 8489b8b commit 6493b44

File tree

14 files changed

+275
-4
lines changed

14 files changed

+275
-4
lines changed

doc/_resource_types/codedeploy.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
11
### exist
2+
3+
```ruby
4+
describe codedeploy('my-codedeploy') do
5+
it { should exist }
6+
end
7+
```

doc/_resource_types/codepipeline.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
### exist
2+
3+
```ruby
4+
describe codepipeline('my-codepipeline') do
5+
it { should exist }
6+
end
7+
```

doc/resource_types.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
| [codebuild](#codebuild)
2020
| [codedeploy](#codedeploy)
2121
| [codedeploy_deployment_group](#codedeploy_deployment_group)
22+
| [codepipeline](#codepipeline)
2223
| [cognito_identity_pool](#cognito_identity_pool)
2324
| [cognito_user_pool](#cognito_user_pool)
2425
| [customer_gateway](#customer_gateway)
@@ -759,6 +760,12 @@ Codedeploy resource type.
759760

760761
### exist
761762

763+
```ruby
764+
describe codedeploy('my-codedeploy') do
765+
it { should exist }
766+
end
767+
```
768+
762769
### its(:application_id), its(:application_name), its(:create_time), its(:linked_to_git_hub), its(:git_hub_account_name), its(:compute_platform)
763770
## <a name="codedeploy_deployment_group">codedeploy_deployment_group</a>
764771

@@ -784,6 +791,19 @@ end
784791
```
785792

786793
### its(:application_name), its(:deployment_group_id), its(:deployment_group_name), its(:deployment_config_name), its(:on_premises_instance_tag_filters), its(:service_role_arn), its(:target_revision), its(:trigger_configurations), its(:alarm_configuration), its(:deployment_style), its(:outdated_instances_strategy), its(:load_balancer_info), its(:last_successful_deployment), its(:last_attempted_deployment), its(:ec2_tag_set), its(:on_premises_tag_set), its(:compute_platform), its(:ecs_services), its(:termination_hook_enabled)
794+
## <a name="codepipeline">codepipeline</a>
795+
796+
Codepipeline resource type.
797+
798+
### exist
799+
800+
```ruby
801+
describe codepipeline('my-codepipeline') do
802+
it { should exist }
803+
end
804+
```
805+
806+
### its(:name), its(:role_arn), its(:artifact_stores), its(:version), its(:execution_mode), its(:pipeline_type), its(:variables), its(:triggers)
787807
## <a name="cognito_identity_pool">cognito_identity_pool</a>
788808

789809
CognitoIdentityPool resource type.

lib/awspec/generator.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
require 'awspec/generator/spec/rds_db_cluster'
4545
require 'awspec/generator/spec/rds_global_cluster'
4646
require 'awspec/generator/spec/managed_prefix_list'
47+
require 'awspec/generator/spec/codepipeline'
4748

4849
# Doc
4950
require 'awspec/generator/doc/type'
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# frozen_string_literal: true
2+
3+
module Awspec::Generator
4+
module Doc
5+
module Type
6+
class Codepipeline < Base
7+
def initialize
8+
super
9+
@type_name = 'Codepipeline'
10+
@type = Awspec::Type::Codepipeline.new('my-codepipeline')
11+
@ret = @type.resource_via_client
12+
@matchers = []
13+
@ignore_matchers = []
14+
@describes = []
15+
end
16+
end
17+
end
18+
end
19+
end
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# frozen_string_literal: true
2+
3+
module Awspec::Generator
4+
module Spec
5+
class Codepipeline
6+
include Awspec::Helper::Finder
7+
def generate_all
8+
pipelines = select_all_codepipelines
9+
raise 'Not Found CodePipeline' if pipelines.empty?
10+
11+
ERB.new(codepipeline_spec_template, nil, '-').result(binding).chomp
12+
end
13+
14+
def codepipeline_spec_template
15+
<<-'EOF'
16+
<% pipelines.each do |pipeline| %>
17+
describe codepipeline('<%= pipeline.name %>') do
18+
it { should exist }
19+
its(:name) { should eq '<%= pipeline.name %>' }
20+
its(:version) { should eq <%= pipeline.version %> }
21+
its(:pipeline_type) { should eq '<%= pipeline.pipeline_type %>' }
22+
its(:execution_mode) { should eq '<%= pipeline.execution_mode %>' }
23+
end
24+
<% end %>
25+
EOF
26+
end
27+
end
28+
end
29+
end

lib/awspec/helper/finder.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
require 'awspec/helper/finder/msk'
5656
require 'awspec/helper/finder/cognito_identity_pool'
5757
require 'awspec/helper/finder/transfer'
58+
require 'awspec/helper/finder/codepipeline'
5859

5960
require 'awspec/helper/finder/account_attributes'
6061

@@ -117,6 +118,7 @@ module Finder
117118
include Awspec::Helper::Finder::Msk
118119
include Awspec::Helper::Finder::CognitoIdentityPool
119120
include Awspec::Helper::Finder::Transfer
121+
include Awspec::Helper::Finder::Codepipeline
120122

121123
CLIENTS = {
122124
ec2_client: Aws::EC2::Client,
@@ -165,7 +167,8 @@ module Finder
165167
msk_client: Aws::Kafka::Client,
166168
cognito_identity_client: Aws::CognitoIdentity::Client,
167169
cognito_identity_provider_client: Aws::CognitoIdentityProvider::Client,
168-
transfer_client: Aws::Transfer::Client
170+
transfer_client: Aws::Transfer::Client,
171+
codepipeline_client: Aws::CodePipeline::Client
169172
}
170173

171174
CLIENT_OPTIONS = {
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# frozen_string_literal: true
2+
3+
module Awspec::Helper
4+
module Finder
5+
module Codepipeline
6+
def find_codepipeline(id)
7+
res = codepipeline_client.get_pipeline({ name: id })
8+
res.pipeline
9+
end
10+
11+
def select_all_codepipelines
12+
req = {}
13+
pipelines = []
14+
loop do
15+
res = codepipeline_client.list_pipelines(req)
16+
pipelines.push(*res.pipelines)
17+
break if res.next_token.nil?
18+
19+
req[:next_token] = res.next_token
20+
end
21+
pipelines
22+
end
23+
end
24+
end
25+
end

lib/awspec/helper/type.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module Type
2424
internet_gateway acm cloudwatch_logs dynamodb_table eip sqs ssm_parameter cloudformation_stack
2525
codebuild sns_topic redshift redshift_cluster_parameter_group codedeploy codedeploy_deployment_group
2626
secretsmanager msk transit_gateway cognito_identity_pool cognito_user_pool vpc_endpoints
27-
transfer_server managed_prefix_list
27+
transfer_server managed_prefix_list codepipeline
2828
]
2929

3030
ACCOUNT_ATTRIBUTES = %w[

lib/awspec/stub/cloudfront_distribution.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
status: 'Deployed',
1818
last_modified_time: Time.new(2015, 1, 2, 10, 00, 00, '+00:00'),
1919
domain_name: 'abcdefghijklmn.cloudfront.net',
20-
staging: false,
2120
aliases: {
2221
quantity: 0,
2322
items: []
@@ -117,7 +116,6 @@
117116
status: 'Deployed',
118117
last_modified_time: Time.new(2016, 3, 2, 10, 00, 00, '+00:00'),
119118
domain_name: '123456789zyxw.cloudfront.net',
120-
staging: false,
121119
aliases: {
122120
quantity: 1,
123121
items: ['cf-s3-origin-hosting.dev.example.com']

0 commit comments

Comments
 (0)