Skip to content

Commit

Permalink
Enhance codebuild resource
Browse files Browse the repository at this point in the history
Enable codebuild properties tests
  • Loading branch information
alpineriveredge committed May 28, 2024
1 parent f556248 commit 38aaec1
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 4 deletions.
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
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

0 comments on commit 38aaec1

Please sign in to comment.