lono 8.0.0.pre.rc2 → 8.0.0.pre.rc5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +84 -0
  3. data/.github/ISSUE_TEMPLATE/documentation.md +12 -0
  4. data/.github/ISSUE_TEMPLATE/feature_request.md +64 -0
  5. data/.github/ISSUE_TEMPLATE/question.md +14 -0
  6. data/.github/ISSUE_TEMPLATE.md +7 -0
  7. data/.github/PULL_REQUEST_TEMPLATE.md +50 -0
  8. data/CHANGELOG.md +56 -2
  9. data/Gemfile +1 -3
  10. data/lib/lono/app/callable_option/concern.rb +12 -0
  11. data/lib/lono/app/callable_option.rb +56 -0
  12. data/lib/lono/app.rb +56 -23
  13. data/lib/lono/autoloader.rb +1 -0
  14. data/lib/lono/aws_services/helper.rb +0 -2
  15. data/lib/lono/blueprint.rb +1 -18
  16. data/lib/lono/builder/allow/base.rb +54 -0
  17. data/lib/lono/builder/allow/env.rb +17 -0
  18. data/lib/lono/builder/allow/region.rb +20 -0
  19. data/lib/lono/builder/allow.rb +8 -0
  20. data/lib/lono/builder/configset/combiner.rb +145 -0
  21. data/lib/lono/builder/configset/definition/base.rb +47 -0
  22. data/lib/lono/builder/configset/definition/context.rb +70 -0
  23. data/lib/lono/{configset/strategy/helpers/dsl → builder/configset/definition/dsl/syntax}/auth.rb +1 -1
  24. data/lib/lono/builder/configset/definition/dsl/syntax/content.rb +22 -0
  25. data/lib/lono/{configset/strategy/helpers/dsl/syntax.rb → builder/configset/definition/dsl/syntax/core.rb} +15 -9
  26. data/lib/lono/{configset/strategy/helpers/dsl → builder/configset/definition/dsl/syntax}/package.rb +1 -1
  27. data/lib/lono/builder/configset/definition/dsl/syntax.rb +5 -0
  28. data/lib/lono/{configset/strategy → builder/configset/definition}/dsl.rb +10 -14
  29. data/lib/lono/{configset/strategy → builder/configset/definition}/erb.rb +13 -16
  30. data/lib/lono/builder/configset/definition.rb +18 -0
  31. data/lib/lono/builder/configset/evaluator.rb +10 -0
  32. data/lib/lono/builder/configset/registration.rb +35 -0
  33. data/lib/lono/builder/context.rb +40 -0
  34. data/lib/lono/builder/dsl/evaluator.rb +6 -55
  35. data/lib/lono/builder/dsl/finalizer/base.rb +8 -0
  36. data/lib/lono/builder/dsl/finalizer/configsets.rb +7 -28
  37. data/lib/lono/builder/dsl/finalizer/files/base.rb +4 -0
  38. data/lib/lono/builder/dsl/finalizer/files/build.rb +50 -0
  39. data/lib/lono/builder/dsl/finalizer/files/replace.rb +36 -0
  40. data/lib/lono/builder/dsl/finalizer/files.rb +9 -0
  41. data/lib/lono/builder/dsl/finalizer/parameter_groups.rb +4 -3
  42. data/lib/lono/builder/dsl/finalizer.rb +4 -2
  43. data/lib/lono/builder/dsl/helpers/ec2.rb +16 -3
  44. data/lib/lono/builder/dsl/helpers/files.rb +7 -0
  45. data/lib/lono/builder/dsl/helpers/partials.rb +48 -53
  46. data/lib/lono/builder/dsl/helpers/s3.rb +5 -7
  47. data/lib/lono/builder/dsl/helpers/ssm/fetcher.rb +3 -1
  48. data/lib/lono/builder/dsl/helpers/stack.rb +2 -4
  49. data/lib/lono/builder/dsl/helpers/template_file.rb +23 -29
  50. data/lib/lono/builder/dsl/helpers.rb +1 -11
  51. data/lib/lono/builder/dsl/syntax/core/resource/property_mover.rb +11 -1
  52. data/lib/lono/builder/dsl/syntax/core/squeezer.rb +19 -3
  53. data/lib/lono/builder/dsl/syntax/fn.rb +0 -2
  54. data/lib/lono/builder/dsl.rb +2 -2
  55. data/lib/lono/builder/param.rb +7 -2
  56. data/lib/lono/builder/template/upload.rb +2 -15
  57. data/lib/lono/builder/template.rb +1 -3
  58. data/lib/lono/builder.rb +39 -0
  59. data/lib/lono/bundler/util/git.rb +18 -16
  60. data/lib/lono/cfn/base.rb +2 -2
  61. data/lib/lono/cfn/cancel.rb +5 -5
  62. data/lib/lono/cfn/concerns/build.rb +1 -1
  63. data/lib/lono/cfn/delete.rb +5 -2
  64. data/lib/lono/cfn/deploy/iam.rb +1 -1
  65. data/lib/lono/cfn/deploy/operable.rb +1 -1
  66. data/lib/lono/cfn/deploy/rollback.rb +1 -3
  67. data/lib/lono/cfn/deploy.rb +23 -5
  68. data/lib/lono/cfn/download.rb +0 -1
  69. data/lib/lono/cfn/plan/changeset.rb +3 -3
  70. data/lib/lono/cfn/plan/diff/data.rb +11 -1
  71. data/lib/lono/cfn/plan/param.rb +1 -1
  72. data/lib/lono/cfn/plan/template.rb +2 -2
  73. data/lib/lono/cfn/plan.rb +26 -0
  74. data/lib/lono/cli/abstract.rb +0 -6
  75. data/lib/lono/cli/base.rb +6 -3
  76. data/lib/lono/cli/clean.rb +3 -2
  77. data/lib/lono/cli/help/new/helper.md +27 -0
  78. data/lib/lono/cli/help/new/hook.md +14 -0
  79. data/lib/lono/cli/help/new/project.md +3 -10
  80. data/lib/lono/cli/iam.rb +27 -0
  81. data/lib/lono/cli/list.rb +3 -6
  82. data/lib/lono/cli/new/blueprint.rb +3 -9
  83. data/lib/lono/cli/new/configset.rb +11 -44
  84. data/lib/lono/cli/new/helper.rb +19 -11
  85. data/lib/lono/cli/new/hook.rb +32 -0
  86. data/lib/lono/cli/new/sequence.rb +6 -1
  87. data/lib/lono/cli/new.rb +9 -9
  88. data/lib/lono/cli/script/build.rb +0 -5
  89. data/lib/lono/cli/status.rb +18 -0
  90. data/lib/lono/{inspector → cli}/summary.rb +23 -33
  91. data/lib/lono/cli.rb +15 -16
  92. data/lib/lono/command.rb +28 -2
  93. data/lib/lono/component.rb +29 -0
  94. data/lib/lono/concerns/aws_info.rb +14 -0
  95. data/lib/lono/concerns/names.rb +9 -0
  96. data/lib/lono/configset.rb +17 -0
  97. data/lib/lono/core.rb +11 -1
  98. data/lib/lono/ext/bundler.rb +7 -0
  99. data/lib/lono/ext/core/module.rb +31 -0
  100. data/lib/lono/ext/core/object.rb +32 -0
  101. data/lib/lono/ext/core/string.rb +9 -0
  102. data/lib/lono/ext.rb +4 -0
  103. data/lib/lono/files/base.rb +12 -0
  104. data/lib/lono/{utils → files/builder/lambda_layer}/rsync.rb +3 -5
  105. data/lib/lono/{app_file/build → files/builder}/lambda_layer/ruby_packager.rb +104 -79
  106. data/lib/lono/files/builder/lambda_layer/ruby_version.rb +38 -0
  107. data/lib/lono/files/builder/lambda_layer.rb +17 -0
  108. data/lib/lono/files/builder.rb +37 -0
  109. data/lib/lono/files/compressor.rb +53 -0
  110. data/lib/lono/files/concerns/post_processing.rb +52 -0
  111. data/lib/lono/files/concerns/registration.rb +16 -0
  112. data/lib/lono/files/registry.rb +6 -0
  113. data/lib/lono/files.rb +41 -0
  114. data/lib/lono/hooks/builder.rb +50 -0
  115. data/lib/lono/hooks/concern.rb +9 -0
  116. data/lib/lono/hooks/dsl.rb +20 -0
  117. data/lib/lono/hooks/runner.rb +46 -0
  118. data/lib/lono/layering/layer.rb +64 -56
  119. data/lib/lono/logger.rb +1 -3
  120. data/lib/lono/names.rb +7 -10
  121. data/lib/lono/s3/bucket.rb +17 -11
  122. data/lib/lono/s3/uploader.rb +33 -28
  123. data/lib/lono/script/build.rb +0 -5
  124. data/lib/lono/seeder.rb +19 -28
  125. data/lib/lono/user_data.rb +3 -1
  126. data/lib/lono/utils/call_line.rb +9 -0
  127. data/lib/lono/utils/sh.rb +32 -0
  128. data/lib/lono/utils.rb +5 -0
  129. data/lib/lono/version.rb +1 -1
  130. data/lib/lono/yamler/validator.rb +7 -22
  131. data/lib/lono.rb +8 -0
  132. data/lib/templates/configset/configset.rb +2 -16
  133. data/lib/templates/examples/configset/configset.rb +16 -0
  134. data/lib/templates/helper/%underscore_name%_helper.rb.tt +1 -1
  135. data/lib/templates/hook/config/hooks.rb.tt +14 -0
  136. data/lib/templates/project/Gemfile.tt +2 -7
  137. data/lono.gemspec +1 -1
  138. metadata +73 -62
  139. data/lib/lono/app_file/base.rb +0 -28
  140. data/lib/lono/app_file/build/lambda_layer.rb +0 -20
  141. data/lib/lono/app_file/build.rb +0 -79
  142. data/lib/lono/app_file/registry/item.rb +0 -24
  143. data/lib/lono/app_file/registry.rb +0 -16
  144. data/lib/lono/app_file/upload.rb +0 -12
  145. data/lib/lono/builder/context/generic.rb +0 -11
  146. data/lib/lono/builder/context/loaders/load_files.rb +0 -23
  147. data/lib/lono/builder/context/loaders.rb +0 -35
  148. data/lib/lono/builder/context/params.rb +0 -6
  149. data/lib/lono/builder/context/template.rb +0 -4
  150. data/lib/lono/builder/template/post_processor.rb +0 -67
  151. data/lib/lono/cli/build.rb +0 -91
  152. data/lib/lono/cli/code.rb +0 -22
  153. data/lib/lono/cli/help/blueprint/new.md +0 -56
  154. data/lib/lono/cli/new/extension.rb +0 -57
  155. data/lib/lono/configset/builder.rb +0 -59
  156. data/lib/lono/configset/combiner.rb +0 -164
  157. data/lib/lono/configset/evaluate_file.rb +0 -8
  158. data/lib/lono/configset/meta/dsl.rb +0 -12
  159. data/lib/lono/configset/meta.rb +0 -19
  160. data/lib/lono/configset/s3_file/build.rb +0 -34
  161. data/lib/lono/configset/s3_file/item.rb +0 -38
  162. data/lib/lono/configset/s3_file/registry.rb +0 -12
  163. data/lib/lono/configset/s3_file/upload.rb +0 -12
  164. data/lib/lono/configset/strategy/base.rb +0 -83
  165. data/lib/lono/configset/strategy/helpers/dsl/core.rb +0 -18
  166. data/lib/lono/configset/strategy/helpers/dsl.rb +0 -8
  167. data/lib/lono/configset/strategy/helpers/erb.rb +0 -9
  168. data/lib/lono/importer/base.rb +0 -48
  169. data/lib/lono/importer/converter.rb +0 -19
  170. data/lib/lono/importer/download.rb +0 -46
  171. data/lib/lono/importer/dsl.rb +0 -36
  172. data/lib/lono/importer/params.rb +0 -56
  173. data/lib/lono/importer/service/coder.rb +0 -85
  174. data/lib/lono/inspector/base.rb +0 -32
  175. data/lib/lono/lookup.rb +0 -12
  176. data/lib/lono/seeder/service_role.rb +0 -11
  177. data/lib/lono/utils/contexts.rb +0 -15
  178. data/lib/lono/utils/item/file_methods.rb +0 -29
  179. data/lib/lono/utils/item/zip.rb +0 -42
  180. data/lib/templates/extension/lib/%extension_name%/autoloader.rb.tt +0 -23
  181. data/lib/templates/extension/lib/%extension_name%/helpers/mappings.rb.tt +0 -24
  182. data/lib/templates/extension/lib/%extension_name%/helpers/outputs.rb.tt +0 -7
  183. data/lib/templates/extension/lib/%extension_name%/helpers/parameters.rb.tt +0 -10
  184. data/lib/templates/extension/lib/%extension_name%/helpers/resources/resource.rb.tt +0 -4
  185. data/lib/templates/extension/lib/%extension_name%/helpers/variables.rb.tt +0 -6
  186. data/lib/templates/extension/lib/%extension_name%/version.rb.tt +0 -3
  187. data/lib/templates/extension/lib/%extension_name%.rb.tt +0 -8
