codebuild 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitmodules +6 -0
- data/CHANGELOG.md +9 -4
- data/README.md +8 -2
- data/codebuild.gemspec +2 -1
- data/{readme/full_dsl.md → docs/dsl/project.md} +1 -39
- data/docs/dsl/role.md +35 -0
- data/docs/dsl/schedule.md +12 -0
- data/{readme → docs}/github_oauth.md +0 -0
- data/{readme → docs}/type.md +7 -1
- data/lib/codebuild/aws_services/helpers.rb +3 -1
- data/lib/codebuild/core.rb +2 -1
- data/lib/codebuild/dsl/project.rb +4 -0
- data/lib/codebuild/dsl/role.rb +12 -2
- data/lib/codebuild/dsl/schedule.rb +30 -0
- data/lib/codebuild/help/deploy.md +27 -3
- data/lib/codebuild/help/init.md +7 -7
- data/lib/codebuild/help/start.md +3 -3
- data/lib/codebuild/role.rb +4 -1
- data/lib/codebuild/schedule.rb +97 -0
- data/lib/codebuild/stack.rb +4 -1
- data/lib/codebuild/version.rb +1 -1
- data/lib/codebuild.rb +4 -1
- data/lib/template/.codebuild/settings.yml +13 -0
- data/spec/fixtures/app/.codebuild/schedule.rb +1 -0
- data/spec/fixtures/app/.codebuild/settings.yml +13 -0
- data/spec/lib/schedule_spec.rb +12 -0
- metadata +21 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5614b3e4b06a4b51c4057d1546c76813a7993b99f47310d7a0f221b64cbdcbbb
|
4
|
+
data.tar.gz: cc65ce705c47211ac74db8cf66a591de4976e659381557663b1f3ef2a386d1b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 695484589a80ba4ae8a0c1f2b8169290500df74e163938d72ec7bc9f17c48d08d8d64cb9af351105b52a3d2df1d87dcafb25af32c773ee1d75f428d6d1a45d37
|
7
|
+
data.tar.gz: 200fbe445ed597192351b897eadeabf148ea9e45e1a695efd3aeec107e7529dbf01eb0cc1563bbc87f662745fce1fc7d03cdd27327018efa6137d3a17b5f9d94
|
data/.gitmodules
CHANGED
@@ -1,3 +1,9 @@
|
|
1
1
|
[submodule "vendor/cfn-status"]
|
2
2
|
path = vendor/cfn-status
|
3
3
|
url = https://github.com/tongueroo/cfn-status
|
4
|
+
[submodule "vendor/cfn_camelizer"]
|
5
|
+
path = vendor/cfn_camelizer
|
6
|
+
url = https://github.com/tongueroo/cfn_camelizer
|
7
|
+
[submodule "vendor/aws_data"]
|
8
|
+
path = vendor/aws_data
|
9
|
+
url = https://github.com/tongueroo/aws_data
|
data/CHANGELOG.md
CHANGED
@@ -3,11 +3,16 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
|
5
5
|
|
6
|
+
## [0.4.0]
|
7
|
+
- Add managed_iam_policy support
|
8
|
+
- #2 Add schedule dsl
|
9
|
+
- starter template fix: add settings.yml for correct cb project detection
|
10
|
+
|
6
11
|
## [0.3.0]
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
12
|
+
- rework cb cli interface
|
13
|
+
- project_name as cli main parameter
|
14
|
+
- type option for subprojects in .codebuild folder
|
15
|
+
- update to zeitwerk for autoloading
|
11
16
|
|
12
17
|
## [0.2.0]
|
13
18
|
- First good release.
|
data/README.md
CHANGED
@@ -94,7 +94,7 @@ Here's a list of some of the convenience shorthand DSL methods:
|
|
94
94
|
|
95
95
|
Please refer to [lib/codebuild/dsl/project.rb](lib/codebuild/dsl/project.rb) for the full list.
|
96
96
|
|
97
|
-
More slightly more control, you may be interested in the `github_source` and `linux_environment` methods. For even more control, see [
|
97
|
+
More slightly more control, you may be interested in the `github_source` and `linux_environment` methods. For even more control, see [DSL docs](docs/dsl).
|
98
98
|
|
99
99
|
## IAM Role DSL
|
100
100
|
|
@@ -121,9 +121,15 @@ iam_policy(
|
|
121
121
|
)
|
122
122
|
```
|
123
123
|
|
124
|
+
You can also create managed iam policy.
|
125
|
+
|
126
|
+
```ruby
|
127
|
+
managed_iam_policy("AmazonS3ReadOnlyAccess")
|
128
|
+
```
|
129
|
+
|
124
130
|
## Full DSL
|
125
131
|
|
126
|
-
The convenience DSL methods shown above are short and clean. They merely wrap a DSL that map to the properties of CloudFormation resources like [AWS::CodeBuild::Project](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codebuild-project.html) and [AWS::IAM::Role](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html). Refer the [
|
132
|
+
The convenience DSL methods shown above are short and clean. They merely wrap a DSL that map to the properties of CloudFormation resources like [AWS::CodeBuild::Project](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codebuild-project.html) and [AWS::IAM::Role](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html). Refer the [DSL docs](docs/dsl) for more info.
|
127
133
|
|
128
134
|
## Type Option
|
129
135
|
|
data/codebuild.gemspec
CHANGED
@@ -22,11 +22,12 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_dependency "aws-sdk-cloudformation"
|
23
23
|
spec.add_dependency "aws-sdk-codebuild"
|
24
24
|
spec.add_dependency "aws-sdk-ssm"
|
25
|
-
spec.add_dependency "cfn_camelizer"
|
25
|
+
# spec.add_dependency "cfn_camelizer" # using vendor/cfn_camelizer for now
|
26
26
|
spec.add_dependency "memoist"
|
27
27
|
spec.add_dependency "rainbow"
|
28
28
|
spec.add_dependency "render_me_pretty"
|
29
29
|
spec.add_dependency "thor"
|
30
|
+
spec.add_dependency "zeitwerk"
|
30
31
|
|
31
32
|
spec.add_development_dependency "bundler"
|
32
33
|
spec.add_development_dependency "byebug"
|
@@ -1,6 +1,4 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
## Project DSL
|
1
|
+
# Project DSL
|
4
2
|
|
5
3
|
The convenience methods are shorter and cleaner. However, you have access to a "Full" DSL if needed. The Full DSL are merely the properties of the [AWS::CodeBuild::Project CloudFormation Resource](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codebuild-project.html). Here's an example.
|
6
4
|
|
@@ -46,39 +44,3 @@ environment(
|
|
46
44
|
|
47
45
|
service_role(ref: "IamRole")
|
48
46
|
```
|
49
|
-
|
50
|
-
## Full IAM Role DSL
|
51
|
-
|
52
|
-
The convenience methods merely wrap properties of the [AWS::IAM::Role
|
53
|
-
CloudFormation Resource](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html). If you wanted to set the CloudFormation properties more directly, here's an example of using the "Full" DSL.
|
54
|
-
|
55
|
-
.codebuild/role.rb:
|
56
|
-
|
57
|
-
```ruby
|
58
|
-
assume_role_policy_document(
|
59
|
-
statement: [{
|
60
|
-
action: ["sts:AssumeRole"],
|
61
|
-
effect: "Allow",
|
62
|
-
principal: {
|
63
|
-
service: ["codebuild.amazonaws.com"]
|
64
|
-
}
|
65
|
-
}],
|
66
|
-
version: "2012-10-17"
|
67
|
-
)
|
68
|
-
path("/")
|
69
|
-
policies([{
|
70
|
-
policy_name: "CodeBuildAccess",
|
71
|
-
policy_document: {
|
72
|
-
version: "2012-10-17",
|
73
|
-
statement: [{
|
74
|
-
action: [
|
75
|
-
"logs:CreateLogGroup",
|
76
|
-
"logs:CreateLogStream",
|
77
|
-
"logs:PutLogEvents",
|
78
|
-
],
|
79
|
-
effect: "Allow",
|
80
|
-
resource: "*"
|
81
|
-
}]
|
82
|
-
}
|
83
|
-
}])
|
84
|
-
```
|
data/docs/dsl/role.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# IAM Role DSL
|
2
|
+
|
3
|
+
The convenience methods merely wrap properties of the [AWS::IAM::Role
|
4
|
+
CloudFormation Resource](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html). If you wanted to set the CloudFormation properties more directly, here's an example of using the "Full" DSL.
|
5
|
+
|
6
|
+
.codebuild/role.rb:
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
assume_role_policy_document(
|
10
|
+
statement: [{
|
11
|
+
action: ["sts:AssumeRole"],
|
12
|
+
effect: "Allow",
|
13
|
+
principal: {
|
14
|
+
service: ["codebuild.amazonaws.com"]
|
15
|
+
}
|
16
|
+
}],
|
17
|
+
version: "2012-10-17"
|
18
|
+
)
|
19
|
+
path("/")
|
20
|
+
policies([{
|
21
|
+
policy_name: "CodeBuildAccess",
|
22
|
+
policy_document: {
|
23
|
+
version: "2012-10-17",
|
24
|
+
statement: [{
|
25
|
+
action: [
|
26
|
+
"logs:CreateLogGroup",
|
27
|
+
"logs:CreateLogStream",
|
28
|
+
"logs:PutLogEvents",
|
29
|
+
],
|
30
|
+
effect: "Allow",
|
31
|
+
resource: "*"
|
32
|
+
}]
|
33
|
+
}
|
34
|
+
}])
|
35
|
+
```
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Schedule DSL
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
The convenience methods merely wrap properties of the [AWS::Events::Rule](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-description). If you wanted to set the CloudFormation properties more directly, here's an example of using the "Full" DSL.
|
6
|
+
|
7
|
+
.codebuild/schedule.rb:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
description "my description"
|
11
|
+
schedule_expression "rate(1 day)"
|
12
|
+
```
|
File without changes
|
data/{readme → docs}/type.md
RENAMED
@@ -1,6 +1,12 @@
|
|
1
1
|
# Type Option
|
2
2
|
|
3
|
-
By default, the codebuild tool looks up files in the `.codebuild` folder.
|
3
|
+
By default, the codebuild tool looks up files in the `.codebuild` folder. Example:
|
4
|
+
|
5
|
+
.codebuild/buildspec.yml
|
6
|
+
.codebuild/project.rb
|
7
|
+
.codebuild/role.rb
|
8
|
+
|
9
|
+
You can affect the behavior of the lookup logic with the `--type` option.
|
4
10
|
|
5
11
|
## Examples
|
6
12
|
|
@@ -26,7 +26,9 @@ module Codebuild::AwsServices
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def project_name_convention(name_base)
|
29
|
-
[@project_name, @options[:type], Codebuild.
|
29
|
+
items = [@project_name, @options[:type], Codebuild.env_extra]
|
30
|
+
items.insert(2, Codebuild.env) if Codebuild.settings.dig(:stack_naming, :append_env)
|
31
|
+
items.reject(&:blank?).compact.join("-")
|
30
32
|
end
|
31
33
|
|
32
34
|
def inferred_project_name
|
data/lib/codebuild/core.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'pathname'
|
2
2
|
require 'yaml'
|
3
|
+
require 'active_support/core_ext/string'
|
3
4
|
|
4
5
|
module Codebuild
|
5
6
|
module Core
|
@@ -14,7 +15,7 @@ module Codebuild
|
|
14
15
|
# 2-way binding
|
15
16
|
cb_env = env_from_profile || 'development'
|
16
17
|
cb_env = ENV['CB_ENV'] if ENV['CB_ENV'] # highest precedence
|
17
|
-
cb_env
|
18
|
+
ActiveSupport::StringInquirer.new(cb_env)
|
18
19
|
end
|
19
20
|
memoize :env
|
20
21
|
|
data/lib/codebuild/dsl/role.rb
CHANGED
@@ -17,11 +17,11 @@ module Codebuild::Dsl
|
|
17
17
|
|
18
18
|
# convenience wrapper methods
|
19
19
|
def iam_policy(*definitions)
|
20
|
-
@iam_statements = definitions.map { |definition|
|
20
|
+
@iam_statements = definitions.map { |definition| standardize_iam_policy(definition) }
|
21
21
|
end
|
22
22
|
|
23
23
|
# Returns standarized IAM statement
|
24
|
-
def
|
24
|
+
def standardize_iam_policy(definition)
|
25
25
|
case definition
|
26
26
|
when String
|
27
27
|
# Expands simple string from: logs => logs:*
|
@@ -36,5 +36,15 @@ module Codebuild::Dsl
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
+
def managed_iam_policy(*definitions)
|
40
|
+
@managed_policy_arns = definitions.map { |definition| standardize_managed_iam_policy(definition) }
|
41
|
+
end
|
42
|
+
|
43
|
+
# AmazonEC2ReadOnlyAccess => arn:aws:iam::aws:policy/AmazonEC2ReadOnlyAccess
|
44
|
+
def standardize_managed_iam_policy(definition)
|
45
|
+
return definition if definition.include?('iam::aws:policy')
|
46
|
+
|
47
|
+
"arn:aws:iam::aws:policy/#{definition}"
|
48
|
+
end
|
39
49
|
end
|
40
50
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Codebuild::Dsl
|
2
|
+
module Schedule
|
3
|
+
PROPERTIES = %w[
|
4
|
+
description
|
5
|
+
event_pattern
|
6
|
+
name
|
7
|
+
role_arn
|
8
|
+
schedule_expression
|
9
|
+
state
|
10
|
+
targets
|
11
|
+
]
|
12
|
+
PROPERTIES.each do |prop|
|
13
|
+
define_method(prop) do |v|
|
14
|
+
@properties[prop.to_sym] = v
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def rate(period)
|
19
|
+
@schedule_expression = "rate(#{period})"
|
20
|
+
end
|
21
|
+
|
22
|
+
def cron(expression)
|
23
|
+
@schedule_expression = "cron(#{expression})"
|
24
|
+
end
|
25
|
+
|
26
|
+
def rule_event(props={})
|
27
|
+
@rule_event_props = props
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -1,8 +1,32 @@
|
|
1
1
|
## Examples
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
cb deploy PROJECT_NAME # explicitly specify project-name
|
4
|
+
cb deploy # infers the CodeBuild name from the parent folder
|
5
5
|
|
6
6
|
It is useful to just see the generated CloudFormation template with `--noop` mode:
|
7
7
|
|
8
|
-
|
8
|
+
cb deploy PROJECT_NAME --noop # see generated CloudFormation template
|
9
|
+
|
10
|
+
## Types
|
11
|
+
|
12
|
+
By default, the codebuild tool looks up files in the `.codebuild` folder. Example:
|
13
|
+
|
14
|
+
.codebuild/buildspec.yml
|
15
|
+
.codebuild/project.rb
|
16
|
+
.codebuild/role.rb
|
17
|
+
|
18
|
+
### Examples
|
19
|
+
|
20
|
+
cb deploy PROJECT_NAME --type deploy
|
21
|
+
|
22
|
+
This will look up buildspec.yml, project.rb, and role.rb files in the `.codebuild/deploy` folder. So:
|
23
|
+
|
24
|
+
.codebuild/deploy/buildspec.yml
|
25
|
+
.codebuild/deploy/project.rb
|
26
|
+
.codebuild/deploy/role.rb
|
27
|
+
|
28
|
+
Likewise `cb deploy PROJECT_NAME --type unit` would result in:
|
29
|
+
|
30
|
+
.codebuild/unit/buildspec.yml
|
31
|
+
.codebuild/unit/project.rb
|
32
|
+
.codebuild/unit/role.rb
|
data/lib/codebuild/help/init.md
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
## Examples
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
cb init # infers the name from the parent folder
|
4
|
+
cb init --name demo-codebuild-project # set the name
|
5
5
|
|
6
6
|
## Custom Templates
|
7
7
|
|
8
|
-
If you would like the `
|
8
|
+
If you would like the `cb init` command to use your own custom templates, you can achieve this with the `--template` and `--template-mode` options. Example:
|
9
9
|
|
10
|
-
|
10
|
+
cb init --template=tongueroo/codebuild-custom-template
|
11
11
|
|
12
12
|
This will clone the repo on GitHub into the `~/.codebuild/templates/tongueroo/codebuild-custom-template` and use that as an additional template source. The default `--template-mode=additive` mode means that if there's a file in `tongueroo/codebuild-custom-template` that exists it will use that in place of the default template files.
|
13
13
|
|
14
14
|
If you do not want to use any of the original default template files within the ufo gem at all, you can use the `--template-mode=replace` mode. Replace mode will only use templates from the provided `--template` option. Example:
|
15
15
|
|
16
|
-
|
16
|
+
cb init --template=tongueroo/codebuild-custom-template --template-mode=replace
|
17
17
|
|
18
18
|
You can also specific the full GitHub url. Example:
|
19
19
|
|
20
|
-
|
20
|
+
cb init --template=https://github.com/tongueroo/codebuild-custom-template
|
21
21
|
|
22
22
|
If you would like to use a local template that is not on GitHub, then created a top-level folder in `~/.codebuild/templates` without a subfolder. Example:
|
23
23
|
|
24
|
-
|
24
|
+
cb init --template=my-custom # uses ~/.codebuild/templates/my-custom
|
data/lib/codebuild/help/start.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
## Examples
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
cb start # infers the name from the parent folder
|
4
|
+
cb start stack-name # looks up project via CloudFormation stack
|
5
|
+
cb start demo-project # looks up project via codebuild project name
|
6
6
|
|
data/lib/codebuild/role.rb
CHANGED
@@ -20,7 +20,10 @@ module Codebuild
|
|
20
20
|
version: "2012-10-17",
|
21
21
|
statement: derived_iam_statements
|
22
22
|
}
|
23
|
-
}]
|
23
|
+
}] unless @iam_statements.empty?
|
24
|
+
|
25
|
+
@properties[:managed_policy_arns] = @managed_policy_arns if !@managed_policy_arns&.empty?
|
26
|
+
|
24
27
|
resource = {
|
25
28
|
IamRole: {
|
26
29
|
type: "AWS::IAM::Role",
|
@@ -0,0 +1,97 @@
|
|
1
|
+
module Codebuild
|
2
|
+
class Schedule
|
3
|
+
include Codebuild::Dsl::Schedule
|
4
|
+
include Evaluate
|
5
|
+
|
6
|
+
def initialize(options={})
|
7
|
+
@options = options
|
8
|
+
@schedule_path = options[:schedule_path] || get_schedule_path
|
9
|
+
@properties = default_properties
|
10
|
+
@iam_policy = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def run
|
14
|
+
return unless File.exist?(@schedule_path)
|
15
|
+
|
16
|
+
evaluate(@schedule_path)
|
17
|
+
@properties[:schedule_expression] = @schedule_expression if @schedule_expression
|
18
|
+
set_rule_event! if @rule_event_props
|
19
|
+
|
20
|
+
resource = {
|
21
|
+
events_rule: {
|
22
|
+
type: "AWS::Events::Rule",
|
23
|
+
properties: @properties
|
24
|
+
},
|
25
|
+
events_rule_role: events_rule_role,
|
26
|
+
}
|
27
|
+
CfnCamelizer.transform(resource)
|
28
|
+
end
|
29
|
+
|
30
|
+
def set_rule_event!
|
31
|
+
props = @rule_event_props
|
32
|
+
if props.key?(:detail)
|
33
|
+
description = props.key?(:description) ? props.delete(:description) : rule_description
|
34
|
+
rule_props = { event_pattern: props, description: description }
|
35
|
+
else # if props.key?(:event_pattern)
|
36
|
+
props[:description] ||= rule_description
|
37
|
+
rule_props = props
|
38
|
+
end
|
39
|
+
|
40
|
+
@properties.merge!(rule_props)
|
41
|
+
end
|
42
|
+
|
43
|
+
def default_properties
|
44
|
+
description = "CodeBuild #{@options[:full_project_name]}"
|
45
|
+
name = description.gsub(" ", "-").downcase
|
46
|
+
{
|
47
|
+
description: description,
|
48
|
+
# event_pattern: ,
|
49
|
+
name: name,
|
50
|
+
# schedule_expression: ,
|
51
|
+
state: "ENABLED",
|
52
|
+
targets: [{
|
53
|
+
arn: { "Fn::GetAtt": "CodeBuild.Arn" },
|
54
|
+
role_arn: { "Fn::GetAtt": "EventsRuleRole.Arn" }, # required for specific CodeBuild target.
|
55
|
+
id: "CodeBuildTarget",
|
56
|
+
}]
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
def get_schedule_path
|
62
|
+
lookup_codebuild_file("schedule.rb")
|
63
|
+
end
|
64
|
+
|
65
|
+
def events_rule_role
|
66
|
+
{
|
67
|
+
type: "AWS::IAM::Role",
|
68
|
+
properties: {
|
69
|
+
assume_role_policy_document: {
|
70
|
+
statement: [{
|
71
|
+
action: [ "sts:AssumeRole" ],
|
72
|
+
effect: "Allow",
|
73
|
+
principal: { service: [ "events.amazonaws.com" ] }
|
74
|
+
}],
|
75
|
+
version: "2012-10-17"
|
76
|
+
},
|
77
|
+
path: "/",
|
78
|
+
policies: [{
|
79
|
+
policy_name: "CodeBuildAccess",
|
80
|
+
policy_document: {
|
81
|
+
version: "2012-10-17",
|
82
|
+
statement: [{
|
83
|
+
action: "codebuild:StartBuild",
|
84
|
+
effect: "Allow",
|
85
|
+
resource: "arn:aws:codebuild:#{aws_data.region}:#{aws_data.account}:project/#{@options[:full_project_name]}"
|
86
|
+
}]
|
87
|
+
}
|
88
|
+
}]
|
89
|
+
}
|
90
|
+
}
|
91
|
+
end
|
92
|
+
|
93
|
+
def aws_data
|
94
|
+
@aws_data ||= AwsData.new
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
data/lib/codebuild/stack.rb
CHANGED
@@ -31,10 +31,13 @@ module Codebuild
|
|
31
31
|
@template["Resources"].merge!(project)
|
32
32
|
|
33
33
|
if project["CodeBuild"]["Properties"]["ServiceRole"] == {"Ref"=>"IamRole"}
|
34
|
-
role = Role.new(
|
34
|
+
role = Role.new(options).run
|
35
35
|
@template["Resources"].merge!(role)
|
36
36
|
end
|
37
37
|
|
38
|
+
schedule = Schedule.new(options).run
|
39
|
+
@template["Resources"].merge!(schedule) if schedule
|
40
|
+
|
38
41
|
template_path = "/tmp/codebuild.yml"
|
39
42
|
FileUtils.mkdir_p(File.dirname(template_path))
|
40
43
|
IO.write(template_path, YAML.dump(@template))
|
data/lib/codebuild/version.rb
CHANGED
data/lib/codebuild.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
$:.unshift(File.expand_path("../", __FILE__))
|
2
|
-
require "cfn_camelizer"
|
3
2
|
require "codebuild/version"
|
4
3
|
require "rainbow/ext/string"
|
5
4
|
require "yaml"
|
@@ -8,6 +7,10 @@ require "codebuild/autoloader"
|
|
8
7
|
Codebuild::Autoloader.setup
|
9
8
|
|
10
9
|
gem_root = File.dirname(__dir__)
|
10
|
+
$:.unshift("#{gem_root}/vendor/aws_data/lib")
|
11
|
+
require "aws_data"
|
12
|
+
$:.unshift("#{gem_root}/vendor/cfn_camelizer/lib")
|
13
|
+
require "cfn_camelizer"
|
11
14
|
$:.unshift("#{gem_root}/vendor/cfn-status/lib")
|
12
15
|
require "cfn/status"
|
13
16
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
base:
|
2
|
+
# stack_naming:
|
3
|
+
# append_env: false # default true
|
4
|
+
|
5
|
+
development:
|
6
|
+
# cluster: development
|
7
|
+
# The aws_profile tightly binds CB_ENV to AWS_PROFILE and vice-versa.
|
8
|
+
# aws_profile: dev_profile
|
9
|
+
|
10
|
+
production:
|
11
|
+
# cluster: production
|
12
|
+
# The aws_profile tightly binds CB_ENV to AWS_PROFILE and vice-versa.
|
13
|
+
# aws_profile: prod_profile
|
@@ -0,0 +1 @@
|
|
1
|
+
rate("1 day")
|
@@ -0,0 +1,13 @@
|
|
1
|
+
base:
|
2
|
+
# stack_naming:
|
3
|
+
# append_env: false # default true
|
4
|
+
|
5
|
+
development:
|
6
|
+
# cluster: development
|
7
|
+
# The aws_profile tightly binds CB_ENV to AWS_PROFILE and vice-versa.
|
8
|
+
# aws_profile: dev_profile
|
9
|
+
|
10
|
+
production:
|
11
|
+
# cluster: production
|
12
|
+
# The aws_profile tightly binds CB_ENV to AWS_PROFILE and vice-versa.
|
13
|
+
# aws_profile: prod_profile
|
@@ -0,0 +1,12 @@
|
|
1
|
+
describe Codebuild::Schedule do
|
2
|
+
let(:schedule) do
|
3
|
+
Codebuild::Schedule.new(schedule_path: "spec/fixtures/app/.codebuild/schedule.rb")
|
4
|
+
end
|
5
|
+
context "general" do
|
6
|
+
it "builds up the template in memory" do
|
7
|
+
template = schedule.run
|
8
|
+
expect(template.keys).to eq ["EventsRule", "EventsRuleRole"]
|
9
|
+
expect(template["EventsRule"]).to be_a(Hash)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codebuild
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: memoist
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: rainbow
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
@@ -95,7 +95,7 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: render_me_pretty
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: thor
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
@@ -123,7 +123,7 @@ dependencies:
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
126
|
+
name: zeitwerk
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - ">="
|
@@ -228,6 +228,11 @@ files:
|
|
228
228
|
- README.md
|
229
229
|
- Rakefile
|
230
230
|
- codebuild.gemspec
|
231
|
+
- docs/dsl/project.md
|
232
|
+
- docs/dsl/role.md
|
233
|
+
- docs/dsl/schedule.md
|
234
|
+
- docs/github_oauth.md
|
235
|
+
- docs/type.md
|
231
236
|
- exe/cb
|
232
237
|
- exe/codebuild
|
233
238
|
- img/github-admin-settings-tab.png
|
@@ -248,6 +253,7 @@ files:
|
|
248
253
|
- lib/codebuild/dsl/project.rb
|
249
254
|
- lib/codebuild/dsl/project/ssm.rb
|
250
255
|
- lib/codebuild/dsl/role.rb
|
256
|
+
- lib/codebuild/dsl/schedule.rb
|
251
257
|
- lib/codebuild/evaluate.rb
|
252
258
|
- lib/codebuild/help.rb
|
253
259
|
- lib/codebuild/help/completion.md
|
@@ -258,6 +264,7 @@ files:
|
|
258
264
|
- lib/codebuild/init.rb
|
259
265
|
- lib/codebuild/project.rb
|
260
266
|
- lib/codebuild/role.rb
|
267
|
+
- lib/codebuild/schedule.rb
|
261
268
|
- lib/codebuild/sequence.rb
|
262
269
|
- lib/codebuild/setting.rb
|
263
270
|
- lib/codebuild/stack.rb
|
@@ -267,14 +274,15 @@ files:
|
|
267
274
|
- lib/template/.codebuild/buildspec.yml
|
268
275
|
- lib/template/.codebuild/project.rb.tt
|
269
276
|
- lib/template/.codebuild/role.rb
|
270
|
-
-
|
271
|
-
- readme/github_oauth.md
|
272
|
-
- readme/type.md
|
277
|
+
- lib/template/.codebuild/settings.yml
|
273
278
|
- spec/fixtures/app/.codebuild/project.rb
|
274
279
|
- spec/fixtures/app/.codebuild/role.rb
|
280
|
+
- spec/fixtures/app/.codebuild/schedule.rb
|
281
|
+
- spec/fixtures/app/.codebuild/settings.yml
|
275
282
|
- spec/lib/cli_spec.rb
|
276
283
|
- spec/lib/project_spec.rb
|
277
284
|
- spec/lib/role_spec.rb
|
285
|
+
- spec/lib/schedule_spec.rb
|
278
286
|
- spec/spec_helper.rb
|
279
287
|
homepage: https://github.com/tongueroo/codebuild
|
280
288
|
licenses:
|
@@ -302,7 +310,10 @@ summary: CodeBuild DSL Tool to Quickly Create CodeBuild Project
|
|
302
310
|
test_files:
|
303
311
|
- spec/fixtures/app/.codebuild/project.rb
|
304
312
|
- spec/fixtures/app/.codebuild/role.rb
|
313
|
+
- spec/fixtures/app/.codebuild/schedule.rb
|
314
|
+
- spec/fixtures/app/.codebuild/settings.yml
|
305
315
|
- spec/lib/cli_spec.rb
|
306
316
|
- spec/lib/project_spec.rb
|
307
317
|
- spec/lib/role_spec.rb
|
318
|
+
- spec/lib/schedule_spec.rb
|
308
319
|
- spec/spec_helper.rb
|