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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7b8aac5691cff8ed8b88b54966069a649acebb0a9560c1ca0dff78319c2ab50
4
- data.tar.gz: fb47bc4be6366f4f88edeb21ede8cfdf58de7f88795cb46b3246e6a6935caf08
3
+ metadata.gz: 385523caa0cc8ae16b14546c6a46f4b8210ea43c21d83807754a75357f92cef2
4
+ data.tar.gz: 9db612e67d8d23db5be53394f71ea2edc03b7e526e72951dfe9c7821d731d00f
5
5
  SHA512:
6
- metadata.gz: f9144be84cdd745dbbcb5dff0882d2ac6e13edb8f979c91264406f1c47c2d3267481f448a0c2c4f508503e04bddd97072dbd9b06fa119d7f8e77cf8ed2ea3f74
7
- data.tar.gz: 355428a2feabeefab9af469bf52e589a3870e2d08bcf1b6d4ae418e8fef8970deff523d6ba2636bf34ddef1b3df843d4782cb8cecc640c8d880411da4fc11f78
6
+ metadata.gz: caece4d3ea56da6d7159ba95cceacfb205f9af85827a20eb2f555db385703a344c81dc32eb390cc65870b34c0bb04a85791c7dc918e18b9ca2bed316f2b826d0
7
+ data.tar.gz: 44e8056a90c0f6346d31a55deeb80e0f80d7aa0f063b55ecf09b312cea9a240f0ec908f5b227731c67b706163c38771f43b8cfd9ee80f0ac0d0c0850e1bd255c
@@ -2,6 +2,9 @@
2
2
 
3
3
  set -exu
4
4
 
5
+ git config --global user.email "tonguerooo@gmail.com"
6
+ git config --global user.name "tung"
7
+
5
8
  # https://unix.stackexchange.com/questions/1496/why-doesnt-my-bash-script-recognize-aliases
6
9
  shopt -s expand_aliases
7
10
  alias lono="$(pwd)/exe/lono"
@@ -12,20 +15,33 @@ rm -rf infra
12
15
 
13
16
  lono new infra
14
17
  cd infra
15
- lono blueprint new demo
16
- # Very simply template with just a security group
17
- cp ../.cody/demo.rb blueprints/demo/app/templates/demo.rb
18
18
 
19
19
  # Rewrite the Gemfile to use the local lono gem for testing
20
20
  cat << EOF > Gemfile
21
21
  source "https://rubygems.org"
22
22
  gem "lono", path: "$CODEBUILD_SRC_DIR", submodules: true
23
23
  EOF
24
+ cat Gemfile
24
25
 
25
26
  bundle # install lono gem in the infra project
26
27
 
28
+ # Create a demo blueprint
29
+ lono blueprint new demo
30
+ # Very simply template with just a security group
31
+ cp ../.cody/demo.rb app/blueprints/demo/app/templates/demo.rb
32
+
27
33
  STACK_NAME="demo-$(date +%Y%m%d%H%M%S)"
28
34
 
35
+ # Configure lono registration
36
+ mkdir -p .lono
37
+ cat << EOF > .lono/registration.yml
38
+ ---
39
+ name: <%= ssm("/lono/registration/name") %>
40
+ company: <%= ssm("/lono/registration/company") %>
41
+ email: <%= ssm("/lono/registration/email") %>
42
+ registration_key: <%= ssm("/lono/registration/registration_key") %>
43
+ EOF
44
+
29
45
  lono cfn deploy $STACK_NAME --blueprint demo
30
46
  lono cfn status $STACK_NAME
31
47
  lono cfn delete $STACK_NAME --sure
data/.gitignore CHANGED
@@ -10,7 +10,6 @@ doc/
10
10
  Gemfile.lock
11
11
  InstalledFiles
12
12
  lib/bundler/man
13
- output
14
13
  pkg
15
14
  rdoc
16
15
  spec/fixtures/my_project/templates/aws-waf-security-automations.yml
@@ -18,6 +17,7 @@ spec/project
18
17
  spec/reports
19
18
  test/tmp
20
19
  test/version_tmp
21
- tmp
22
20
 
23
21
  /infra
22
+ /output
23
+ /tmp
@@ -3,6 +3,21 @@
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
+ ## [7.0.0]
7
+ * Breaking: project `blueprints` moved to `app/blueprints`. Use `lono upgrade` to update.
8
+ * Introduce configsets concept.
9
+ * Introduce lono sets concept: `lono sets`, `lono sets deploy`, `lono sets instances sync`
10
+ * Merge lono-pro into lono. Deprecate lono-pro gem.
11
+ * Add lono registration.
12
+ * Major refactoring:
13
+ * Remove stack name suffix option
14
+ * Remove current concept
15
+ * Introduce Lono::AbstractBase class
16
+ * Pass CLI options consistently straight through.
17
+ * Use Lono::Conventions.
18
+ * Introduce Lono::Cfn::Opts to remove duplication
19
+ * Internally use `@stack` instead of `@stack_name`. `@stack` can be either a stack or stack_set
20
+
6
21
  ## [6.1.11]
