-
-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d71e7d
commit 6082b18
Showing
14 changed files
with
276 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
### exist | ||
|
||
```ruby | ||
describe codedeploy('my-codedeploy') do | ||
it { should exist } | ||
end | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
### exist | ||
|
||
```ruby | ||
describe codepipeline('my-codepipeline') do | ||
it { should exist } | ||
end | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
module Awspec::Generator | ||
module Doc | ||
module Type | ||
class Codepipeline < Base | ||
def initialize | ||
super | ||
@type_name = 'Codepipeline' | ||
@type = Awspec::Type::Codepipeline.new('my-codepipeline') | ||
@ret = @type.resource_via_client | ||
@matchers = [] | ||
@ignore_matchers = [] | ||
@describes = [] | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
module Awspec::Generator | ||
module Spec | ||
class Codepipeline | ||
include Awspec::Helper::Finder | ||
def generate_all | ||
pipelines = select_all_codepipelines | ||
raise 'Not Found CodePipeline' if pipelines.empty? | ||
|
||
ERB.new(codepipeline_spec_template, nil, '-').result(binding).chomp | ||
end | ||
|
||
def codepipeline_spec_template | ||
<<-'EOF' | ||
<% pipelines.each do |pipeline| %> | ||
describe codepipeline('<%= pipeline.name %>') do | ||
it { should exist } | ||
its(:name) { should eq '<%= pipeline.name %>' } | ||
its(:version) { should eq <%= pipeline.version %> } | ||
its(:pipeline_type) { should eq '<%= pipeline.pipeline_type %>' } | ||
its(:execution_mode) { should eq '<%= pipeline.execution_mode %>' } | ||
end | ||
<% end %> | ||
EOF | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
module Awspec::Helper | ||
module Finder | ||
module Codepipeline | ||
def find_codepipeline(id) | ||
res = codepipeline_client.get_pipeline({ name: id }) | ||
res.pipeline | ||
end | ||
|
||
def select_all_codepipelines | ||
req = {} | ||
pipelines = [] | ||
loop do | ||
res = codepipeline_client.list_pipelines(req) | ||
pipelines.push(*res.pipelines) | ||
break if res.next_token.nil? | ||
|
||
req[:next_token] = res.next_token | ||
end | ||
pipelines | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# frozen_string_literal: true | ||
|
||
Aws.config[:codepipeline] = { | ||
stub_responses: { | ||
get_pipeline: { | ||
pipeline: { | ||
name: 'my-codepipeline', | ||
role_arn: 'arn:aws:iam::123456789012:role/service-role/AWSCodePipelineServiceRole-my-codepipeline', | ||
artifact_store: { | ||
type: 'S3', | ||
location: 'codepipeline-ap-northeast-1-12345678901' | ||
}, | ||
stages: [ | ||
{ | ||
name: 'Source', | ||
actions: [ | ||
{ | ||
name: 'Source', | ||
action_type_id: { | ||
category: 'Source', | ||
owner: 'AWS', | ||
provider: 'S3', | ||
version: '1' | ||
}, | ||
run_order: 1, | ||
configuration: { | ||
'PollForSourceChanges' => 'false', | ||
'S3Bucket' => 'example-bucket', | ||
'S3ObjectKey' => 'test.zip' | ||
}, | ||
output_artifacts: [ | ||
{ | ||
name: 'SourceArtifact' | ||
} | ||
], | ||
input_artifacts: [], | ||
region: 'ap-northeast-1', | ||
namespace: 'SourceVariables' | ||
} | ||
] | ||
}, | ||
{ | ||
name: 'Build', | ||
actions: [ | ||
{ | ||
name: 'Build', | ||
action_type_id: { | ||
category: 'Build', | ||
owner: 'AWS', | ||
provider: 'CodeBuild', | ||
version: '1' | ||
}, | ||
run_order: 1, | ||
configuration: { | ||
'ProjectName' => 'my-codebuild1' | ||
}, | ||
output_artifacts: [ | ||
{ | ||
name: 'BuildArtifact' | ||
} | ||
], | ||
input_artifacts: [ | ||
{ | ||
name: 'SourceArtifact' | ||
} | ||
], | ||
region: 'ap-northeast-1', | ||
namespace: 'BuildVariables' | ||
} | ||
] | ||
} | ||
], | ||
version: 1, | ||
execution_mode: 'QUEUED', | ||
pipeline_type: 'V2' | ||
}, | ||
metadata: { | ||
pipeline_arn: 'arn:aws:codepipeline:ap-northeast-1:123456789012:my-codepipeline', | ||
created: Time.local(2024), | ||
updated: Time.local(2024) | ||
} | ||
}, | ||
list_pipelines: { | ||
pipelines: [ | ||
{ | ||
name: 'my-codepipeline1', | ||
version: 1, | ||
pipeline_type: 'V2', | ||
execution_mode: 'QUEUED', | ||
created: Time.local(2024), | ||
updated: Time.local(2024) | ||
}, | ||
{ | ||
name: 'my-codepipeline2', | ||
version: 1, | ||
pipeline_type: 'V2', | ||
execution_mode: 'QUEUED', | ||
created: Time.local(2024), | ||
updated: Time.local(2024) | ||
} | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
module Awspec::Type | ||
class Codepipeline < ResourceBase | ||
def resource_via_client | ||
@resource_via_client ||= find_codepipeline(@display_name) | ||
end | ||
|
||
def id | ||
@id ||= resource_via_client if resource_via_client.name | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe 'Awspec::Generator::Spec::Codepipeline' do | ||
before do | ||
Awspec::Stub.load 'codepipeline' | ||
end | ||
let(:codepipeline) { Awspec::Generator::Spec::Codepipeline.new } | ||
it 'generate_all generate spec' do | ||
spec = <<-'EOF' | ||
describe codepipeline('my-codepipeline1') do | ||
it { should exist } | ||
its(:name) { should eq 'my-codepipeline1' } | ||
its(:version) { should eq 1 } | ||
its(:pipeline_type) { should eq 'V2' } | ||
its(:execution_mode) { should eq 'QUEUED' } | ||
end | ||
describe codepipeline('my-codepipeline2') do | ||
it { should exist } | ||
its(:name) { should eq 'my-codepipeline2' } | ||
its(:version) { should eq 1 } | ||
its(:pipeline_type) { should eq 'V2' } | ||
its(:execution_mode) { should eq 'QUEUED' } | ||
end | ||
EOF | ||
expect(codepipeline.generate_all.to_s.gsub(/\n/, "\n")).to eq spec | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
Awspec::Stub.load 'codepipeline' | ||
|
||
describe codepipeline('my-codepipeline') do | ||
it { should exist } | ||
its(:name) { should eq 'my-codepipeline' } | ||
its(:role_arn) { should eq 'arn:aws:iam::123456789012:role/service-role/AWSCodePipelineServiceRole-my-codepipeline' } | ||
its('artifact_store.type') { should eq 'S3' } | ||
its('artifact_store.location') { should eq 'codepipeline-ap-northeast-1-12345678901' } | ||
its(:version) { should eq 1 } | ||
its(:execution_mode) { should eq 'QUEUED' } | ||
its(:pipeline_type) { should eq 'V2' } | ||
end |