lono 8.0.0.pre.rc1 → 8.0.0.pre.rc4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (218) hide show
  1. checksums.yaml +4 -4
  2. data/.cody/acceptance/bin/build.sh +5 -5
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +84 -0
  4. data/.github/ISSUE_TEMPLATE/documentation.md +12 -0
  5. data/.github/ISSUE_TEMPLATE/feature_request.md +64 -0
  6. data/.github/ISSUE_TEMPLATE/question.md +14 -0
  7. data/.github/ISSUE_TEMPLATE.md +7 -0
  8. data/.github/PULL_REQUEST_TEMPLATE.md +50 -0
  9. data/CHANGELOG.md +59 -2
  10. data/Gemfile +1 -3
  11. data/README.md +2 -7
  12. data/lib/lono/app/callable_option/concern.rb +12 -0
  13. data/lib/lono/app/callable_option.rb +56 -0
  14. data/lib/lono/app.rb +56 -20
  15. data/lib/lono/autoloader.rb +1 -0
  16. data/lib/lono/aws_services/helper.rb +0 -2
  17. data/lib/lono/blueprint.rb +1 -18
  18. data/lib/lono/builder/allow/base.rb +54 -0
  19. data/lib/lono/builder/allow/env.rb +17 -0
  20. data/lib/lono/builder/allow/region.rb +20 -0
  21. data/lib/lono/builder/allow.rb +8 -0
  22. data/lib/lono/builder/configset/combiner.rb +145 -0
  23. data/lib/lono/builder/configset/definition/base.rb +47 -0
  24. data/lib/lono/builder/configset/definition/context.rb +70 -0
  25. data/lib/lono/{configset/strategy/helpers/dsl → builder/configset/definition/dsl/syntax}/auth.rb +1 -1
  26. data/lib/lono/builder/configset/definition/dsl/syntax/content.rb +22 -0
  27. data/lib/lono/{configset/strategy/helpers/dsl/syntax.rb → builder/configset/definition/dsl/syntax/core.rb} +15 -9
  28. data/lib/lono/{configset/strategy/helpers/dsl → builder/configset/definition/dsl/syntax}/package.rb +1 -1
  29. data/lib/lono/builder/configset/definition/dsl/syntax.rb +5 -0
  30. data/lib/lono/{configset/strategy → builder/configset/definition}/dsl.rb +10 -14
  31. data/lib/lono/{configset/strategy → builder/configset/definition}/erb.rb +13 -16
  32. data/lib/lono/builder/configset/definition.rb +18 -0
  33. data/lib/lono/builder/configset/evaluator.rb +10 -0
  34. data/lib/lono/builder/configset/registration.rb +35 -0
  35. data/lib/lono/builder/context.rb +33 -18
  36. data/lib/lono/builder/dsl/evaluator.rb +45 -0
  37. data/lib/lono/builder/dsl/finalizer/base.rb +8 -0
  38. data/lib/lono/builder/dsl/finalizer/configsets.rb +20 -0
  39. data/lib/lono/builder/dsl/finalizer/files/base.rb +4 -0
  40. data/lib/lono/builder/dsl/finalizer/files/build.rb +50 -0
  41. data/lib/lono/builder/dsl/finalizer/files/replace.rb +36 -0
  42. data/lib/lono/builder/dsl/finalizer/files.rb +9 -0
  43. data/lib/lono/builder/{template/dsl → dsl}/finalizer/parameter_groups.rb +6 -5
  44. data/lib/lono/builder/dsl/finalizer.rb +15 -0
  45. data/lib/lono/builder/{template/dsl/evaluator/helpers/ec2_helper.rb → dsl/helpers/ec2.rb} +3 -3
  46. data/lib/lono/builder/dsl/helpers/files.rb +7 -0
  47. data/lib/lono/builder/{template/helpers.rb → dsl/helpers/partials.rb} +48 -57
  48. data/lib/lono/builder/dsl/helpers/s3.rb +14 -0
  49. data/lib/lono/builder/{context/ssm_fetcher.rb → dsl/helpers/ssm/fetcher.rb} +5 -3
  50. data/lib/lono/builder/{context/helpers.rb → dsl/helpers/ssm.rb} +3 -3
  51. data/lib/lono/builder/{template/dsl/evaluator/helpers/stack_helper.rb → dsl/helpers/stack.rb} +6 -6
  52. data/lib/lono/builder/{template/dsl/evaluator/helpers/tags_helper.rb → dsl/helpers/tags.rb} +2 -2
  53. data/lib/lono/builder/dsl/helpers/template_file.rb +66 -0
  54. data/lib/lono/builder/dsl/helpers.rb +5 -0
  55. data/lib/lono/builder/{template/dsl/evaluator/section → dsl/syntax/core}/base.rb +4 -5
  56. data/lib/lono/builder/{template/dsl/evaluator/section → dsl/syntax/core}/condition.rb +1 -1
  57. data/lib/lono/builder/{template/dsl/evaluator/section → dsl/syntax/core}/mapping.rb +1 -1
  58. data/lib/lono/builder/{template/dsl/evaluator/section → dsl/syntax/core}/output.rb +1 -1
  59. data/lib/lono/builder/{template/dsl/evaluator/section → dsl/syntax/core}/parameter.rb +1 -1
  60. data/lib/lono/builder/{template/dsl/evaluator/section → dsl/syntax/core}/resource/property_mover.rb +12 -2
  61. data/lib/lono/builder/{template/dsl/evaluator/section → dsl/syntax/core}/resource.rb +1 -1
  62. data/lib/lono/builder/{template/dsl/evaluator/section → dsl/syntax/core}/section.rb +1 -1
  63. data/lib/lono/builder/dsl/syntax/core/squeezer.rb +40 -0
  64. data/lib/lono/builder/{template/dsl/evaluator/section/methods.rb → dsl/syntax/core.rb} +2 -2
  65. data/lib/lono/builder/{template/dsl/evaluator → dsl/syntax}/fn.rb +1 -3
  66. data/lib/lono/builder/{template/dsl/evaluator → dsl}/syntax/parameter_group.rb +1 -1
  67. data/lib/lono/builder/dsl/syntax.rb +9 -0
  68. data/lib/lono/builder/{template/dsl.rb → dsl.rb} +2 -2
  69. data/lib/lono/builder/param.rb +5 -2
  70. data/lib/lono/builder/template/upload.rb +2 -15
  71. data/lib/lono/builder/template.rb +1 -3
  72. data/lib/lono/builder/{template/dsl/evaluator → util}/stringify.rb +1 -1
  73. data/lib/lono/builder.rb +39 -0
  74. data/lib/lono/bundler/component/props/extension.rb +0 -1
  75. data/lib/lono/bundler/extract/tar.rb +0 -1
  76. data/lib/lono/bundler/util/git.rb +18 -16
  77. data/lib/lono/cfn/base.rb +2 -2
  78. data/lib/lono/cfn/cancel.rb +5 -5
  79. data/lib/lono/cfn/concerns/build.rb +1 -1
  80. data/lib/lono/cfn/delete.rb +5 -2
  81. data/lib/lono/cfn/deploy/iam.rb +1 -2
  82. data/lib/lono/cfn/deploy/rollback.rb +1 -3
  83. data/lib/lono/cfn/deploy.rb +46 -5
  84. data/lib/lono/cfn/download.rb +0 -1
  85. data/lib/lono/cfn/plan/changeset.rb +3 -3
  86. data/lib/lono/cfn/plan/diff/data.rb +11 -1
  87. data/lib/lono/cfn/plan/diff/file.rb +2 -1
  88. data/lib/lono/cfn/plan/param.rb +1 -1
  89. data/lib/lono/cfn/plan/template.rb +2 -2
  90. data/lib/lono/cfn/plan.rb +1 -0
  91. data/lib/lono/cli/abstract.rb +0 -6
  92. data/lib/lono/cli/base.rb +6 -3
  93. data/lib/lono/cli/clean.rb +3 -2
  94. data/lib/lono/cli/help/cfn/status.md +0 -1
  95. data/lib/lono/cli/help/new/helper.md +27 -0
  96. data/lib/lono/cli/help/new/hook.md +14 -0
  97. data/lib/lono/cli/help/new/project.md +3 -10
  98. data/lib/lono/cli/help/seed.md +22 -21
  99. data/lib/lono/cli/iam.rb +27 -0
  100. data/lib/lono/cli/list.rb +3 -6
  101. data/lib/lono/cli/new/blueprint.rb +3 -9
  102. data/lib/lono/cli/new/configset.rb +11 -44
  103. data/lib/lono/cli/new/helper.rb +19 -11
  104. data/lib/lono/cli/new/hook.rb +32 -0
  105. data/lib/lono/cli/new/sequence.rb +6 -1
  106. data/lib/lono/cli/new.rb +9 -9
  107. data/lib/lono/cli/s3.rb +3 -3
  108. data/lib/lono/cli/script/build.rb +0 -5
  109. data/lib/lono/cli/status.rb +18 -0
  110. data/lib/lono/{inspector → cli}/summary.rb +23 -33
  111. data/lib/lono/cli.rb +16 -16
  112. data/lib/lono/command.rb +28 -2
  113. data/lib/lono/component.rb +29 -0
  114. data/lib/lono/concerns/aws_info.rb +14 -0
  115. data/lib/lono/concerns/names.rb +9 -0
  116. data/lib/lono/configset.rb +17 -0
  117. data/lib/lono/core.rb +11 -1
  118. data/lib/lono/ext/bundler.rb +7 -0
  119. data/lib/lono/ext/core/module.rb +31 -0
  120. data/lib/lono/ext/core/object.rb +32 -0
  121. data/lib/lono/ext/core/string.rb +9 -0
  122. data/lib/lono/ext.rb +4 -0
  123. data/lib/lono/files/base.rb +12 -0
  124. data/lib/lono/{utils → files/builder/lambda_layer}/rsync.rb +3 -5
  125. data/lib/lono/{app_file/build → files/builder}/lambda_layer/ruby_packager.rb +104 -79
  126. data/lib/lono/files/builder/lambda_layer/ruby_version.rb +38 -0
  127. data/lib/lono/files/builder/lambda_layer.rb +17 -0
  128. data/lib/lono/files/builder.rb +37 -0
  129. data/lib/lono/files/compressor.rb +53 -0
  130. data/lib/lono/files/concerns/post_processing.rb +52 -0
  131. data/lib/lono/files/concerns/registration.rb +16 -0
  132. data/lib/lono/files/registry.rb +6 -0
  133. data/lib/lono/files.rb +41 -0
  134. data/lib/lono/hooks/builder.rb +50 -0
  135. data/lib/lono/hooks/concern.rb +9 -0
  136. data/lib/lono/hooks/dsl.rb +20 -0
  137. data/lib/lono/hooks/runner.rb +46 -0
  138. data/lib/lono/layering/layer.rb +64 -56
  139. data/lib/lono/logger.rb +2 -3
  140. data/lib/lono/names.rb +7 -10
  141. data/lib/lono/s3/bucket.rb +43 -37
  142. data/lib/lono/s3/rollback.rb +8 -0
  143. data/lib/lono/s3/uploader.rb +33 -28
  144. data/lib/lono/script/build.rb +0 -5
  145. data/lib/lono/seeder.rb +38 -29
  146. data/lib/lono/user_data.rb +3 -1
  147. data/lib/lono/utils/sh.rb +32 -0
  148. data/lib/lono/utils.rb +5 -0
  149. data/lib/lono/version.rb +1 -1
  150. data/lib/lono/yamler/validator.rb +7 -22
  151. data/lib/lono.rb +8 -0
  152. data/lib/templates/configset/configset.rb +2 -16
  153. data/lib/templates/examples/configset/configset.rb +16 -0
  154. data/lib/templates/helper/%underscore_name%_helper.rb.tt +1 -1
  155. data/lib/templates/hook/config/hooks.rb.tt +14 -0
  156. data/lono.gemspec +1 -1
  157. metadata +99 -93
  158. data/lib/lono/app_file/base.rb +0 -28
  159. data/lib/lono/app_file/build/lambda_layer.rb +0 -20
  160. data/lib/lono/app_file/build.rb +0 -79
  161. data/lib/lono/app_file/registry/item.rb +0 -24
  162. data/lib/lono/app_file/registry.rb +0 -16
  163. data/lib/lono/app_file/upload.rb +0 -12
  164. data/lib/lono/builder/context/loader/load_files.rb +0 -23
  165. data/lib/lono/builder/context/loader.rb +0 -35
  166. data/lib/lono/builder/context/params.rb +0 -7
  167. data/lib/lono/builder/template/configset_injector.rb +0 -52
  168. data/lib/lono/builder/template/dsl/evaluator/helpers/core_helper.rb +0 -14
  169. data/lib/lono/builder/template/dsl/evaluator/helpers/file_helper.rb +0 -44
  170. data/lib/lono/builder/template/dsl/evaluator/helpers/s3_helper.rb +0 -16
  171. data/lib/lono/builder/template/dsl/evaluator/helpers.rb +0 -16
  172. data/lib/lono/builder/template/dsl/evaluator/squeezer.rb +0 -24
  173. data/lib/lono/builder/template/dsl/evaluator/syntax/extend_with.rb +0 -9
  174. data/lib/lono/builder/template/dsl/evaluator/syntax.rb +0 -11
  175. data/lib/lono/builder/template/dsl/evaluator.rb +0 -45
  176. data/lib/lono/builder/template/dsl/finalizer.rb +0 -12
  177. data/lib/lono/builder/template/evaluate.rb +0 -52
  178. data/lib/lono/builder/template/post_processor.rb +0 -67
  179. data/lib/lono/cli/build.rb +0 -101
  180. data/lib/lono/cli/code.rb +0 -22
  181. data/lib/lono/cli/help/blueprint/new.md +0 -56
  182. data/lib/lono/cli/new/extension.rb +0 -57
  183. data/lib/lono/configset/builder.rb +0 -59
  184. data/lib/lono/configset/combiner.rb +0 -164
  185. data/lib/lono/configset/evaluate_file.rb +0 -8
  186. data/lib/lono/configset/meta/dsl.rb +0 -12
  187. data/lib/lono/configset/meta.rb +0 -19
  188. data/lib/lono/configset/s3_file/build.rb +0 -34
  189. data/lib/lono/configset/s3_file/item.rb +0 -38
  190. data/lib/lono/configset/s3_file/registry.rb +0 -12
  191. data/lib/lono/configset/s3_file/upload.rb +0 -12
  192. data/lib/lono/configset/strategy/base.rb +0 -83
  193. data/lib/lono/configset/strategy/helpers/dsl/core.rb +0 -18
  194. data/lib/lono/configset/strategy/helpers/dsl.rb +0 -8
  195. data/lib/lono/configset/strategy/helpers/erb.rb +0 -9
  196. data/lib/lono/extensions/dsl.rb +0 -8
  197. data/lib/lono/extensions/loader.rb +0 -19
  198. data/lib/lono/extensions.rb +0 -18
  199. data/lib/lono/importer/base.rb +0 -48
  200. data/lib/lono/importer/converter.rb +0 -19
  201. data/lib/lono/importer/download.rb +0 -46
  202. data/lib/lono/importer/dsl.rb +0 -36
  203. data/lib/lono/importer/params.rb +0 -56
  204. data/lib/lono/importer/service/coder.rb +0 -81
  205. data/lib/lono/inspector/base.rb +0 -32
  206. data/lib/lono/lookup.rb +0 -12
  207. data/lib/lono/seeder/service_role.rb +0 -11
  208. data/lib/lono/utils/context.rb +0 -15
  209. data/lib/lono/utils/item/file_methods.rb +0 -29
  210. data/lib/lono/utils/item/zip.rb +0 -42
  211. data/lib/templates/extension/lib/%extension_name%/autoloader.rb.tt +0 -23
  212. data/lib/templates/extension/lib/%extension_name%/helpers/mappings.rb.tt +0 -24
  213. data/lib/templates/extension/lib/%extension_name%/helpers/outputs.rb.tt +0 -7
  214. data/lib/templates/extension/lib/%extension_name%/helpers/parameters.rb.tt +0 -10
  215. data/lib/templates/extension/lib/%extension_name%/helpers/resources/resource.rb.tt +0 -4
  216. data/lib/templates/extension/lib/%extension_name%/helpers/variables.rb.tt +0 -6
  217. data/lib/templates/extension/lib/%extension_name%/version.rb.tt +0 -3
  218. data/lib/templates/extension/lib/%extension_name%.rb.tt +0 -8