7
22
  - #35 fix app files variables erb lookup scope
8
23
 
@@ -206,7 +221,7 @@ This project *tries* to adhere to [Semantic Versioning](http://semver.org/), eve
206
221
  - update cli docs
207
222
 
208
223
  ## [4.0.1]
209
- - add http://lono.cloud/reference/
224
+ - add https://lono.cloud/reference/
210
225
  - improve cli docs
211
226
 
212
227
  ## [4.0.0]
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <div align="center">
2
- <img src="http://lono.cloud/img/logos/lono-logo-small.png" />
2
+ <img src="https://lono.cloud/img/logos/lono-logo-small.png" />
3
3
  </div>
4
4
 
5
5
  # Lono
@@ -10,17 +10,25 @@
10
10
 
11
11
  [![BoltOps Badge](https://img.boltops.com/boltops/badges/boltops-badge.png)](https://www.boltops.com)
12
12
 
13
- Lono is a powerful CloudFormation framework. Lono handles the entire CloudFormation lifecycle. It builds, manages and deploys CloudFormation templates.
13
+ Lono is a CloudFormation framework. It builds, manages, and deploys CloudFormation templates.
14
14
 
15
- * Lono generates CloudFormation templates based on a [DSL](http://lono.cloud/docs/dsl/).
16
- * Lono takes simple env-like files and generates the CloudFormation parameter files.
17
- * Lono provides a simple CLI interface to launch the CloudFormation stacks.
15
+ ## Lono Features
16
+
17
+ * Simple CLI interface to launch CloudFormation stacks.
18
+ * Ability to use [Existing CloudFormation Templates](https://lono.cloud/docs/existing-templates/).
19
+ * [The Lono DSL](https://lono.cloud/docs/dsl/) - Generate templates from beautiful code.
20
+ * Write your CloudFormation parameters with [simple env-like values](https://lono.cloud/docs/configs/params/).
21
+ * Preview CloudFormation changes before pressing the big red button.
22
+ * [Layering](https://lono.cloud/docs/core/layering/) - Allows you to build multiple environments like development and production with the same template.
23
+ * [Variables](https://lono.cloud/docs/layering/variables/) - Allows you to construct templates where runtime Parameters do not suffice.
24
+ * [Helpers](https://lono.cloud/docs/core/helpers/) - Allows you to extend Lono and simplify code.
25
+ * [Configsets](https://lono.cloud/docs/configsets/) - Configurement Management. Automatically configure EC2 instances with reuseable code.
18
26
 
19
27
  See [lono.cloud](http://lono.cloud) for full lono documentation.
20
28
 
21
29
  ## Upgrading
22
30
 
23
- If you are on version 4.2 and upgrade to 5.0. You can run `lono upgrade v4to5` within your project to upgrade it to version 5.0. Refer to the [Upgrading Guide](http://lono.cloud/docs/extras/upgrading/).
31
+ If you are on version 6 and upgrading to 7. You can run [lono upgrade](https://lono.cloud/reference/lono-upgrade/) within your project. Refer to the [Upgrading Guide](https://lono.cloud/docs/extras/upgrading/).
24
32
 
25
33
  ## Quick Usage
26
34
 
@@ -29,9 +37,10 @@ It only takes a couple of commands to start using lono.
29
37
  gem install lono
30
38
  lono new infra
31
39
  cd infra
40
+ lono blueprint new demo
32
41
  lono cfn deploy demo
33
42
 
34
- ![Lono flowchart](http://lono.cloud/img/tutorial/lono-flowchart.png "Lono flowchart")
43
+ ![Lono flowchart](https://lono.cloud/img/tutorial/lono-flowchart.png "Lono flowchart")
35
44
 
36
45
  ## DSL
37
46
 
@@ -61,23 +70,12 @@ output("Instance")
61
70
  output("SecurityGroup", get_att("SecurityGroup.GroupId"))
62
71
  ```
63
72
 
64
- ### Lono Cfn Lifecycle Commands
73
+ ### Lono Cfn Deploy
65
74
 
66
- Lono provides a `lono cfn` lifecycle command that allows you to launch stacks quickly. The `lono cfn` tool automatically runs `lono generate` internally and then launches the CloudFormation stack all in one command. If you are in a lono project and have a `demo` lono blueprint. To create a stack you can simply run:
75
+ Lono provides a `lono cfn` lifecycle command that allows you to launch stacks quickly. The `lono cfn deploy` generates and launches the CloudFormation stack. If you are in a lono project and have a `demo` lono blueprint. To create a stack run:
67
76
 
68
77
  $ lono cfn deploy demo
69
78
 
70
- The above command will generate files to `output/infra/templates/demo.yml` and `output/infra/params/demo.txt` and use them to create a CloudFormation stack. Here are some more examples of cfn commands:
71
-
72
- lono cfn deploy demo # shorthand if blueprint, template and params file matches.
73
- lono cfn deploy demo-$(date +%Y%m%d%H%M%S) --blueprint demo --template demo --param demo
74
- lono cfn diff demo
75
- lono cfn preview demo
76
- lono cfn delete demo
77
- lono cfn deploy -h # getting help
78
-
79
- See [lono.cloud](http://lono.cloud) for full lono documentation.
80
-
81
79
  ## Contributing
82
80
 
83
81
  1. Fork it
data/Rakefile CHANGED
@@ -1,3 +1,4 @@
1
+ require "./lib/lono"
1
2
  require "bundler/gem_tasks"
2
3
  require "rspec/core/rake_task"
3
4
 
@@ -1,5 +1,6 @@
1
1
  $stdout.sync = true unless ENV["LONO_STDOUT_SYNC"] == "0"
2
2
 
3
+ require "active_support/core_ext/class"
3
4
  require 'active_support/core_ext/hash'
4
5
  require 'active_support/core_ext/string'
5
6
  require 'fileutils'
@@ -16,16 +17,17 @@ $:.unshift("#{gem_root}/lib")
16
17
  $:.unshift("#{gem_root}/vendor/cfn-status/lib")
17
18
  require "cfn_status"
18
19
 
20
+ require "lono/ext/bundler"
21
+
19
22
  require "lono/autoloader"
20
23
  Lono::Autoloader.setup
21
24
 
22
25
  module Lono
26
+ API_DEFAULT = 'https://api.lono.cloud/v1'
27
+ API = ENV['LONO_API'] || API_DEFAULT
28
+
23
29
  extend Core
24
30
  end
25
31
 
26
32
  Lono.set_aws_profile!
27
-
28
- begin
29
- require "lono-pro" # optional
30
- rescue LoadError
31
- end
33
+ Lono.lono_pro_removal_check!
@@ -0,0 +1,25 @@
1
+ module Lono
2
+ class AbstractBase
3
+ extend Memoist
4
+ include Lono::Blueprint::Root
5
+
6
+ def initialize(options={})
7
+ reinitialize(options)
8
+ end
9
+
10
+ # Hack so that we can use include Thor::Base
11
+ def reinitialize(options)
12
+ @options = options
13
+ Lono::ProjectChecker.check
14
+ @stack, @blueprint, @template, @param = Conventions.new(options).values
15
+
16
+ return if options[:source]
17
+ set_blueprint_root(@blueprint)
18
+ Lono::ProjectChecker.empty_templates
19
+ end
20
+
21
+ def template_path
22
+ "#{Lono.config.output_path}/#{@blueprint}/templates/#{@template}.yml"
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,30 @@
1
+ module Lono::Api
2
+ class Client
3
+ extend Memoist
4
+ include Verify
5
+ include Repos
6
+
7
+ def http
8
+ Proxy.new
9
+ end
10
+ memoize :http
11
+
12
+ def load_json(res)
13
+ if res.code == "200"
14
+ data = JSON.load(res.body)
15
+ case data
16
+ when Array
17
+ data.map(&:deep_symbolize_keys)
18
+ when Hash
19
+ data.deep_symbolize_keys
20
+ end
21
+ else
22
+ if ENV['LONO_DEBUG_API']
23
+ puts "Error: Non-successful http response status code: #{res.code}"
24
+ puts "headers: #{res.each_header.to_h.inspect}"
25
+ end
26
+ nil
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,58 @@
1
+ # To allow a pretty interface:
2
+ #
3
+ # res = http.get("blueprints")
4
+ #
5
+ module Lono::Api
6
+ class Proxy
7
+ extend Memoist
8
+
9
+ def get(path)
10
+ request(Net::HTTP::Get, path)
11
+ end
12
+
13
+ def post(path, data={})
14
+ request(Net::HTTP::Post, path, data)
15
+ end
16
+
17
+ def http(url)
18
+ uri = URI(url)
19
+ http = Net::HTTP.new(uri.host, uri.port)
20
+ http.open_timeout = http.read_timeout = 30
21
+ http.use_ssl = true if uri.scheme == 'https'
22
+ http
23
+ end
24
+ memoize :http
25
+
26
+ def request(klass, path, data={})
27
+ url = url(path)
28
+ http = http(url)
29
+ req = send_request(klass, url, data)
30
+ http.request(req) # send request
31
+ end
32
+
33
+ def send_request(klass, url, data={})
34
+ data.merge!(
35
+ lono_version: Lono::VERSION,
36
+ lono_command: lono_command,
37
+ )
38
+ req = klass.new(url) # url includes query string and uri.path does not, must used url
39
+ if [Net::HTTP::Post, Net::HTTP::Put].include?(klass)
40
+ text = JSON.dump(data)
41
+ req.body = text
42
+ req.content_length = text.bytesize
43
+ end
44
+ req
45
+ end
46
+
47
+ # Lono::API does not include the /. IE: localhost:8888
48
+ # path includes the /. IE: "/blueprints"
49
+ def url(path)
50
+ "#{Lono::API}/#{path}"
51
+ end
52
+
53
+ private
54
+ def lono_command
55
+ "#{$0} #{ARGV.join(' ')}"
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,8 @@
1
+ module Lono::Api
2
+ module Repos
3
+ def repos(type)
4
+ res = http.get("repos?type=#{type}")
5
+ load_json(res)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,13 @@
1
+ module Lono::Api
2
+ module Verify
3
+ def verify(data)
4
+ res = http.post("verify", data)
5
+ load_json(res)
6
+ end
7
+
8
+ def temp_key
9
+ res = http.post("temp_keys")
10
+ load_json(res)
11
+ end
12
+ end
13
+ end
@@ -1,20 +1,13 @@
1
1
  # Naming AppFile instead of File so we dont to use ::File for normal regular File class
2
2
  module Lono::AppFile
3
- class Base
4
- include Lono::Blueprint::Root
5
- extend Memoist
6
-
3
+ class Base < Lono::AbstractBase
7
4
  # What's needed for a Thor::Group or "Sequence". Gives us Thor::Actions commands like create_file
8
5
  # Must be included before `def initialize` as we override the Thor initialize
9
6
  include Thor::Actions
10
7
  include Thor::Base
11
-
12
- def initialize(blueprint, options={})
13
- @blueprint, @options = blueprint, options
14
- @template = @options[:template] || @blueprint
15
- Lono::ProjectChecker.check
16
- set_blueprint_root(@blueprint)
17
- Lono::ProjectChecker.empty_templates
8
+ # Override Thor::Base initialize
9
+ def initialize(options={})
10
+ reinitialize(options)
18
11
  initialize_variables
19
12
  end
20
13
 
@@ -33,7 +33,7 @@ module Lono::AppFile
33
33
  end
34
34
 
35
35
  def context
36
- Lono::Template::Context.new(@blueprint, @options)
36
+ Lono::Template::Context.new(@options)
37
37
  end
38
38
  memoize :context
39
39
 
@@ -3,11 +3,8 @@ module Lono::AppFile
3
3
  include Lono::AwsServices
4
4
  extend Memoist
5
5
 
6
- def initialize(blueprint, options={})
7
- @blueprint, @options = blueprint, options
8
- end
9
-
10
6
  def upload
7
+ return unless Registry.items.size > 0
11
8
  puts "Uploading app/files..."
12
9
 
13
10
  Registry.items.each do |item|
@@ -1,3 +1,5 @@
1
+ require "lono/bundle"
2
+ Lono::Bundle.setup
1
3
  require "zeitwerk"
2
4
 
3
5
  module Lono
@@ -14,7 +16,7 @@ module Lono
14
16
  loader = Zeitwerk::Loader.new
15
17
  loader.inflector = Inflector.new
16
18
  loader.push_dir(File.dirname(__dir__)) # lib
17
- # loader.log! # uncomment to debug
19
+ loader.log! if ENV["LONO_AUTOLOAD_LOG"]
18
20
  loader.setup
19
21
  end
20
22
  end
@@ -8,7 +8,12 @@ require "aws_mfa_secure/ext/aws" # add MFA support
8
8
  module Lono
9
9
  module AwsServices
10
10
  extend Memoist
11
- include Util
11
+ include Helper
12
+
13
+ def cfn
14
+ Aws::CloudFormation::Client.new
15
+ end
16
+ memoize :cfn
12
17
 
13
18
  def ec2
14
19
  Aws::EC2::Client.new
@@ -20,11 +25,6 @@ module Lono
20
25
  end
21
26
  memoize :iam
22
27
 
23
- def sts
24
- Aws::STS::Client.new # part of aws-sdk-core
25
- end
26
- memoize :sts
27
-
28
28
  def s3
29
29
  Aws::S3::Client.new
30
30
  end
@@ -40,9 +40,9 @@ module Lono
40
40
  end
41
41
  memoize :s3_presigner
42
42
 
43
- def cfn
44
- Aws::CloudFormation::Client.new
43
+ def sts
44
+ Aws::STS::Client.new # part of aws-sdk-core
45
45
  end
46
- memoize :cfn
46
+ memoize :sts
47
47
  end
48
48
  end