cody 1.0.6 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +1 -0
- data/CHANGELOG.md +12 -0
- data/cody.gemspec +1 -0
- data/lib/cody/autoloader.rb +3 -1
- data/lib/cody/cli.rb +1 -1
- data/lib/cody/dsl/base.rb +2 -1
- data/lib/cody/dsl/role/registry.rb +25 -0
- data/lib/cody/dsl/role.rb +14 -6
- data/lib/cody/evaluate.rb +1 -40
- data/lib/cody/project.rb +1 -1
- data/lib/cody/role.rb +9 -2
- data/lib/cody/schedule.rb +1 -1
- data/lib/cody/stack/base.rb +2 -4
- data/lib/cody/stack/status.rb +7 -0
- data/lib/cody/stack.rb +1 -0
- data/lib/cody/version.rb +1 -1
- data/lib/cody.rb +3 -2
- metadata +20 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ee7a26eb0ccb0b5c2b745983fcf98d35d5c1e921fb7d2623cc3be533d5cce2a
|
4
|
+
data.tar.gz: 406a89def1acc38cb62cce043650d856f495c892c3a390653debe7993e2976d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae13df30790a0d64fa255b13ebd60acb9d3e609d9a87e17205df9b69508e2c96097c31e1f81d3b2060a03b303409e731e16cd5c6c433dbef0562aee7ec081e88
|
7
|
+
data.tar.gz: bfd5847d7f804a35fc2c7cba29f64e7d661893d7ab079f0d0a371f3e2fa4fee4f337851cecf4fdfedb6a5e6ed88ec7eb7d7d17ca8ce0de81176ac0057690f24e
|
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
github: boltops-tools
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,18 @@
|
|
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
|
+
## [1.2.1] - 2023-11-22
|
7
|
+
- Actually include changes from 1.2.0
|
8
|
+
|
9
|
+
## [1.2.0] - 2023-11-22
|
10
|
+
- [#35](https://github.com/tongueroo/cody/pull/35) fix eager load by specifying do not eager load for template files
|
11
|
+
- add github funding
|
12
|
+
|
13
|
+
## [1.1.0] - 2022-03-03
|
14
|
+
- [#33](https://github.com/tongueroo/cody/pull/33) fix cfn status when auto deleting rollback completed stack
|
15
|
+
- [#34](https://github.com/tongueroo/cody/pull/34) iam roles: support multiple calls
|
16
|
+
- update iam role docs
|
17
|
+
|
6
18
|
## [1.0.6] - 2021-12-17
|
7
19
|
- [#32](https://github.com/tongueroo/cody/pull/32) fix activesupport require
|
8
20
|
- fix warn not found ssm param message
|
data/cody.gemspec
CHANGED
@@ -32,6 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_dependency "cfn-status"
|
33
33
|
spec.add_dependency "cfn_camelizer"
|
34
34
|
spec.add_dependency "cli-format"
|
35
|
+
spec.add_dependency "dsl_evaluator"
|
35
36
|
spec.add_dependency "memoist"
|
36
37
|
spec.add_dependency "rainbow"
|
37
38
|
spec.add_dependency "render_me_pretty"
|
data/lib/cody/autoloader.rb
CHANGED
@@ -13,7 +13,9 @@ module Cody
|
|
13
13
|
def setup
|
14
14
|
loader = Zeitwerk::Loader.new
|
15
15
|
loader.inflector = Inflector.new
|
16
|
-
|
16
|
+
lib = File.dirname(__dir__) # lib
|
17
|
+
loader.push_dir(lib)
|
18
|
+
loader.do_not_eager_load("#{lib}/template")
|
17
19
|
loader.setup
|
18
20
|
end
|
19
21
|
end
|
data/lib/cody/cli.rb
CHANGED
@@ -37,7 +37,7 @@ module Cody
|
|
37
37
|
long_desc Help.text(:start)
|
38
38
|
option :source_version, default: "master", desc: "git branch"
|
39
39
|
option :branch, aliases: "b", default: "master", desc: "git branch"
|
40
|
-
option :env_vars, type: :array, desc: "env var overrides. IE: KEY1=VALUE1 KEY2=VALUE2"
|
40
|
+
option :env_vars, aliases: "e", type: :array, desc: "env var overrides. IE: KEY1=VALUE1 KEY2=VALUE2"
|
41
41
|
common_options.call
|
42
42
|
def start(project_name=nil)
|
43
43
|
Start.new(options.merge(project_name: project_name)).run
|
data/lib/cody/dsl/base.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
module Cody::Dsl
|
2
2
|
class Base
|
3
|
-
attr_reader :project_name, :full_project_name
|
3
|
+
attr_reader :options, :project_name, :full_project_name, :type
|
4
4
|
def initialize(options={})
|
5
5
|
@options = options
|
6
6
|
@project_name = options[:project_name]
|
7
|
+
@type = options[:type]
|
7
8
|
@full_project_name = options[:full_project_name] # includes -development at the end
|
8
9
|
@properties = default_properties # defaults make project.rb simpler
|
9
10
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "set"
|
2
|
+
|
3
|
+
module Cody::Dsl::Role
|
4
|
+
class Registry
|
5
|
+
class_attribute :iam_statements
|
6
|
+
self.iam_statements = nil # nil to allow fallback to default_iam_statements in cody/role.rb
|
7
|
+
class_attribute :managed_policy_arns
|
8
|
+
self.managed_policy_arns = nil # nil to allow fallback to default_managed_policy_arns in cody/role.rb
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def register_policy(*statements)
|
12
|
+
statements.flatten!
|
13
|
+
self.iam_statements ||= []
|
14
|
+
self.iam_statements += statements # using set so DSL can safely be evaluated multiple times
|
15
|
+
end
|
16
|
+
|
17
|
+
def register_managed_policy(*policies)
|
18
|
+
policies.flatten!
|
19
|
+
self.managed_policy_arns ||= []
|
20
|
+
self.managed_policy_arns += policies # using set so DSL can safely be evaluated multiple times
|
21
|
+
self.managed_policy_arns.uniq!
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/cody/dsl/role.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Cody::Dsl
|
2
2
|
module Role
|
3
|
+
extend Memoist
|
4
|
+
|
3
5
|
PROPERTIES = %w[
|
4
6
|
AssumeRolePolicyDocument
|
5
7
|
ManagedPolicyArns
|
@@ -17,7 +19,13 @@ module Cody::Dsl
|
|
17
19
|
|
18
20
|
# convenience wrapper methods
|
19
21
|
def iam_policy(*definitions)
|
20
|
-
|
22
|
+
statements = definitions.map { |definition| standardize_iam_policy(definition) }
|
23
|
+
Registry.register_policy(statements)
|
24
|
+
end
|
25
|
+
|
26
|
+
def managed_iam_policy(*definitions)
|
27
|
+
managed_policy_arns = definitions.map { |definition| standardize_managed_iam_policy(definition) }
|
28
|
+
Registry.register_managed_policy(managed_policy_arns)
|
21
29
|
end
|
22
30
|
|
23
31
|
# Returns standarized IAM statement
|
@@ -36,15 +44,15 @@ module Cody::Dsl
|
|
36
44
|
end
|
37
45
|
end
|
38
46
|
|
39
|
-
def managed_iam_policy(*definitions)
|
40
|
-
@managed_policy_arns = definitions.map { |definition| standardize_managed_iam_policy(definition) }
|
41
|
-
end
|
42
|
-
|
43
47
|
# AmazonEC2ReadOnlyAccess => arn:aws:iam::aws:policy/AmazonEC2ReadOnlyAccess
|
44
48
|
def standardize_managed_iam_policy(definition)
|
45
49
|
return definition if definition.include?('iam::aws:policy')
|
46
|
-
|
47
50
|
"arn:aws:iam::aws:policy/#{definition}"
|
48
51
|
end
|
52
|
+
|
53
|
+
def aws
|
54
|
+
AwsData.new
|
55
|
+
end
|
56
|
+
memoize :aws
|
49
57
|
end
|
50
58
|
end
|
data/lib/cody/evaluate.rb
CHANGED
@@ -1,47 +1,8 @@
|
|
1
1
|
module Cody
|
2
2
|
module Evaluate
|
3
|
+
include DslEvaluator
|
3
4
|
include Interface
|
4
5
|
|
5
|
-
def evaluate(path)
|
6
|
-
source_code = IO.read(path)
|
7
|
-
begin
|
8
|
-
instance_eval(source_code, path)
|
9
|
-
rescue Exception => e
|
10
|
-
if e.class == SystemExit # allow exit to happen normally
|
11
|
-
raise
|
12
|
-
else
|
13
|
-
task_definition_error(e)
|
14
|
-
puts "\nFull error:"
|
15
|
-
raise
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
# Prints out a user friendly task_definition error message
|
22
|
-
def task_definition_error(e)
|
23
|
-
error_info = e.backtrace.first
|
24
|
-
path, line_no, _ = error_info.split(':')
|
25
|
-
line_no = line_no.to_i
|
26
|
-
puts "Error evaluating #{path}:".color(:red)
|
27
|
-
puts e.message
|
28
|
-
puts "Here's the line in #{path} with the error:\n\n"
|
29
|
-
|
30
|
-
contents = IO.read(path)
|
31
|
-
content_lines = contents.split("\n")
|
32
|
-
context = 5 # lines of context
|
33
|
-
top, bottom = [line_no-context-1, 0].max, line_no+context-1
|
34
|
-
spacing = content_lines.size.to_s.size
|
35
|
-
content_lines[top..bottom].each_with_index do |line_content, index|
|
36
|
-
line_number = top+index+1
|
37
|
-
if line_number == line_no
|
38
|
-
printf("%#{spacing}d %s\n".color(:red), line_number, line_content)
|
39
|
-
else
|
40
|
-
printf("%#{spacing}d %s\n", line_number, line_content)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
6
|
def lookup_cody_file(name)
|
46
7
|
[".cody", @options[:type], name].compact.join("/")
|
47
8
|
end
|
data/lib/cody/project.rb
CHANGED
data/lib/cody/role.rb
CHANGED
@@ -2,9 +2,9 @@ require "yaml"
|
|
2
2
|
|
3
3
|
module Cody
|
4
4
|
class Role < Dsl::Base
|
5
|
-
include Cody::Dsl::Role
|
6
5
|
include Evaluate
|
7
6
|
include Variables
|
7
|
+
include Dsl::Role
|
8
8
|
|
9
9
|
def initialize(options={})
|
10
10
|
super
|
@@ -14,7 +14,8 @@ module Cody
|
|
14
14
|
|
15
15
|
def run
|
16
16
|
load_variables
|
17
|
-
|
17
|
+
evaluate_file(@role_path) if File.exist?(@role_path) # registers definitions to registry
|
18
|
+
build # build definitions from registry. can set: @iam_statements and @managed_policy_arns
|
18
19
|
@properties[:Policies] = [{
|
19
20
|
PolicyName: "CodeBuildAccess",
|
20
21
|
PolicyDocument: {
|
@@ -35,6 +36,12 @@ module Cody
|
|
35
36
|
end
|
36
37
|
|
37
38
|
private
|
39
|
+
Registry = Cody::Dsl::Role::Registry
|
40
|
+
def build
|
41
|
+
@iam_statements = Registry.iam_statements if Registry.iam_statements
|
42
|
+
@managed_policy_arns = Registry.managed_policy_arns if Registry.managed_policy_arns
|
43
|
+
end
|
44
|
+
|
38
45
|
def get_role_path
|
39
46
|
lookup_cody_file("role.rb")
|
40
47
|
end
|
data/lib/cody/schedule.rb
CHANGED
data/lib/cody/stack/base.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
class Cody::Stack
|
2
2
|
class Base
|
3
3
|
include Cody::AwsServices
|
4
|
+
include Status
|
4
5
|
|
5
6
|
def initialize(options)
|
6
7
|
@options = options
|
@@ -40,6 +41,7 @@ class Cody::Stack
|
|
40
41
|
FileUtils.mkdir_p(File.dirname(template_path))
|
41
42
|
IO.write(template_path, YAML.dump(@template))
|
42
43
|
puts "Generated CloudFormation template at #{template_path.color(:green)}"
|
44
|
+
|
43
45
|
return if @options[:noop]
|
44
46
|
puts "Deploying stack #{@stack_name.color(:green)} with CodeBuild project #{@full_project_name.color(:green)}"
|
45
47
|
|
@@ -68,10 +70,6 @@ class Cody::Stack
|
|
68
70
|
puts "Here's the CloudFormation url to check for more details #{url}"
|
69
71
|
end
|
70
72
|
|
71
|
-
def status
|
72
|
-
@status ||= CfnStatus.new(@stack_name)
|
73
|
-
end
|
74
|
-
|
75
73
|
def rollback_complete?(stack)
|
76
74
|
stack.stack_status == 'ROLLBACK_COMPLETE'
|
77
75
|
end
|
data/lib/cody/stack.rb
CHANGED
data/lib/cody/version.rb
CHANGED
data/lib/cody.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
$:.unshift(File.expand_path("../", __FILE__))
|
2
|
-
require
|
3
|
-
require
|
2
|
+
require "active_support"
|
3
|
+
require "active_support/core_ext/string"
|
4
4
|
require "aws_data"
|
5
5
|
require "cfn_camelizer"
|
6
6
|
require "cfn_status"
|
7
7
|
require "cody/version"
|
8
|
+
require "dsl_evaluator"
|
8
9
|
require "memoist"
|
9
10
|
require "rainbow/ext/string"
|
10
11
|
require "yaml"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cody
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -150,6 +150,20 @@ dependencies:
|
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: dsl_evaluator
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :runtime
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
168
|
name: memoist
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -316,6 +330,7 @@ files:
|
|
316
330
|
- ".cody/project.rb"
|
317
331
|
- ".cody/role.rb"
|
318
332
|
- ".cody/settings.yml"
|
333
|
+
- ".github/FUNDING.yml"
|
319
334
|
- ".gitignore"
|
320
335
|
- ".gitmodules"
|
321
336
|
- ".rspec"
|
@@ -357,6 +372,7 @@ files:
|
|
357
372
|
- lib/cody/dsl/project.rb
|
358
373
|
- lib/cody/dsl/project/ssm.rb
|
359
374
|
- lib/cody/dsl/role.rb
|
375
|
+
- lib/cody/dsl/role/registry.rb
|
360
376
|
- lib/cody/dsl/schedule.rb
|
361
377
|
- lib/cody/evaluate.rb
|
362
378
|
- lib/cody/evaluate/interface.rb
|
@@ -369,6 +385,7 @@ files:
|
|
369
385
|
- lib/cody/stack.rb
|
370
386
|
- lib/cody/stack/base.rb
|
371
387
|
- lib/cody/stack/create.rb
|
388
|
+
- lib/cody/stack/status.rb
|
372
389
|
- lib/cody/stack/update.rb
|
373
390
|
- lib/cody/tailer.rb
|
374
391
|
- lib/cody/variables.rb
|
@@ -401,7 +418,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
401
418
|
- !ruby/object:Gem::Version
|
402
419
|
version: '0'
|
403
420
|
requirements: []
|
404
|
-
rubygems_version: 3.
|
421
|
+
rubygems_version: 3.4.20
|
405
422
|
signing_key:
|
406
423
|
specification_version: 4
|
407
424
|
summary: Cody provides a beautiful DSL to create and manage AWS CodeBuild projects
|