lono 6.1.11 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (240) hide show
  1. checksums.yaml +4 -4
  2. data/.cody/acceptance.sh +19 -3
  3. data/.gitignore +2 -2
  4. data/CHANGELOG.md +16 -1
  5. data/README.md +18 -20
  6. data/Rakefile +1 -0
  7. data/lib/lono.rb +7 -5
  8. data/lib/lono/abstract_base.rb +25 -0
  9. data/lib/lono/api/client.rb +30 -0
  10. data/lib/lono/api/proxy.rb +58 -0
  11. data/lib/lono/api/repos.rb +8 -0
  12. data/lib/lono/api/verify.rb +13 -0
  13. data/lib/lono/app_file/base.rb +4 -11
  14. data/lib/lono/app_file/build.rb +1 -1
  15. data/lib/lono/app_file/upload.rb +1 -4
  16. data/lib/lono/autoloader.rb +3 -1
  17. data/lib/lono/aws_services.rb +9 -9
  18. data/lib/lono/aws_services/helper.rb +14 -0
  19. data/lib/lono/aws_services/{util.rb → stack.rb} +1 -9
  20. data/lib/lono/aws_services/stack_set.rb +41 -0
  21. data/lib/lono/blueprint.rb +2 -2
  22. data/lib/lono/blueprint/configset/loader.rb +7 -0
  23. data/lib/lono/blueprint/helper.rb +8 -2
  24. data/lib/lono/blueprint/meta.rb +4 -12
  25. data/lib/lono/blueprint/new.rb +3 -3
  26. data/lib/lono/blueprint/root.rb +6 -26
  27. data/lib/lono/bundle.rb +54 -0
  28. data/lib/lono/cfn.rb +31 -75
  29. data/lib/lono/cfn/base.rb +39 -136
  30. data/lib/lono/cfn/cancel.rb +14 -9
  31. data/lib/lono/cfn/create.rb +15 -19
  32. data/lib/lono/cfn/delete.rb +9 -9
  33. data/lib/lono/cfn/deploy.rb +4 -4
  34. data/lib/lono/cfn/download.rb +27 -9
  35. data/lib/lono/cfn/opts.rb +80 -0
  36. data/lib/lono/cfn/preview/changeset.rb +23 -23
  37. data/lib/lono/cfn/preview/codediff.rb +5 -6
  38. data/lib/lono/cfn/preview/param.rb +10 -10
  39. data/lib/lono/cfn/rollback.rb +5 -5
  40. data/lib/lono/cfn/status.rb +0 -10
  41. data/lib/lono/cfn/update.rb +22 -27
  42. data/lib/lono/clean.rb +3 -3
  43. data/lib/lono/cli.rb +69 -34
  44. data/lib/lono/code.rb +22 -0
  45. data/lib/lono/command.rb +7 -0
  46. data/lib/lono/config_location.rb +6 -13
  47. data/lib/lono/configset.rb +9 -0
  48. data/lib/lono/configset/combiner.rb +128 -0
  49. data/lib/lono/configset/evaluate_file.rb +8 -0
  50. data/lib/lono/configset/list.rb +67 -0
  51. data/lib/lono/configset/loader.rb +98 -0
  52. data/lib/lono/configset/loader/dsl.rb +9 -0
  53. data/lib/lono/configset/materializer/final.rb +10 -0
  54. data/lib/lono/configset/materializer/gems_builder.rb +81 -0
  55. data/lib/lono/configset/materializer/jade.rb +15 -0
  56. data/lib/lono/configset/materializer/source.rb +54 -0
  57. data/lib/lono/configset/meta.rb +19 -0
  58. data/lib/lono/configset/meta/dsl.rb +12 -0
  59. data/lib/lono/configset/new.rb +84 -0
  60. data/lib/lono/configset/preparer.rb +44 -0
  61. data/lib/lono/configset/register/base.rb +121 -0
  62. data/lib/lono/configset/register/blueprint.rb +16 -0
  63. data/lib/lono/configset/register/dsl.rb +15 -0
  64. data/lib/lono/configset/register/project.rb +12 -0
  65. data/lib/lono/configset/registry.rb +34 -0
  66. data/lib/lono/configset/resolver.rb +42 -0
  67. data/lib/lono/conventions.rb +18 -7
  68. data/lib/lono/core.rb +16 -20
  69. data/lib/lono/default/settings.yml +2 -3
  70. data/lib/lono/ext/bundler.rb +7 -0
  71. data/lib/lono/file_uploader.rb +8 -5
  72. data/lib/lono/finder/base.rb +140 -0
  73. data/lib/lono/finder/blueprint.rb +11 -0
  74. data/lib/lono/finder/blueprint/configset.rb +17 -0
  75. data/lib/lono/finder/configset.rb +11 -0
  76. data/lib/lono/generate.rb +93 -0
  77. data/lib/lono/help/blueprint/new.md +0 -1
  78. data/lib/lono/help/cfn/delete.md +1 -1
  79. data/lib/lono/help/cfn/deploy.md +5 -76
  80. data/lib/lono/help/cfn/status.md +0 -4
  81. data/lib/lono/help/cfn/update.md +1 -1
  82. data/lib/lono/help/code/convert.md +51 -0
  83. data/lib/lono/help/code/import.md +30 -0
  84. data/lib/lono/help/configsets.md +24 -0
  85. data/lib/lono/help/generate.md +4 -4
  86. data/lib/lono/help/new.md +1 -2
  87. data/lib/lono/help/sets/delete.md +8 -0
  88. data/lib/lono/help/sets/deploy.md +76 -0
  89. data/lib/lono/help/sets/instances/delete.md +21 -0
  90. data/lib/lono/help/sets/instances/list.md +14 -0
  91. data/lib/lono/help/sets/instances/status.md +15 -0
  92. data/lib/lono/help/sets/instances/sync.md +88 -0
  93. data/lib/lono/help/sets/status.md +23 -0
  94. data/lib/lono/help/upgrade.md +1 -0
  95. data/lib/lono/importer.rb +22 -0
  96. data/lib/lono/importer/base.rb +59 -0
  97. data/lib/lono/importer/converter.rb +19 -0
  98. data/lib/lono/importer/download.rb +46 -0
  99. data/lib/lono/importer/dsl.rb +36 -0
  100. data/lib/lono/importer/erb.rb +31 -0
  101. data/lib/lono/importer/params.rb +56 -0
  102. data/lib/lono/importer/service/coder.rb +81 -0
  103. data/lib/lono/inspector/base.rb +12 -22
  104. data/lib/lono/inspector/graph.rb +1 -1
  105. data/lib/lono/inspector/summary.rb +41 -17
  106. data/lib/lono/jade.rb +103 -0
  107. data/lib/lono/jade/circular.rb +26 -0
  108. data/lib/lono/jadespec.rb +41 -0
  109. data/lib/lono/new.rb +2 -2
  110. data/lib/lono/opts.rb +43 -0
  111. data/lib/lono/output/template.rb +48 -0
  112. data/lib/lono/param.rb +3 -5
  113. data/lib/lono/param/generator.rb +13 -33
  114. data/lib/lono/pro.rb +15 -0
  115. data/lib/lono/pro/base.rb +16 -0
  116. data/lib/lono/pro/repo.rb +27 -0
  117. data/lib/lono/project_checker.rb +4 -29
  118. data/lib/lono/registration.rb +15 -0
  119. data/lib/lono/registration/base.rb +37 -0
  120. data/lib/lono/registration/check.rb +15 -0
  121. data/lib/lono/registration/temp.rb +60 -0
  122. data/lib/lono/registration/user.rb +54 -0
  123. data/lib/lono/script/base.rb +1 -10
  124. data/lib/lono/script/upload.rb +2 -12
  125. data/lib/lono/seed.rb +2 -11
  126. data/lib/lono/seed/base.rb +55 -110
  127. data/lib/lono/sets.rb +38 -0
  128. data/lib/lono/sets/base.rb +45 -0
  129. data/lib/lono/sets/create.rb +30 -0
  130. data/lib/lono/sets/delete.rb +47 -0
  131. data/lib/lono/sets/deploy.rb +11 -0
  132. data/lib/lono/sets/instances.rb +33 -0
  133. data/lib/lono/sets/instances/base.rb +30 -0
  134. data/lib/lono/sets/instances/delete.rb +69 -0
  135. data/lib/lono/sets/instances/list.rb +13 -0
  136. data/lib/lono/sets/instances/opts.rb +29 -0
  137. data/lib/lono/sets/instances/status.rb +12 -0
  138. data/lib/lono/sets/instances/sync.rb +182 -0
  139. data/lib/lono/sets/list.rb +35 -0
  140. data/lib/lono/sets/opts.rb +18 -0
  141. data/lib/lono/sets/preview/codediff.rb +35 -0
  142. data/lib/lono/sets/preview/param.rb +32 -0
  143. data/lib/lono/sets/status.rb +116 -0
  144. data/lib/lono/sets/status/instance.rb +20 -0
  145. data/lib/lono/sets/status/instance/base.rb +120 -0
  146. data/lib/lono/sets/status/instance/completed.rb +35 -0
  147. data/lib/lono/sets/status/instance/deleted.rb +32 -0
  148. data/lib/lono/sets/status/instance/show.rb +7 -0
  149. data/lib/lono/sets/status/instances.rb +111 -0
  150. data/lib/lono/sets/summarize.rb +20 -0
  151. data/lib/lono/sets/time_spent.rb +11 -0
  152. data/lib/lono/sets/update.rb +81 -0
  153. data/lib/lono/template.rb +5 -7
  154. data/lib/lono/template/configset_injector.rb +50 -0
  155. data/lib/lono/template/context.rb +4 -4
  156. data/lib/lono/template/context/loader.rb +4 -16
  157. data/lib/lono/template/evaluate.rb +2 -1
  158. data/lib/lono/template/generator.rb +17 -15
  159. data/lib/lono/template/helper.rb +7 -7
  160. data/lib/lono/template/post_processor.rb +2 -12
  161. data/lib/lono/template/strategy/base.rb +4 -0
  162. data/lib/lono/template/{dsl.rb → strategy/dsl.rb} +4 -6
  163. data/lib/lono/template/{dsl → strategy/dsl}/builder.rb +11 -15
  164. data/lib/lono/template/{dsl → strategy/dsl}/builder/fn.rb +1 -1
  165. data/lib/lono/template/strategy/dsl/builder/helpers.rb +11 -0
  166. data/lib/lono/template/strategy/dsl/builder/helpers/core_helper.rb +14 -0
  167. data/lib/lono/template/strategy/dsl/builder/helpers/file_helper.rb +48 -0
  168. data/lib/lono/template/strategy/dsl/builder/helpers/lookup_helper.rb +27 -0
  169. data/lib/lono/template/strategy/dsl/builder/helpers/s3_helper.rb +13 -0
  170. data/lib/lono/template/strategy/dsl/builder/helpers/tags_helper.rb +39 -0
  171. data/lib/lono/template/{dsl/builder → strategy/dsl/builder/section}/base.rb +6 -17
  172. data/lib/lono/template/{dsl/builder → strategy/dsl/builder/section}/condition.rb +1 -1
  173. data/lib/lono/template/strategy/dsl/builder/section/extensions.rb +9 -0
  174. data/lib/lono/template/{dsl/builder → strategy/dsl/builder/section}/mapping.rb +1 -1
  175. data/lib/lono/template/{dsl/builder/section_methods.rb → strategy/dsl/builder/section/methods.rb} +9 -2
  176. data/lib/lono/template/{dsl/builder → strategy/dsl/builder/section}/output.rb +1 -1
  177. data/lib/lono/template/strategy/dsl/builder/section/parameter.rb +69 -0
  178. data/lib/lono/template/{dsl/builder → strategy/dsl/builder/section}/resource.rb +1 -1
  179. data/lib/lono/template/{dsl/builder → strategy/dsl/builder/section}/resource/property_mover.rb +1 -1
  180. data/lib/lono/template/{dsl/builder → strategy/dsl/builder/section}/section.rb +1 -1
  181. data/lib/lono/template/{dsl → strategy/dsl}/builder/squeezer.rb +1 -1
  182. data/lib/lono/template/strategy/dsl/builder/stringify.rb +15 -0
  183. data/lib/lono/template/{dsl → strategy/dsl}/builder/syntax.rb +3 -2
  184. data/lib/lono/template/strategy/dsl/finalizer.rb +12 -0
  185. data/lib/lono/template/strategy/dsl/finalizer/parameter_groups.rb +56 -0
  186. data/lib/lono/template/{erb.rb → strategy/erb.rb} +5 -5
  187. data/lib/lono/template/strategy/source.rb +8 -0
  188. data/lib/lono/template/template.rb +1 -1
  189. data/lib/lono/template/upload.rb +4 -9
  190. data/lib/lono/template/util.rb +0 -40
  191. data/lib/lono/upgrade.rb +12 -10
  192. data/lib/lono/user_data.rb +4 -4
  193. data/lib/lono/utils/pretty_time.rb +14 -0
  194. data/lib/lono/utils/sure.rb +23 -0
  195. data/lib/lono/version.rb +1 -1
  196. data/lib/lono/yamler/loader.rb +52 -0
  197. data/lib/lono/yamler/validator.rb +51 -0
  198. data/lib/templates/blueprint/%blueprint_name%.gemspec.tt +4 -0
  199. data/lib/templates/blueprint/README.md.tt +1 -1
  200. data/lib/templates/blueprint/seed/configs.rb +2 -2
  201. data/lib/templates/blueprint_types/dsl/app/templates/%blueprint_name%.rb +17 -18
  202. data/lib/templates/blueprint_types/erb/app/templates/%blueprint_name%.yml +63 -4
  203. data/lib/templates/configset/%configset_name%.gemspec.tt +41 -0
  204. data/lib/templates/configset/.gitignore +11 -0
  205. data/lib/templates/configset/CHANGELOG.md +7 -0
  206. data/lib/templates/configset/Gemfile +4 -0
  207. data/lib/templates/configset/README.md.tt +3 -0
  208. data/lib/templates/configset/Rakefile.tt +9 -0
  209. data/lib/templates/configset/lib/configset.yml +20 -0
  210. data/lib/templates/skeleton/.gitignore +1 -0
  211. data/lib/templates/skeleton/Gemfile +0 -1
  212. data/lib/templates/skeleton/README.md +4 -4
  213. data/lib/templates/skeleton/configs/settings.yml +1 -1
  214. data/lono.gemspec +1 -4
  215. metadata +146 -79
  216. data/Guardfile +0 -19
  217. data/lib/lono/app_file.rb +0 -5
  218. data/lib/lono/blueprint/find.rb +0 -90
  219. data/lib/lono/blueprint/info.rb +0 -10
  220. data/lib/lono/blueprint/list.rb +0 -14
  221. data/lib/lono/cfn/current.rb +0 -95
  222. data/lib/lono/cfn/preview.rb +0 -4
  223. data/lib/lono/cfn/suffix.rb +0 -67
  224. data/lib/lono/cfn/util.rb +0 -27
  225. data/lib/lono/help/cfn/current.md +0 -18
  226. data/lib/lono/help/upgrade4.md +0 -25
  227. data/lib/lono/inspector.rb +0 -4
  228. data/lib/lono/output_template.rb +0 -35
  229. data/lib/lono/template/base.rb +0 -13
  230. data/lib/lono/template/dsl/builder/helpers.rb +0 -8
  231. data/lib/lono/template/dsl/builder/helpers/core_helper.rb +0 -107
  232. data/lib/lono/template/dsl/builder/helpers/param_helper.rb +0 -61
  233. data/lib/lono/template/dsl/builder/parameter.rb +0 -39
  234. data/lib/lono/upgrade/upgrade4.rb +0 -175
  235. data/lib/lono/upgrade/upgrade42.rb +0 -36
  236. data/lib/lono/upgrade/upgrade5.rb +0 -55
  237. data/lib/templates/blueprint/.meta/config.yml.tt +0 -4
  238. data/lib/templates/skeleton/Guardfile +0 -12
  239. data/lib/templates/upgrade5/blueprints/main/.lono/config.yml +0 -3
  240. data/lib/templates/upgrade5/blueprints/main/.meta/config.yml +0 -3