@@ -1,48 +0,0 @@
1
- class Lono::Importer
2
- class Base < Lono::CLI::Base
3
- include Download
4
- include Thor::Actions
5
- include Thor::Base
6
-
7
- def initialize(options)
8
- reinitialize(options)
9
- @source = options[:source]
10
- @tmp_path = "/tmp/lono/import/template.yml"
11
- self.destination_root = Dir.pwd # Thor::Actions require destination_root to be set
12
- end
13
-
14
- private
15
- def summarize
16
- return unless @options[:summary]
17
- logger.info "Template Summary:"
18
- Lono::Inspector::Summary.new(@options).run
19
- end
20
-
21
- def create_params(template_path)
22
- create_params_file(template_path, "development")
23
- create_params_file(template_path, "production")
24
- end
25
-
26
- def create_params_file(template_path, env)
27
- params_path = if @blueprint.name != @template
28
- "config/#{@blueprint.name}/params/#{env}/#{@template}.txt"
29
- else
30
- "config/#{@blueprint.name}/params/#{env}.txt"
31
- end
32
- params = Params.new(template_path, params_path)
33
- params.create
34
- end
35
-
36
- # removes the ./ at the beginning if it's there in the path
37
- def pretty_path(path)
38
- path.sub("#{Lono.root}/",'')
39
- end
40
-
41
- def blueprint_name
42
- return @options[:name] if @options[:name]
43
- # Else infer name from the original source.
44
- name = File.basename(@source, ".*")
45
- @options[:casing] == "camelcase" ? name.camelize : name.underscore.dasherize
46
- end
47
- end
48
- end
@@ -1,19 +0,0 @@
1
- class Lono::Importer
2
- class Converter
3
- include Download
4
-
5
- # source is a path
6
- def initialize(options={})
7
- @options = options
8
- @source = options[:source]
9
- end
10
-
11
- def run
12
- tmp_path = "/tmp/lono/import/template.yml"
13
- tmp_template_path = download_template(@source, tmp_path)
14
- template = IO.read(tmp_template_path)
15
- coder = Service::Coder.new(template, @options)
16
- coder.translate
17
- end
18
- end
19
- end
@@ -1,46 +0,0 @@
1
- require "json"
2
- require "open-uri"
3
- require "yaml"
4
-
5
- class Lono::Importer
6
- module Download
7
- def download_template(source, dest_path)
8
- template = read_source(source)
9
-
10
- result = if json?(template)
11
- # abusing YAML.dump(YAML.load()) to convert json to yaml
12
- YAML.dump(YAML.load(template))
13
- else
14
- template # template is already in YAML format
15
- end
16
-
17
- folder = File.dirname(dest_path)
18
- FileUtils.mkdir_p(folder) unless File.exist?(folder)
19
- IO.write(dest_path, result)
20
- dest_path
21
- end
22
-
23
- def read_source(source)
24
- open(source).read
25
- rescue OpenURI::HTTPError, SocketError, Errno::ENOENT
26
- logger.info "ERROR: Unable to read source template provided: #{source}".color(:red)
27
- e = $!
28
- logger.info "#{e.class}: #{e.message}"
29
- logger.info "Please double check the source provided."
30
- exit 1
31
- rescue Exception => e
32
- logger.info "ERROR: Unable to read source template provided: #{source}".color(:red)
33
- logger.info "General Exception Error:"
34
- logger.info "#{e.class}: #{e.message}"
35
- logger.info "Please double check the source provided."
36
- exit 1
37
- end
38
-
39
- def json?(text)
40
- JSON.load(text)
41
- true # if reach here than it's just
42
- rescue JSON::ParserError
43
- false # not json
44
- end
45
- end
46
- end
@@ -1,36 +0,0 @@
1
- class Lono::Importer
2
- class Dsl < Base
3
- def run
4
- tmp_template_path = download_template(@source, @tmp_path)
5
- template = IO.read(tmp_template_path)
6
-
7
- Lono::Blueprint::New.start([@blueprint.name, "--import", "--type", "dsl"])
8
-
9
- translate_to_dsl(template)
10
- create_params(tmp_template_path)
11
- # Let's not summarize the template in case the Ruby syntax is invalid with the import coder.
12
- # Add summarize back in later
13
- # summarize
14
-
15
- final_message
16
- end
17
-
18
- def translate_to_dsl(template)
19
- coder = Service::Coder.new(template, @options)
20
- result = coder.translate
21
-
22
- path = "#{Lono.config.paths.templates}/#{@template}.rb"
23
- FileUtils.mkdir_p(File.dirname(path))
24
- create_file(path, result) # Thor::Action
25
- end
26
-
27
- def final_message
28
- logger.info <<~EOL
29
- #{"="*64}
30
- Congrats 🎉 You have successfully imported a lono blueprint.
31
-
32
- More info: https://lono.cloud/docs/core/blueprints
33
- EOL
34
- end
35
- end
36
- end
@@ -1,56 +0,0 @@
1
- class Lono::Importer
2
- class Params
3
- include Thor::Actions
4
- include Thor::Base
5
- extend Memoist
6
-
7
- attr_reader :options
8
- def initialize(template_path, params_path)
9
- @template_path, @params_path = template_path, params_path
10
- @params_path = normalize_path(@params_path)
11
- self.destination_root = Dir.pwd # Thor::Actions require destination_root to be set
12
- @options = {} # For Thor::Actions to work
13
- end
14
-
15
- # Creates starter params/base/[stack-name].txt file
16
- def create
17
- result = []
18
- required_parameters.each do |name, attributes|
19
- result << "#{name}=#{attributes["Default"]}"
20
- end
21
- optional_parameters.each do |name, attributes|
22
- key = "#{name}=".ljust(20, ' ')
23
- result << "##{key} # optional"
24
- end
25
- content = result.join("\n") + "\n"
26
-
27
-
28
- folder = File.dirname(@params_path)
29
- FileUtils.mkdir_p(folder) unless File.exist?(folder)
30
- create_file(@params_path, content) # Thor::Action
31
- end
32
-
33
- def required_parameters
34
- parameters.reject { |logical_id, p| p["Default"] }
35
- end
36
-
37
- def optional_parameters
38
- parameters.select { |logical_id, p| p["Default"] }
39
- end
40
-
41
- def parameters
42
- template_data["Parameters"] || []
43
- end
44
-
45
- def template_data
46
- YAML.load(IO.read(@template_path))
47
- end
48
- memoize :template_data
49
-
50
- private
51
- # Add Lono.root if not already there, helps cli_spec.rb to pass
52
- def normalize_path(path)
53
- path.include?(Lono.root.to_s) ? path : "#{Lono.root}/#{path}"
54
- end
55
- end
56
- end
@@ -1,81 +0,0 @@
1
- require 'base64'
2
- require 'json'
3
- require 'net/http'
4
-
5
- class Lono::Importer::Service::Coder
6
- def initialize(template, options={})
7
- @template, @options = template, options
8
- end
9
-
10
- def translate
11
- url = "#{Lono::API}/code"
12
- http = net_http_client(url)
13
- req = net_http_request(url,
14
- template: Base64.encode64(@template), # Base64 JSON for special chars that Rack::LintWrapper cannot process
15
- lono_version: Lono::VERSION,
16
- lono_command: lono_command,
17
- )
18
- res = http.request(req) # send request
19
-
20
- if res.code == "200"
21
- data = JSON.load(res.body)
22
- ruby_code = print(data) # returns data["ruby_code"] / passthrough
23
- ruby_code
24
- else
25
- logger.info "Error: Unable to convert template to Ruby code."
26
- logger.info "The error has been reported."
27
- logger.info "Non-successful http response status code: #{res.code}"
28
- # logger.info "headers: #{res.each_header.to_h.inspect}"
29
- exit 1
30
- end
31
- end
32
-
33
- private
34
- def print(data)
35
- return if ENV['LONO_PRO_TEST']
36
-
37
- if data["error"]
38
- # Code was processed but there was this error with an HTTP 200 OK
39
- $stderr.logger.info "ERROR: #{data["error"]}".color(:red)
40
- if data["message"]
41
- $stderr.logger.info data["message"]
42
- end
43
- return
44
- end
45
-
46
- validity = data["valid_ruby"] ? "valid" : "invalid"
47
- if validity == "valid"
48
- $stderr.logger.info "INFO: The generated Ruby code is has #{validity} syntax."
49
- else
50
- $stderr.logger.info "WARN: The generated Ruby code is has #{validity} syntax. Providing because it may be small errors.".color(:yellow) # note redirection disables color
51
- end
52
-
53
- $stderr.logger.info <<~EOL
54
- Translated ruby code below:
55
-
56
- EOL
57
- ruby_code = data["ruby_code"]
58
- logger.info ruby_code
59
- ruby_code
60
- end
61
-
62
- def net_http_client(url)
63
- uri = URI(url)
64
- http = Net::HTTP.new(uri.host, uri.port)
65
- http.open_timeout = http.read_timeout = 30
66
- http.use_ssl = true if uri.scheme == 'https'
67
- http
68
- end
69
-
70
- def net_http_request(url, data)
71
- req = Net::HTTP::Post.new(url) # url includes query string and uri.path does not, must used url
72
- text = JSON.dump(data)
73
- req.body = text
74
- req.content_length = text.bytesize
75
- req
76
- end
77
-
78
- def lono_command
79
- "#{$0} #{ARGV.join(' ')}"
80
- end
81
- end
@@ -1,32 +0,0 @@
1
- module Lono::Inspector
2
- class Base < Lono::CLI::Base
3
- extend Memoist
4
-
5
- def run
6
- build
7
- templates = @template_name ? [@template_name] : all_templates
8
- templates.each do |template_name|
9
- perform(template_name)
10
- end
11
- end
12
-
13
- def build
14
- if @options[:source]
15
- Lono::Cfn::Download.new(@options).run
16
- else
17
- build_templates
18
- end
19
- end
20
-
21
- def build_templates
22
- Lono::Builder::Template.new(@options.merge(quiet: false)).run
23
- end
24
-
25
- def all_templates
26
- templates_path = "#{Lono.root}/output/#{@blueprint.name}/templates"
27
- Dir.glob("#{templates_path}/**").map do |path|
28
- path.sub("#{templates_path}/", '').sub('.yml','') # template_name
29
- end
30
- end
31
- end
32
- end
data/lib/lono/lookup.rb DELETED
@@ -1,12 +0,0 @@
1
- module Lono
2
- class Lookup
3
- include Lono::Utils::Logging
4
- include Lono::Utils::Pretty
5
-
6
- def list(type)
7
- Dir.glob("#{Lono.root}/{app,vendor}/#{type}/*").each do |path|
8
- logger.info pretty_path(path)
9
- end
10
- end
11
- end
12
- end
@@ -1,11 +0,0 @@
1
- class Lono::Seeder
2
- module ServiceRole
3
- def create_service_linked_role(aws_service_name)
4
- iam.create_service_linked_role(
5
- aws_service_name: aws_service_name
6
- )
7
- rescue Aws::IAM::Errors::InvalidInput # already exist
8
- raise if ENV['LONO_DEBUG_SEED']
9
- end
10
- end
11
- end
@@ -1,15 +0,0 @@
1
- module Lono::Utils
2
- module Context
3
- extend Memoist
4
-
5
- def context
6
- Lono::Builder::Context.new(@options)
7
- end
8
- memoize :context
9
-
10
- def params_context
11
- Lono::Builder::Context::Params.new(@options)
12
- end
13
- memoize :params_context
14
- end
15
- end
@@ -1,29 +0,0 @@
1
- module Lono::Utils::Item
2
- module FileMethods
3
- def exist?
4
- File.exist?(output_path)
5
- end
6
-
7
- def directory?
8
- File.directory?(output_path)
9
- end
10
-
11
- def file?
12
- File.file?(output_path)
13
- end
14
-
15
- def s3_path
16
- path = zip_file_path.gsub("#{Lono.root}/",'') # remove Lono.root
17
- "#{Lono.env}/#{path}"
18
- end
19
-
20
- # full path
21
- def zip_file_path
22
- "#{File.dirname(output_path)}/#{zip_file_name}"
23
- end
24
-
25
- def zip_file_name
26
- "#{File.basename(output_path)}-#{@type}-#{Lono::Md5.sum(output_path)}.zip"
27
- end
28
- end
29
- end
@@ -1,42 +0,0 @@
1
- require 'fileutils'
2
-
3
- module Lono::Utils::Item
4
- module Zip
5
- def zip(item)
6
- if item.directory?
7
- zip_directory(item)
8
- else
9
- zip_file(item)
10
- end
11
- end
12
-
13
- def zip_file(item)
14
- path = item.output_path
15
- zip_file = item.zip_file_name
16
-
17
- logger.info "Zipping file and generating md5 named file from: #{path}"
18
- command = "cd #{File.dirname(path)} && zip -q #{zip_file} #{File.basename(path)}" # create zipfile at same level of file
19
- execute_zip(command)
20
- end
21
-
22
- def zip_directory(item)
23
- path = item.output_path
24
- zip_file = item.zip_file_name
25
-
26
- logger.info "Zipping folder and generating md5 named file from: #{path}"
27
- command = "cd #{path} && zip --symlinks -rq #{zip_file} ." # create zipfile witih directory
28
- execute_zip(command)
29
- FileUtils.mv("#{path}/#{zip_file}", "#{File.dirname(path)}/#{zip_file}") # move zip back to the parent directory
30
- end
31
-
32
- def execute_zip(command)
33
- # logger.info "=> #{command}".color(:green) # uncomment to debug
34
- `#{command}`
35
- unless $?.success?
36
- logger.info "ERROR: Fail to run #{command}".color(:red)
37
- logger.info "Maybe zip is not installed or path is incorrect?"
38
- exit 1
39
- end
40
- end
41
- end
42
- end
@@ -1,23 +0,0 @@
1
- require "zeitwerk"
2
-
3
- module <%= extension_class_name %>
4
- class Autoloader
5
- class Inflector < Zeitwerk::Inflector
6
- def camelize(basename, _abspath)
7
- map = { cli: "CLI", version: "VERSION" }
8
- map[basename.to_sym] || super
9
- end
10
- end
11
-
12
- class << self
13
- def setup
14
- loader = Zeitwerk::Loader.new
15
- loader.inflector = Inflector.new
16
- loader.push_dir(File.dirname(__dir__)) # lib
17
- # loader.log!
18
- loader.ignore("#{__dir__}/user_data")
19
- loader.setup
20
- end
21
- end
22
- end
23
- end
@@ -1,24 +0,0 @@
1
- module <%= extension_class_name %>::Helpers
2
- module Mappings
3
- def ami_mappings
4
- mapping("AmiMap",
5
- "ap-northeast-1": { Ami: "ami-011facbea5ec0363b" },
6
- "ap-northeast-2": { Ami: "ami-0bea7fd38fabe821a" },
7
- "ap-south-1": { Ami: "ami-0217a85e28e625474" },
8
- "ap-southeast-1": { Ami: "ami-05c64f7b4062b0a21" },
9
- "ap-southeast-2": { Ami: "ami-0b8b10b5bf11f3a22" },
10
- "ca-central-1": { Ami: "ami-0a269ca7cc3e3beff" },
11
- "eu-central-1": { Ami: "ami-07cda0db070313c52" },
12
- "eu-north-1": { Ami: "ami-0662eb9b9b8685935" },
13
- "eu-west-1": { Ami: "ami-0713f98de93617bb4" },
14
- "eu-west-2": { Ami: "ami-0089b31e09ac3fffc" },
15
- "eu-west-3": { Ami: "ami-007fae589fdf6e955" },
16
- "sa-east-1": { Ami: "ami-09de7b4017733e2af" },
17
- "us-east-1": { Ami: "ami-062f7200baf2fa504" },
18
- "us-east-2": { Ami: "ami-02ccb28830b645a41" },
19
- "us-west-1": { Ami: "ami-03caa3f860895f82e" },
20
- "us-west-2": { Ami: "ami-04590e7389a6e577c" }
21
- )
22
- end
23
- end
24
- end
@@ -1,7 +0,0 @@
1
- module <%= extension_class_name %>::Helpers
2
- module Outputs
3
- def resource1_output
4
- output("Resource1")
5
- end
6
- end
7
- end
@@ -1,10 +0,0 @@
1
- module <%= extension_class_name %>::Helpers
2
- module Parameters
3
- def example_parameters
4
- parameter_group("AWS::Service::Resource") do
5
- parameter("Parameter1")
6
- parameter("Parameter2")
7
- end
8
- end
9
- end
10
- end
@@ -1,4 +0,0 @@
1
- module <%= extension_class_name %>::Helpers::Resources
2
- module Resource
3
- end
4
- end
@@ -1,6 +0,0 @@
1
- module <%= extension_class_name %>::Helpers
2
- module Variables
3
- # AWS::Service::Resource example
4
- attr_reader :property1, :property2
5
- end
6
- end
@@ -1,3 +0,0 @@
1
- module <%= extension_class_name %>
2
- VERSION = "0.1.0"
3
- end
@@ -1,8 +0,0 @@
1
- $:.unshift(File.expand_path("../", __FILE__))
2
- require "<%= extension_underscore_name %>/version"
3
-
4
- require "<%= extension_underscore_name %>/autoloader"
5
- <%= extension_class_name %>::Autoloader.setup
6
-
7
- module <%= extension_class_name %>
8
- end