@@ -1,18 +0,0 @@
1
- module Lono::Configset::Strategy::Helpers::Dsl
2
- module Core
3
- def content_file(path)
4
- content_path = "#{@root}/lib/content"
5
- file = "#{content_path}/#{path}"
6
- if File.exist?(file)
7
- IO.read(file)
8
- else
9
- "File not found: #{file}"
10
- end
11
- end
12
-
13
- def s3_key(name)
14
- Lono::Configset::S3File::Registry.register(name, blueprint: @blueprint.name, configset: @configset, root: @root)
15
- "file://configset/#{@configset}/#{name}"
16
- end
17
- end
18
- end
@@ -1,8 +0,0 @@
1
- module Lono::Configset::Strategy::Helpers
2
- module Dsl
3
- include Auth
4
- include Core
5
- include Package
6
- include Syntax
7
- end
8
- end
@@ -1,9 +0,0 @@
1
- module Lono::Configset::Strategy::Helpers
2
- module Erb
3
- def indent(text, indentation_amount)
4
- text.split("\n").map do |line|
5
- " " * indentation_amount + line
6
- end.join("\n")
7
- end
8
- end
9
- end
@@ -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,85 +0,0 @@
1
- require 'base64'
2
- require 'json'
3
- require 'net/http'
4
-
5
- module Lono::Importer::Service
6
- class Coder
7
- include Lono::Utils::Logging
8
-
9
- def initialize(template, options={})
10
- @template, @options = template, options
11
- end
12
-
13
- def translate
14
- url = "#{Lono::API}/code"
15
- http = net_http_client(url)
16
- req = net_http_request(url,
17
- template: Base64.encode64(@template), # Base64 JSON for special chars that Rack::LintWrapper cannot process
18
- lono_version: Lono::VERSION,
19
- lono_command: lono_command,
20
- )
21
- res = http.request(req) # send request
22
-
23
- if res.code == "200"
24
- data = JSON.load(res.body)
25
- ruby_code = print(data) # returns data["ruby_code"] / passthrough
26
- ruby_code
27
- else
28
- logger.info "Error: Unable to convert template to Ruby code."
29
- logger.info "The error has been reported."
30
- logger.info "Non-successful http response status code: #{res.code}"
31
- # logger.info "headers: #{res.each_header.to_h.inspect}"
32
- exit 1
33
- end
34
- end
35
-
36
- private
37
- def print(data)
38
- return if ENV['LONO_PRO_TEST']
39
-
40
- if data["error"]
41
- # Code was processed but there was this error with an HTTP 200 OK
42
- logger.info "ERROR: #{data["error"]}".color(:red)
43
- if data["message"]
44
- logger.info data["message"]
45
- end
46
- return
47
- end
48
-
49
- validity = data["valid_ruby"] ? "valid" : "invalid"
50
- if validity == "valid"
51
- logger.info "INFO: The generated Ruby code is has #{validity} syntax."
52
- else
53
- logger.info "WARN: The generated Ruby code is has #{validity} syntax. Providing because it may be small errors.".color(:yellow) # note redirection disables color
54
- end
55
-
56
- logger.info <<~EOL
57
- Translated ruby code below:
58
-
59
- EOL
60
- ruby_code = data["ruby_code"]
61
- logger.info ruby_code
62
- ruby_code
63
- end
64
-
65
- def net_http_client(url)
66
- uri = URI(url)
67
- http = Net::HTTP.new(uri.host, uri.port)
68
- http.open_timeout = http.read_timeout = 30
69
- http.use_ssl = true if uri.scheme == 'https'
70
- http
71
- end
72
-
73
- def net_http_request(url, data)
74
- req = Net::HTTP::Post.new(url) # url includes query string and uri.path does not, must used url
75
- text = JSON.dump(data)
76
- req.body = text
77
- req.content_length = text.bytesize
78
- req
79
- end
80
-
81
- def lono_command
82
- "#{$0} #{ARGV.join(' ')}"
83
- end
84
- end
85
- 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 Contexts
3
- extend Memoist
4
-
5
- def template_context
6
- Lono::Builder::Context::Template.new(@options)
7
- end
8
- memoize :template_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