@@ -1,9 +1,9 @@
1
- class Lono::Template
1
+ module Lono::Template::Strategy
2
2
  class Erb < Base
3
- include Evaluate
4
- include Util
3
+ include Lono::Template::Evaluate
4
+ include Lono::Template::Util
5
5
 
6
- def initialize(blueprint, options={})
6
+ def initialize(options={})
7
7
  super
8
8
  @templates = []
9
9
  @results = {}
@@ -67,7 +67,7 @@ class Lono::Template
67
67
  ensure_parent_dir(path)
68
68
  text = commented(text)
69
69
  IO.write(path, text) # write file first so validate method is simpler
70
- validate_yaml(path)
70
+ Lono::Yamler::Validator.new(path).validate!
71
71
  end
72
72
  end
73
73
 
@@ -0,0 +1,8 @@
1
+ module Lono::Template::Strategy
2
+ # url or path
3
+ class Source < Base
4
+ def run
5
+ Lono::Cfn::Download.new(@options).run
6
+ end
7
+ end
8
+ end
@@ -49,6 +49,6 @@ class Lono::Template::Template
49
49
  # Context for ERB rendering.
50
50
  # This is where we control what references get passed to the ERB rendering.
51
51
  def context
52
- @context ||= Lono::Template::Context.new(@blueprint, @options)
52
+ @context ||= Lono::Template::Context.new(@options)
53
53
  end
