lono 6.0.0 → 6.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 277fec8b235735156d549bc309cebad6c7277eaf102ef4ac7d242d0af610c54a
4
- data.tar.gz: 80239ae154cbd2de9ad4730fbcdccbc2b746654db65935f84ed1293a776c76be
3
+ metadata.gz: ffc3d416a358f6676a11c46731c18dff4c2eb1220ec68dce304e4e570e19dca0
4
+ data.tar.gz: 03a5e764bb8f66582d909fef1f5c32274e1a1105d4c3627a0834bb1316f0b2f4
5
5
  SHA512:
6
- metadata.gz: 937af6ff08ea6e36ad6cb785f50665f3e50d9c45b90fcaa2dd4e09771824791cd7ea7cb9b1816dfaff6bd7a188824a9d4d30fbac93ccdafc508f79b17d9c2b8e
7
- data.tar.gz: 16b40f4b8ddae0d6de37992ab7f8f673622d6a3097bec434db90cec0951386be2f96ddb6bd41d22758a5b3fef44d3bc8ee84672fe4623f97db53bef9e82302e0
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": { ami: "ami-0de53d8956e8dcf80" },
47
- "us-west-2": { ami: "ami-061392db613a6357b" }
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
- instance_type: ref("InstanceType"),
52
- image_id: find_in_map("AmiMap", ref("AWS::Region"), :ami),
53
- security_group_ids: [get_att("SecurityGroup.GroupId")],
54
- user_data: base64(user_data("bootstrap.sh"))
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 update
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
@@ -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['LONO_PARAM_DEBUG']
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['LONO_PARAM_DEBUG']
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
@@ -4,7 +4,8 @@ class Lono::Template
4
4
  extend Memoist
5
5
  include Lono::Template::Helper
6
6
  include Loader
7
- include Helpers
7
+ include Helpers # ERB
8
+ include Dsl::Builder::Syntax # DSL
8
9
 
9
10
  def initialize(blueprint, options={})
10
11
  @blueprint, @options = blueprint, options
@@ -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
- load_variables_file(project_path(Lono.env))
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 blueprint_path(name)
18
- "#{Lono.blueprint_root}/config/variables/#{name}.rb"
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)
@@ -3,9 +3,6 @@ class Lono::Template::Dsl
3
3
  include Lono::Template::Util
4
4
  include Lono::Template::Context::Loader
5
5
 
6
- include Fn
7
- include Helpers # built-in helpers
8
- include Lono::Template::Evaluate
9
6
  include Syntax
10
7
  extend Memoist
11
8
 
@@ -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
- type: type
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
- # Organize core syntax here
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
- 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
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
@@ -1,3 +1,3 @@
1
1
  module Lono
2
- VERSION = "6.0.0"
2
+ VERSION = "6.0.1"
3
3
  end
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.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-30 00:00:00.000000000 Z
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