Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance codebuild resource #591

Merged
merged 2 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions doc/_resource_types/codebuild.md
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
### exist

```ruby
describe codebuild('my-codebuild1') do
it { should exist }
end
```

### have_tag

```ruby
describe codebuild('my-codebuild1') do
it { should have_tag('env').value('dev') }
end
```
15 changes: 15 additions & 0 deletions doc/resource_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,22 @@ Codebuild resource type.

### exist

```ruby
describe codebuild('my-codebuild1') do
it { should exist }
end
```


### have_tag

```ruby
describe codebuild('my-codebuild1') do
it { should have_tag('env').value('dev') }
end
```

### its(:name), its(:arn), its(:description), its(:secondary_sources), its(:source_version), its(:secondary_source_versions), its(:secondary_artifacts), its(:service_role), its(:timeout_in_minutes), its(:queued_timeout_in_minutes), its(:encryption_key), its(:created), its(:last_modified), its(:webhook), its(:vpc_config), its(:file_system_locations), its(:build_batch_config), its(:concurrent_build_limit), its(:project_visibility), its(:public_project_alias), its(:resource_access_role)
## <a name="codedeploy">codedeploy</a>

Codedeploy resource type.
Expand Down
2 changes: 1 addition & 1 deletion lib/awspec/generator/spec/iam_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def iam_group_spec_template
describe iam_group('<%= group.group_name %>') do
it { should exist }
its(:arn) { should eq '<%= group.arn %>' }
its(:create_date) { should eq Time.parse('<%= group.create_date %>') }
its(:create_date) { should eq Time.parse('<%= group.create_date.utc %>') }
<% select_iam_policy_by_group_name(group.group_name).each do |policy| %> it { should have_iam_policy('<%= policy.policy_name %>') }
<% end %>
<%- inline_policies.each do |line| -%>
Expand Down
2 changes: 1 addition & 1 deletion lib/awspec/generator/spec/iam_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def policy_spec_template
it { should_not be_attachable }
<%- end -%>
its(:arn) { should eq '<%= policy.arn %>' }
its(:update_date) { should eq Time.parse('<%= policy.update_date %>') }
its(:update_date) { should eq Time.parse('<%= policy.update_date.utc %>') }
its(:attachment_count) { should eq <%= policy.attachment_count %> }
<%- users = select_attached_users(policy.arn) -%>
<%- if users.empty? -%>
Expand Down
2 changes: 1 addition & 1 deletion lib/awspec/generator/spec/iam_role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def iam_role_spec_template
describe iam_role('<%= role.role_name %>') do
it { should exist }
its(:arn) { should eq '<%= role.arn %>' }
its(:create_date) { should eq Time.parse('<%= role.create_date %>') }
its(:create_date) { should eq Time.parse('<%= role.create_date.utc %>') }
<% select_iam_policy_by_role_name(role.role_name).each do |policy| %> it { should have_iam_policy('<%= policy.policy_name %>') }
<% end %>
<%- inline_policies.each do |line| -%>
Expand Down
2 changes: 1 addition & 1 deletion lib/awspec/generator/spec/iam_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def iam_user_spec_template
describe iam_user('<%= user.user_name %>') do
it { should exist }
its(:arn) { should eq '<%= user.arn %>' }
its(:create_date) { should eq Time.parse('<%= user.create_date %>') }
its(:create_date) { should eq Time.parse('<%= user.create_date.utc %>') }
<% select_iam_policy_by_user_name(user.user_name).each do |policy| %> it { should have_iam_policy('<%= policy.policy_name %>') }
<% end %>
<%- inline_policies.each do |line| -%>
Expand Down
6 changes: 2 additions & 4 deletions lib/awspec/helper/finder/codebuild.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ module Awspec::Helper
module Finder
module Codebuild
def find_codebuild_project(id)
projects = select_all_codebuild_projects.select do |project|
project == id
end
projects.single_resource(id)
res = codebuild_client.batch_get_projects({ names: [id] })
res.projects.single_resource(id)
end

def select_all_codebuild_projects
Expand Down
56 changes: 56 additions & 0 deletions lib/awspec/stub/codebuild.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,62 @@

Aws.config[:codebuild] = {
stub_responses: {
batch_get_projects: {
projects: [
{
name: 'my-codebuild1',
arn: 'arn:aws:codebuild:ap-northeast-1:123456789012:project/my-codebuild1',
source: {
type: 'S3',
location: 'example-bucket/test.zip',
insecure_ssl: false
},
secondary_sources: [],
secondary_source_versions: [],
artifacts: {
type: 'NO_ARTIFACTS'
},
secondary_artifacts: [],
cache: {
type: 'NO_CACHE'
},
environment: {
type: 'LINUX_CONTAINER',
image: 'aws/codebuild/amazonlinux2-x86_64-standard:5.0',
compute_type: 'BUILD_GENERAL1_SMALL',
environment_variables: [],
privileged_mode: false,
image_pull_credentials_type: 'CODEBUILD'
},
service_role: 'arn:aws:iam::123456789012:role/service-role/codebuild-my-codebuild1-service-role',
timeout_in_minutes: 60,
queued_timeout_in_minutes: 480,
encryption_key: 'arn:aws:kms:ap-northeast-1:123456789012:alias/aws/s3',
tags: [
{
key: 'env',
value: 'dev'
}
],
created: Time.local(2024),
last_modified: Time.local(2024),
badge: {
badge_enabled: false
},
logs_config: {
cloud_watch_logs: {
status: 'ENABLED'
},
s3_logs: {
status: 'DISABLED',
encryption_disabled: false
}
},
project_visibility: 'PRIVATE'
}
],
projects_not_found: []
},
list_projects: {
projects: %w[
my-codebuild1
Expand Down
3 changes: 3 additions & 0 deletions lib/awspec/type/codebuild.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

module Awspec::Type
class Codebuild < ResourceBase
aws_resource Aws::CodeBuild::Types::Project
tags_allowed

def resource_via_client
@resource_via_client ||= find_codebuild_project(@display_name)
end
Expand Down
Loading