54
54
  end
@@ -4,16 +4,11 @@ require 'base64'
4
4
  require 'digest'
5
5
 
6
6
  class Lono::Template
7
- class Upload
8
- include Lono::Blueprint::Root
7
+ class Upload < Lono::AbstractBase
9
8
  include Lono::AwsServices
10
9
 
11
- def initialize(blueprint, options={})
12
- @blueprint, @options = blueprint, options
13
- @template = @options[:template] || @blueprint
14
- Lono::ProjectChecker.check
15
- set_blueprint_root(@blueprint)
16
-
10
+ def initialize(options={})
11
+ super
17
12
  @checksums = {}
18
13
  @prefix = Lono.env # s3://s3-bucket/development
19
14
  end
@@ -99,7 +94,7 @@ class Lono::Template
99
94
  "https://s3.amazonaws.com/#{s3_bucket}/#{@prefix}/#{template_path}"
100
95
  end
101
96
 
102
- # used for cfn/base.rb def set_template_body!(params)
97
+ # used for cfn/base.rb def set_template_url!(options)
103
98
  def s3_presigned_url(template_output_path)
104
99
  template_path = template_output_path.sub('output/templates/','')
105
100
  key = "#{@prefix}/#{template_path}"
@@ -4,45 +4,5 @@ class Lono::Template
4
4
  dir = File.dirname(path)
