lono 6.0.0 → 6.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +6 -6
- data/lib/lono/cfn.rb +5 -4
- data/lib/lono/param/generator.rb +2 -2
- data/lib/lono/template/context.rb +2 -1
- data/lib/lono/template/context/loader.rb +23 -5
- data/lib/lono/template/dsl/builder.rb +0 -3
- data/lib/lono/template/dsl/builder/resource.rb +1 -1
- data/lib/lono/template/dsl/builder/section_methods.rb +57 -0
- data/lib/lono/template/dsl/builder/syntax.rb +5 -53
- data/lib/lono/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffc3d416a358f6676a11c46731c18dff4c2eb1220ec68dce304e4e570e19dca0
|
4
|
+
data.tar.gz: 03a5e764bb8f66582d909fef1f5c32274e1a1105d4c3627a0834bb1316f0b2f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cf2ee72d6d80f0be84171139b45855d167012e28c54a262c5f7954941d577958d7cb600aecffc9fc446c8b5b4f1f873750ff8511eafc84197b875e9758952af
|
7
|
+
data.tar.gz: fdb40125279f0e67eea4e5abda5e445febfd3ce26ae427070f850955b794206c83f58e311778a6febb60ebba20ff6472afd3fae77609f7339402a15d4fb96bd9
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,11 @@
|
|
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
|
+
## [6.0.1]
|
7
|
+
- #14 restructure dsl methods are available in variables definition
|
8
|
+
- #15 fix Type camelize bug
|
9
|
+
- #16 add --variable option, allow user to specify
|
10
|
+
|
6
11
|
## [6.0.0]
|
7
12
|
- #13 DSL improvements: auto camelize off by default
|
8
13
|
- `auto_camelize: off` as new default for blueprints.
|
data/README.md
CHANGED
@@ -43,15 +43,15 @@ description "Demo stack"
|
|
43
43
|
parameter("InstanceType", "t3.micro")
|
44
44
|
|
45
45
|
mapping("AmiMap",
|
46
|
-
"us-east-1": {
|
47
|
-
"us-west-2": {
|
46
|
+
"us-east-1": { Ami: "ami-0de53d8956e8dcf80" },
|
47
|
+
"us-west-2": { Ami: "ami-061392db613a6357b" }
|
48
48
|
)
|
49
49
|
|
50
50
|
resource("Instance", "AWS::EC2::Instance",
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
51
|
+
InstanceType: ref("InstanceType"),
|
52
|
+
ImageId: find_in_map("AmiMap", ref("AWS::Region"), "Ami"),
|
53
|
+
SecurityGroupIds: [get_att("SecurityGroup.GroupId")],
|
54
|
+
UserData: base64(user_data("bootstrap.sh"))
|
55
55
|
)
|
56
56
|
resource("SecurityGroup", "AWS::EC2::SecurityGroup",
|
57
57
|
group_description: "demo security group",
|
data/lib/lono/cfn.rb
CHANGED
@@ -4,15 +4,16 @@ module Lono
|
|
4
4
|
class_option :noop, type: :boolean
|
5
5
|
|
6
6
|
base_options = Proc.new do
|
7
|
-
# common to create and
|
7
|
+
# common to create, update and deploy
|
8
8
|
option :blueprint, desc: "override convention and specify the template file to use"
|
9
|
-
option :template, desc: "override convention and specify the template file to use"
|
10
|
-
option :param, desc: "override convention and specify the param file to use"
|
11
|
-
option :lono, type: :boolean, desc: "invoke lono to generate CloudFormation templates", default: true
|
12
9
|
option :capabilities, type: :array, desc: "iam capabilities. Ex: CAPABILITY_IAM, CAPABILITY_NAMED_IAM"
|
13
10
|
option :iam, type: :boolean, desc: "Shortcut for common IAM capabilities: CAPABILITY_IAM, CAPABILITY_NAMED_IAM"
|
11
|
+
option :lono, type: :boolean, desc: "invoke lono to generate CloudFormation templates", default: true
|
12
|
+
option :param, desc: "override convention and specify the param file to use"
|
14
13
|
option :rollback, type: :boolean, desc: "rollback", default: true
|
15
14
|
option :tags, type: :hash, desc: "Tags for the stack. IE: name:api-web owner:bob"
|
15
|
+
option :template, desc: "override convention and specify the template file to use"
|
16
|
+
option :variable, desc: "override convention and specify the variable file to use"
|
16
17
|
end
|
17
18
|
wait_option = Proc.new do
|
18
19
|
option :wait, type: :boolean, desc: "Wait for stack operation to complete.", default: true
|
data/lib/lono/param/generator.rb
CHANGED
@@ -37,7 +37,7 @@ class Lono::Param
|
|
37
37
|
medium_form = "#{root}/configs/#{@blueprint}/params/#{env}/#{@param}"
|
38
38
|
short_form = "#{root}/configs/#{@blueprint}/params/#{env}"
|
39
39
|
|
40
|
-
if ENV['
|
40
|
+
if ENV['LONO_DEBUG_PARAM']
|
41
41
|
puts "Lono.blueprint_root #{Lono.blueprint_root}"
|
42
42
|
puts "direct_absolute_form #{direct_absolute_form}"
|
43
43
|
puts "direct_relative_form #{direct_relative_form}"
|
@@ -87,7 +87,7 @@ class Lono::Param
|
|
87
87
|
@base_path = lookup_param_file(env: "base")
|
88
88
|
@env_path = lookup_param_file(env: Lono.env)
|
89
89
|
|
90
|
-
if ENV['
|
90
|
+
if ENV['LONO_DEBUG_PARAM']
|
91
91
|
puts " @base_path #{@base_path.inspect}"
|
92
92
|
puts " @env_path #{@env_path.inspect}"
|
93
93
|
end
|
@@ -8,14 +8,32 @@ class Lono::Template::Context
|
|
8
8
|
# config/variables/development.rb - will override any variables in base.rb
|
9
9
|
#
|
10
10
|
def load_variables
|
11
|
-
load_variables_file(blueprint_path("base"))
|
12
|
-
load_variables_file(blueprint_path(Lono.env))
|
13
11
|
load_variables_file(project_path("base"))
|
14
|
-
|
12
|
+
|
13
|
+
direct_absolute_form = @options[:variable] # user provided the absolute full path
|
14
|
+
direct_relative_form = "#{Lono.root}/configs/#{@blueprint}/variables/#{@options[:variable]}" # user provided the full path within the lono project
|
15
|
+
conventional_form = project_path(Lono.env)
|
16
|
+
|
17
|
+
if ENV['LONO_DEBUG_VARIABLE']
|
18
|
+
puts "direct_absolute_form: #{direct_absolute_form.inspect}"
|
19
|
+
puts "direct_relative_form: #{direct_relative_form.inspect}"
|
20
|
+
puts "conventional_form: #{conventional_form.inspect}"
|
21
|
+
end
|
22
|
+
|
23
|
+
load_variables_file(variable_file(direct_absolute_form)) if variable_file?(direct_absolute_form)
|
24
|
+
load_variables_file(variable_file(direct_relative_form)) if variable_file?(direct_relative_form)
|
25
|
+
load_variables_file(conventional_form) if variable_file?(conventional_form)
|
26
|
+
end
|
27
|
+
|
28
|
+
def variable_file?(path)
|
29
|
+
return if path.nil?
|
30
|
+
return path if File.file?(path) # direct lookup with .rb extension
|
31
|
+
return "#{path}.rb" if File.file?("#{path}.rb") # direct lookup without .rb extension
|
15
32
|
end
|
16
33
|
|
17
|
-
def
|
18
|
-
|
34
|
+
def variable_file(path)
|
35
|
+
return path if File.file?(path)
|
36
|
+
return "#{path}.rb" if File.file?("#{path}.rb")
|
19
37
|
end
|
20
38
|
|
21
39
|
def project_path(name)
|
@@ -21,7 +21,7 @@ class Lono::Template::Dsl::Builder
|
|
21
21
|
elsif definition.size == 2 && second.is_a?(String) # short form with no properties
|
22
22
|
logical_id, type = first, second
|
23
23
|
{ logical_id => {
|
24
|
-
|
24
|
+
Type: type
|
25
25
|
}}
|
26
26
|
elsif definition.size == 3 && (second.is_a?(String) || second.is_a?(NilClass)) # short form
|
27
27
|
logical_id, type, properties = first, second, third
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# Organize core section method syntax here
|
2
|
+
class Lono::Template::Dsl::Builder
|
3
|
+
module SectionMethods
|
4
|
+
def aws_template_format_version(version_date)
|
5
|
+
@cfn["AWSTemplateFormatVersion"] = version_date
|
6
|
+
end
|
7
|
+
|
8
|
+
def description(text)
|
9
|
+
@cfn["Description"] = text
|
10
|
+
end
|
11
|
+
|
12
|
+
def metadata(data)
|
13
|
+
@cfn["Metadata"] = data
|
14
|
+
end
|
15
|
+
|
16
|
+
def transform(*definition)
|
17
|
+
definition = definition.flatten
|
18
|
+
@cfn["Transform"] = definition.size == 1 ? definition.first : definition
|
19
|
+
end
|
20
|
+
|
21
|
+
def parameter(*definition)
|
22
|
+
@cfn["Parameters"] ||= {}
|
23
|
+
param = Parameter.new(@blueprint, definition)
|
24
|
+
@cfn["Parameters"].merge!(param.template)
|
25
|
+
end
|
26
|
+
|
27
|
+
def mapping(*definition)
|
28
|
+
@cfn["Mappings"] ||= {}
|
29
|
+
mapping = Mapping.new(@blueprint, definition)
|
30
|
+
@cfn["Mappings"].merge!(mapping.template)
|
31
|
+
end
|
32
|
+
|
33
|
+
def resource(*definition)
|
34
|
+
@cfn["Resources"] ||= {}
|
35
|
+
resource = Resource.new(@blueprint, definition)
|
36
|
+
@cfn["Resources"].merge!(resource.template)
|
37
|
+
end
|
38
|
+
|
39
|
+
def condition(*definition)
|
40
|
+
@cfn["Conditions"] ||= {}
|
41
|
+
condition = Condition.new(@blueprint, definition)
|
42
|
+
@cfn["Conditions"].merge!(condition.template)
|
43
|
+
end
|
44
|
+
|
45
|
+
def output(*definition)
|
46
|
+
@cfn["Outputs"] ||= {}
|
47
|
+
output = Output.new(@blueprint, definition)
|
48
|
+
@cfn["Outputs"].merge!(output.template)
|
49
|
+
end
|
50
|
+
|
51
|
+
# Generic section method in case CloudFormation adds a new future section.
|
52
|
+
# The generic section method adds a new top-level key
|
53
|
+
def section(key, definition)
|
54
|
+
@cfn[key] = Section.new(@blueprint, definition).template
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -1,57 +1,9 @@
|
|
1
|
-
#
|
1
|
+
# Encapsulates syntax methods so they can be included in both the Builder and Context scope
|
2
2
|
class Lono::Template::Dsl::Builder
|
3
3
|
module Syntax
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
def description(text)
|
9
|
-
@cfn["Description"] = text
|
10
|
-
end
|
11
|
-
|
12
|
-
def metadata(data)
|
13
|
-
@cfn["Metadata"] = data
|
14
|
-
end
|
15
|
-
|
16
|
-
def transform(*definition)
|
17
|
-
definition = definition.flatten
|
18
|
-
@cfn["Transform"] = definition.size == 1 ? definition.first : definition
|
19
|
-
end
|
20
|
-
|
21
|
-
def parameter(*definition)
|
22
|
-
@cfn["Parameters"] ||= {}
|
23
|
-
param = Parameter.new(@blueprint, definition)
|
24
|
-
@cfn["Parameters"].merge!(param.template)
|
25
|
-
end
|
26
|
-
|
27
|
-
def mapping(*definition)
|
28
|
-
@cfn["Mappings"] ||= {}
|
29
|
-
mapping = Mapping.new(@blueprint, definition)
|
30
|
-
@cfn["Mappings"].merge!(mapping.template)
|
31
|
-
end
|
32
|
-
|
33
|
-
def resource(*definition)
|
34
|
-
@cfn["Resources"] ||= {}
|
35
|
-
resource = Resource.new(@blueprint, definition)
|
36
|
-
@cfn["Resources"].merge!(resource.template)
|
37
|
-
end
|
38
|
-
|
39
|
-
def condition(*definition)
|
40
|
-
@cfn["Conditions"] ||= {}
|
41
|
-
condition = Condition.new(@blueprint, definition)
|
42
|
-
@cfn["Conditions"].merge!(condition.template)
|
43
|
-
end
|
44
|
-
|
45
|
-
def output(*definition)
|
46
|
-
@cfn["Outputs"] ||= {}
|
47
|
-
output = Output.new(@blueprint, definition)
|
48
|
-
@cfn["Outputs"].merge!(output.template)
|
49
|
-
end
|
50
|
-
|
51
|
-
# Generic section method in case CloudFormation adds a new future section.
|
52
|
-
# The generic section method adds a new top-level key
|
53
|
-
def section(key, definition)
|
54
|
-
@cfn[key] = Section.new(@blueprint, definition).template
|
55
|
-
end
|
4
|
+
include Fn
|
5
|
+
include Helpers # built-in helpers
|
6
|
+
include Lono::Template::Evaluate
|
7
|
+
include SectionMethods
|
56
8
|
end
|
57
9
|
end
|
data/lib/lono/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lono
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.
|
4
|
+
version: 6.0.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: 2019-
|
11
|
+
date: 2019-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -562,6 +562,7 @@ files:
|
|
562
562
|
- lib/lono/template/dsl/builder/resource.rb
|
563
563
|
- lib/lono/template/dsl/builder/resource/property_mover.rb
|
564
564
|
- lib/lono/template/dsl/builder/section.rb
|
565
|
+
- lib/lono/template/dsl/builder/section_methods.rb
|
565
566
|
- lib/lono/template/dsl/builder/syntax.rb
|
566
567
|
- lib/lono/template/erb.rb
|
567
568
|
- lib/lono/template/evaluate.rb
|