5
5
  FileUtils.mkdir_p(dir) unless File.exist?(dir)
6
6
  end
7
-
8
- def validate_yaml(path)
9
- text = IO.read(path)
10
- begin
11
- YAML.load(text)
12
- rescue Psych::SyntaxError => e
13
- handle_yaml_syntax_error(e, path)
14
- end
15
- end
16
-
17
- def handle_yaml_syntax_error(e, path)
18
- io = StringIO.new
19
- io.puts "Invalid yaml. Output written to debugging: #{path}".color(:red)
20
- io.puts "ERROR: #{e.message}".color(:red)
21
-
22
- # Grab line info. Example error:
23
- # ERROR: (<unknown>): could not find expected ':' while scanning a simple key at line 2 column 1
24
- md = e.message.match(/at line (\d+) column (\d+)/)
25
- line = md[1].to_i
26
-
27
- lines = IO.read(path).split("\n")
28
- context = 5 # lines of context
29
- top, bottom = [line-context-1, 0].max, line+context-1
30
- spacing = lines.size.to_s.size
31
- lines[top..bottom].each_with_index do |line_content, index|
32
- line_number = top+index+1
33
- if line_number == line
34
- io.printf("%#{spacing}d %s\n".color(:red), line_number, line_content)
35
- else
36
- io.printf("%#{spacing}d %s\n", line_number, line_content)
37
- end
38
- end
39
-
40
- if ENV['TEST']
41
- io.string
42
- else
43
- puts io.string
44
- exit 1
45
- end
46
- end
47
7
  end
48
8
  end
@@ -1,18 +1,20 @@
1
1
  module Lono
2
- class Upgrade < Command
3
- desc "v3to4", "Upgrade from version 3 to 4."
4
- def v3to4
5
- Upgrade4.new(options).run
2
+ class Upgrade
3
+ def initialize(options)
4
+ @options = options
6
5
  end
7
6
 
8
- desc "v4to4_2", "Upgrade from version 4.0 to 4.2"
9
- def v4to4_2
10
- Upgrade42.start
7
+ def run
8
+ app_blueprints_move # v6 to v7
9
+ puts "Lono project upgraded"
11
10
  end
12
11
 
13
- desc "v4to5", "Upgrade from version 4.2 to 5.0"
14
- def v4to5
15
- Upgrade5.start
12
+ def app_blueprints_move
13
+ return if File.exist?("#{Lono.root}/app/blueprints")
14
+ return unless File.exist?("#{Lono.root}/blueprints")
15
+
16
+ FileUtils.mv("#{Lono.root}/blueprints", "#{Lono.root}/app/blueprints")
17
+ puts "Move blueprints to app/blueprints"
16
18
  end
17
19
  end
18
20
  end
@@ -5,9 +5,9 @@ module Lono
5
5
  #
6
6
  # Normally, the Lono::Erb#run method generates the CloudFormation templates
7
7
  # and embeds user-data script into the template.
8
- class UserData
9
- def initialize(blueprint, options)
10
- @blueprint, @options = blueprint, options
8
+ class UserData < AbstractBase
9
+ def initialize(options={})
10
+ super
11
11
  @name = options[:name]
12
12
  @path = "#{Lono.root}/app/user_data/#{@name}.sh"
13
13
  end
@@ -25,7 +25,7 @@ module Lono
25
25
  # Context for ERB rendering.
26
26
  # This is where we control what references get passed to the ERB rendering.
27
27
  def context
28
- @context ||= Lono::Template::Context.new(@blueprint, @options)
28
+ @context ||= Lono::Template::Context.new(@options)
29
29
  end
30
30
  end
31
31
  end
@@ -0,0 +1,14 @@
1
+ module Lono::Utils
2
+ module PrettyTime
3
+ # http://stackoverflow.com/questions/4175733/convert-duration-to-hoursminutesseconds-or-similar-in-rails-3-or-ruby
4
+ def pretty_time(total_seconds)
5
+ minutes = (total_seconds / 60) % 60
6
+ seconds = total_seconds % 60
7
+ if total_seconds < 60
8
+ "#{seconds.to_i}s"
9
+ else
10
+ "#{minutes.to_i}m #{seconds.to_i}s"
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,23 @@
1
+ module Lono::Utils
2
+ module Sure
3
+ def sure?(message, desc=nil)
4
+ if @options[:sure]
5
+ sure = 'y'
6
+ else
7
+ out = message
8
+ if desc
9
+ out += "\n#{desc}\nAre you sure? (y/N) "
10
+ else
11
+ out += " (y/N) "
12
+ end
13
+ print out
14
+ sure = $stdin.gets
15
+ end
16
+
17
+ unless sure =~ /^y/
18
+ puts "Whew! Exiting."
19
+ exit 0
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module Lono
2
- VERSION = "6.1.11"
2
+ VERSION = "7.0.0"
3
3
  end
@@ -0,0 +1,52 @@
1
+ require "yaml"
2
+
3
+ module Lono::Yamler
4
+ class Loader
5
+ def self.load(text)
6
+ new(text).load
7
+ end
8
+
9
+ def initialize(text)
10
+ @text = text
11
+ end
12
+
13
+ def load
14
+ add_domain_types!
15
+ YAML.load(@text)
16
+ end
17
+
18
+ private
19
+ def add_domain_types!
20
+ intrinsic_functions.each do |name|
21
+ YAML.add_domain_type('', name) do |type,val|
22
+ key = type.split('::').last
23
+ key = "Fn::" + key unless name == 'Ref'
24
+ { key => val }
25
+ end
26
+ end
27
+ end
28
+
29
+ def intrinsic_functions
30
+ %w[
31
+ And
32
+ Base64
33
+ Cidr
34
+ Equals
35
+ FindInMap
36
+ GetAtt
37
+ GetAZs
38
+ If
39
+ If
40
+ ImportValue
41
+ Join
42
+ Not
43
+ Or
44
+ Ref
45
+ Select
46
+ Split
47
+ Sub
48
+ Transform
49
+ ]
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,51 @@
1
+ module Lono::Yamler
2
+ class Validator
3
+ def initialize(path)
4
+ @path = path
5
+ end
6
+
7
+ def validate!
8
+ validate_yaml(@path)
9
+ end
10
+
11
+ def validate_yaml(path)
12
+ text = IO.read(path)
13
+ begin
14
+ YAML.load(text)
15
+ rescue Psych::SyntaxError => e
16
+ handle_yaml_syntax_error(e, path)
17
+ end
18
+ end
19
+
20
+ def handle_yaml_syntax_error(e, path)
21
+ io = StringIO.new
22
+ io.puts "Invalid yaml. Output written for debugging: #{path}".color(:red)
23
+ io.puts "ERROR: #{e.message}".color(:red)
24
+
25
+ # Grab line info. Example error:
26
+ # ERROR: (<unknown>): could not find expected ':' while scanning a simple key at line 2 column 1
27
+ md = e.message.match(/at line (\d+) column (\d+)/)
28
+ line = md[1].to_i
29
+
30
+ lines = IO.read(path).split("\n")
31
+ context = 5 # lines of context
32
+ top, bottom = [line-context-1, 0].max, line+context-1
33
+ spacing = lines.size.to_s.size
34
+ lines[top..bottom].each_with_index do |line_content, index|
35
+ line_number = top+index+1
36
+ if line_number == line
37
+ io.printf("%#{spacing}d %s\n".color(:red), line_number, line_content)
38
+ else
39
+ io.printf("%#{spacing}d %s\n", line_number, line_content)
40
+ end
41
+ end
42
+
43
+ if ENV['LONO_TEST']
44
+ io.string
45
+ else
46
+ puts io.string
47
+ exit 1
48
+ end
49
+ end
50
+ end
51
+ end
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
28
28
  else
29
29
  raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
30
30
  end
31
+
31
32
  # Specify which files should be added to the gem when it is released.
32
33
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
33
34
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
@@ -40,4 +41,7 @@ Gem::Specification.new do |spec|
40
41
  spec.add_development_dependency "bundler", "~> 2.0"
41
42
  spec.add_development_dependency "rake", "~> 10.0"
42
43
  spec.add_development_dependency "rspec", "~> 3.0"
44
+ <% if @options[:type] != "dsl" %>
45
+ spec.metadata = {"template_type" => "erb"}
46
+ <% end %>
43
47
  end
@@ -27,7 +27,7 @@ The generated files in `config/<%= blueprint_name %>` folder look something like
27
27
 
28
28
  ## Deploy
29
29
 
30
- Use the [lono cfn deploy](http://lono.cloud/reference/lono-cfn-deploy/) command to deploy. Example:
30
+ Use the [lono cfn deploy](https://lono.cloud/reference/lono-cfn-deploy/) command to deploy. Example:
31
31
 
32
32
  LONO_ENV=development lono cfn deploy <%= blueprint_name %>-development --blueprint <%= blueprint_name %> --sure
33
33
  LONO_ENV=production lono cfn deploy <%= blueprint_name %>-production --blueprint <%= blueprint_name %> --sure
@@ -21,8 +21,8 @@ class Lono::Seed::Configs < Lono::Seed::Base
21
21
  # Return String with the content of the config/BLUEPRINT/variables file.
22
22
  # def variables
23
23
  # <<~EOL
24
- # @variable1=starter_value1
25
- # @variable2=starter_value2
24
+ # @variable1 = "starter_value1"
25
+ # @variable2 = "starter_value2"
26
26
  # EOL
27
27
  # end
28
28
  end
@@ -1,33 +1,32 @@
1
- # Starter Demo Example
2
1
  aws_template_format_version "2010-09-09"
3
2
  description "Demo stack"
4
3
 
5
4
  parameter("InstanceType", "t3.micro")
6
5
 
7
6
  mapping("AmiMap",
8
- "ap-northeast-1": { Ami: "ami-0f9ae750e8274075b" },
9
- "ap-northeast-2": { Ami: "ami-047f7b46bd6dd5d84" },
10
- "ap-south-1": { Ami: "ami-0889b8a448de4fc44" },
11
- "ap-southeast-1": { Ami: "ami-0b419c3a4b01d1859" },
12
- "ap-southeast-2": { Ami: "ami-04481c741a0311bbb" },
13
- "ca-central-1": { Ami: "ami-03338e1f67dae0168" },
14
- "eu-central-1": { Ami: "ami-09def150731bdbcc2" },
15
- "eu-north-1": { Ami: "ami-d16fe6af" },
16
- "eu-west-1": { Ami: "ami-07683a44e80cd32c5" },
17
- "eu-west-2": { Ami: "ami-09ead922c1dad67e4" },
18
- "eu-west-3": { Ami: "ami-0451ae4fd8dd178f7" },
19
- "sa-east-1": { Ami: "ami-0669a96e355eac82f" },
20
- "us-east-1": { Ami: "ami-0de53d8956e8dcf80" },
21
- "us-east-2": { Ami: "ami-02bcbb802e03574ba" },
22
- "us-west-1": { Ami: "ami-0019ef04ac50be30f" },
23
- "us-west-2": { Ami: "ami-061392db613a6357b" }
7
+ "ap-northeast-1": { Ami: "ami-068a6cefc24c301d2" },
8
+ "ap-northeast-2": { Ami: "ami-0d59ddf55cdda6e21" },
9
+ "ap-south-1": { Ami: "ami-0ce933e2ae91880d3" },
10
+ "ap-southeast-1": { Ami: "ami-07539a31f72d244e7" },
11
+ "ap-southeast-2": { Ami: "ami-0119aa4d67e59007c" },
12
+ "ca-central-1": { Ami: "ami-0ff24797826ebbcd5" },
13
+ "eu-central-1": { Ami: "ami-0d4c3eabb9e72650a" },
14
+ "eu-north-1": { Ami: "ami-006cda581cf39451b" },
15
+ "eu-west-1": { Ami: "ami-01f14919ba412de34" },
16
+ "eu-west-2": { Ami: "ami-05f37c3995fffb4fd" },
17
+ "eu-west-3": { Ami: "ami-0e9e6ba6d3d38faa8" },
18
+ "sa-east-1": { Ami: "ami-07820a4443539a2b0" },
19
+ "us-east-1": { Ami: "ami-00068cd7555f543d5" },
20
+ "us-east-2": { Ami: "ami-0dacb0c129b49f529" },
21
+ "us-west-1": { Ami: "ami-0b2d8d1abb76a53d8" },
22
+ "us-west-2": { Ami: "ami-0c5204531f799e0c6" }
24
23
  )
25
24
 
26
25
  resource("Instance", "AWS::EC2::Instance",
27
26
  InstanceType: ref("InstanceType"),
28
27
  ImageId: find_in_map("AmiMap", ref("AWS::Region"), "Ami"),
29
28
  SecurityGroupIds: [get_att("SecurityGroup.GroupId")],
30
- UserData: base64(user_data("bootstrap.sh"))
29
+ UserData: base64(sub(user_data("bootstrap.sh")))
31
30
  )
32
31
  resource("SecurityGroup", "AWS::EC2::SecurityGroup",
33
32
  GroupDescription: "demo security group",
@@ -1,8 +1,67 @@
1
1
  ---
2
- # Simple Starter Example
2
+ AWSTemplateFormatVersion: '2010-09-09'
3
+ Description: Demo stack
4
+ Parameters:
5
+ InstanceType:
6
+ Default: t3.micro
7
+ Type: String
8
+ Mappings:
9
+ AmiMap:
10
+ ap-northeast-1:
11
+ Ami: ami-068a6cefc24c301d2
12
+ ap-northeast-2:
13
+ Ami: ami-0d59ddf55cdda6e21
14
+ ap-south-1:
15
+ Ami: ami-0ce933e2ae91880d3
16
+ ap-southeast-1:
17
+ Ami: ami-07539a31f72d244e7
18
+ ap-southeast-2:
19
+ Ami: ami-0119aa4d67e59007c
20
+ ca-central-1:
21
+ Ami: ami-0ff24797826ebbcd5
22
+ eu-central-1:
23
+ Ami: ami-0d4c3eabb9e72650a
24
+ eu-north-1:
25
+ Ami: ami-006cda581cf39451b
26
+ eu-west-1:
27
+ Ami: ami-01f14919ba412de34
28
+ eu-west-2:
29
+ Ami: ami-05f37c3995fffb4fd
30
+ eu-west-3:
31
+ Ami: ami-0e9e6ba6d3d38faa8
32
+ sa-east-1:
33
+ Ami: ami-07820a4443539a2b0
34
+ us-east-1:
35
+ Ami: ami-00068cd7555f543d5
36
+ us-east-2:
37
+ Ami: ami-0dacb0c129b49f529
38
+ us-west-1:
39
+ Ami: ami-0b2d8d1abb76a53d8
40
+ us-west-2:
41
+ Ami: ami-0c5204531f799e0c6
3
42
  Resources:
4
- EC2Instance:
43
+ Instance:
5
44
  Type: AWS::EC2::Instance
6
45
  Properties:
7
- InstanceType: t3.micro
8
- ImageId: ami-05b186cbeb4bd0170 # us-west-2 Amazon Linux 2 AMI (HVM), SSD Volume Type
46
+ InstanceType:
47
+ Ref: InstanceType
48
+ ImageId:
49
+ Fn::FindInMap:
50
+ - AmiMap
51
+ - Ref: AWS::Region
52
+ - Ami
53
+ SecurityGroupIds:
54
+ - Fn::GetAtt:
55
+ - SecurityGroup
56
+ - GroupId
57
+ UserData:
58
+ Fn::Base64:
59
+ Fn::Sub:
60
+ - |-
61
+ #!/bin/bash
62
+ echo "hello world"
63
+ - {}
64
+ SecurityGroup:
65
+ Type: AWS::EC2::SecurityGroup
66
+ Properties:
67
+ GroupDescription: demo security group