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.
- checksums.yaml +4 -4
- data/.cody/acceptance/bin/build.sh +5 -5
- data/.github/ISSUE_TEMPLATE/bug_report.md +84 -0
- data/.github/ISSUE_TEMPLATE/documentation.md +12 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +64 -0
- data/.github/ISSUE_TEMPLATE/question.md +14 -0
- data/.github/ISSUE_TEMPLATE.md +7 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +50 -0
- data/CHANGELOG.md +59 -2
- data/Gemfile +1 -3
- data/README.md +2 -7
- data/lib/lono/app/callable_option/concern.rb +12 -0
- data/lib/lono/app/callable_option.rb +56 -0
- data/lib/lono/app.rb +56 -20
- data/lib/lono/autoloader.rb +1 -0
- data/lib/lono/aws_services/helper.rb +0 -2
- data/lib/lono/blueprint.rb +1 -18
- data/lib/lono/builder/allow/base.rb +54 -0
- data/lib/lono/builder/allow/env.rb +17 -0
- data/lib/lono/builder/allow/region.rb +20 -0
- data/lib/lono/builder/allow.rb +8 -0
- data/lib/lono/builder/configset/combiner.rb +145 -0
- data/lib/lono/builder/configset/definition/base.rb +47 -0
- data/lib/lono/builder/configset/definition/context.rb +70 -0
- data/lib/lono/{configset/strategy/helpers/dsl → builder/configset/definition/dsl/syntax}/auth.rb +1 -1
- data/lib/lono/builder/configset/definition/dsl/syntax/content.rb +22 -0
- data/lib/lono/{configset/strategy/helpers/dsl/syntax.rb → builder/configset/definition/dsl/syntax/core.rb} +15 -9
- data/lib/lono/{configset/strategy/helpers/dsl → builder/configset/definition/dsl/syntax}/package.rb +1 -1
- data/lib/lono/builder/configset/definition/dsl/syntax.rb +5 -0
- data/lib/lono/{configset/strategy → builder/configset/definition}/dsl.rb +10 -14
- data/lib/lono/{configset/strategy → builder/configset/definition}/erb.rb +13 -16
- data/lib/lono/builder/configset/definition.rb +18 -0
- data/lib/lono/builder/configset/evaluator.rb +10 -0
- data/lib/lono/builder/configset/registration.rb +35 -0
- data/lib/lono/builder/context.rb +33 -18
- data/lib/lono/builder/dsl/evaluator.rb +45 -0
- data/lib/lono/builder/dsl/finalizer/base.rb +8 -0
- data/lib/lono/builder/dsl/finalizer/configsets.rb +20 -0
- data/lib/lono/builder/dsl/finalizer/files/base.rb +4 -0
- data/lib/lono/builder/dsl/finalizer/files/build.rb +50 -0
- data/lib/lono/builder/dsl/finalizer/files/replace.rb +36 -0
- data/lib/lono/builder/dsl/finalizer/files.rb +9 -0
- data/lib/lono/builder/{template/dsl → dsl}/finalizer/parameter_groups.rb +6 -5
- data/lib/lono/builder/dsl/finalizer.rb +15 -0
- data/lib/lono/builder/{template/dsl/evaluator/helpers/ec2_helper.rb → dsl/helpers/ec2.rb} +3 -3
- data/lib/lono/builder/dsl/helpers/files.rb +7 -0
- data/lib/lono/builder/{template/helpers.rb → dsl/helpers/partials.rb} +48 -57
- data/lib/lono/builder/dsl/helpers/s3.rb +14 -0
- data/lib/lono/builder/{context/ssm_fetcher.rb → dsl/helpers/ssm/fetcher.rb} +5 -3
- data/lib/lono/builder/{context/helpers.rb → dsl/helpers/ssm.rb} +3 -3
- data/lib/lono/builder/{template/dsl/evaluator/helpers/stack_helper.rb → dsl/helpers/stack.rb} +6 -6
- data/lib/lono/builder/{template/dsl/evaluator/helpers/tags_helper.rb → dsl/helpers/tags.rb} +2 -2
- data/lib/lono/builder/dsl/helpers/template_file.rb +66 -0
- data/lib/lono/builder/dsl/helpers.rb +5 -0
- data/lib/lono/builder/{template/dsl/evaluator/section → dsl/syntax/core}/base.rb +4 -5
- data/lib/lono/builder/{template/dsl/evaluator/section → dsl/syntax/core}/condition.rb +1 -1
- data/lib/lono/builder/{template/dsl/evaluator/section → dsl/syntax/core}/mapping.rb +1 -1
- data/lib/lono/builder/{template/dsl/evaluator/section → dsl/syntax/core}/output.rb +1 -1
- data/lib/lono/builder/{template/dsl/evaluator/section → dsl/syntax/core}/parameter.rb +1 -1
- data/lib/lono/builder/{template/dsl/evaluator/section → dsl/syntax/core}/resource/property_mover.rb +12 -2
- data/lib/lono/builder/{template/dsl/evaluator/section → dsl/syntax/core}/resource.rb +1 -1
- data/lib/lono/builder/{template/dsl/evaluator/section → dsl/syntax/core}/section.rb +1 -1
- data/lib/lono/builder/dsl/syntax/core/squeezer.rb +40 -0
- data/lib/lono/builder/{template/dsl/evaluator/section/methods.rb → dsl/syntax/core.rb} +2 -2
- data/lib/lono/builder/{template/dsl/evaluator → dsl/syntax}/fn.rb +1 -3
- data/lib/lono/builder/{template/dsl/evaluator → dsl}/syntax/parameter_group.rb +1 -1
- data/lib/lono/builder/dsl/syntax.rb +9 -0
- data/lib/lono/builder/{template/dsl.rb → dsl.rb} +2 -2
- data/lib/lono/builder/param.rb +5 -2
- data/lib/lono/builder/template/upload.rb +2 -15
- data/lib/lono/builder/template.rb +1 -3
- data/lib/lono/builder/{template/dsl/evaluator → util}/stringify.rb +1 -1
- data/lib/lono/builder.rb +39 -0
- data/lib/lono/bundler/component/props/extension.rb +0 -1
- data/lib/lono/bundler/extract/tar.rb +0 -1
- data/lib/lono/bundler/util/git.rb +18 -16
- data/lib/lono/cfn/base.rb +2 -2
- data/lib/lono/cfn/cancel.rb +5 -5
- data/lib/lono/cfn/concerns/build.rb +1 -1
- data/lib/lono/cfn/delete.rb +5 -2
- data/lib/lono/cfn/deploy/iam.rb +1 -2
- data/lib/lono/cfn/deploy/rollback.rb +1 -3
- data/lib/lono/cfn/deploy.rb +46 -5
- data/lib/lono/cfn/download.rb +0 -1
- data/lib/lono/cfn/plan/changeset.rb +3 -3
- data/lib/lono/cfn/plan/diff/data.rb +11 -1
- data/lib/lono/cfn/plan/diff/file.rb +2 -1
- data/lib/lono/cfn/plan/param.rb +1 -1
- data/lib/lono/cfn/plan/template.rb +2 -2
- data/lib/lono/cfn/plan.rb +1 -0
- data/lib/lono/cli/abstract.rb +0 -6
- data/lib/lono/cli/base.rb +6 -3
- data/lib/lono/cli/clean.rb +3 -2
- data/lib/lono/cli/help/cfn/status.md +0 -1
- data/lib/lono/cli/help/new/helper.md +27 -0
- data/lib/lono/cli/help/new/hook.md +14 -0
- data/lib/lono/cli/help/new/project.md +3 -10
- data/lib/lono/cli/help/seed.md +22 -21
- data/lib/lono/cli/iam.rb +27 -0
- data/lib/lono/cli/list.rb +3 -6
- data/lib/lono/cli/new/blueprint.rb +3 -9
- data/lib/lono/cli/new/configset.rb +11 -44
- data/lib/lono/cli/new/helper.rb +19 -11
- data/lib/lono/cli/new/hook.rb +32 -0
- data/lib/lono/cli/new/sequence.rb +6 -1
- data/lib/lono/cli/new.rb +9 -9
- data/lib/lono/cli/s3.rb +3 -3
- data/lib/lono/cli/script/build.rb +0 -5
- data/lib/lono/cli/status.rb +18 -0
- data/lib/lono/{inspector → cli}/summary.rb +23 -33
- data/lib/lono/cli.rb +16 -16
- data/lib/lono/command.rb +28 -2
- data/lib/lono/component.rb +29 -0
- data/lib/lono/concerns/aws_info.rb +14 -0
- data/lib/lono/concerns/names.rb +9 -0
- data/lib/lono/configset.rb +17 -0
- data/lib/lono/core.rb +11 -1
- data/lib/lono/ext/bundler.rb +7 -0
- data/lib/lono/ext/core/module.rb +31 -0
- data/lib/lono/ext/core/object.rb +32 -0
- data/lib/lono/ext/core/string.rb +9 -0
- data/lib/lono/ext.rb +4 -0
- data/lib/lono/files/base.rb +12 -0
- data/lib/lono/{utils → files/builder/lambda_layer}/rsync.rb +3 -5
- data/lib/lono/{app_file/build → files/builder}/lambda_layer/ruby_packager.rb +104 -79
- data/lib/lono/files/builder/lambda_layer/ruby_version.rb +38 -0
- data/lib/lono/files/builder/lambda_layer.rb +17 -0
- data/lib/lono/files/builder.rb +37 -0
- data/lib/lono/files/compressor.rb +53 -0
- data/lib/lono/files/concerns/post_processing.rb +52 -0
- data/lib/lono/files/concerns/registration.rb +16 -0
- data/lib/lono/files/registry.rb +6 -0
- data/lib/lono/files.rb +41 -0
- data/lib/lono/hooks/builder.rb +50 -0
- data/lib/lono/hooks/concern.rb +9 -0
- data/lib/lono/hooks/dsl.rb +20 -0
- data/lib/lono/hooks/runner.rb +46 -0
- data/lib/lono/layering/layer.rb +64 -56
- data/lib/lono/logger.rb +2 -3
- data/lib/lono/names.rb +7 -10
- data/lib/lono/s3/bucket.rb +43 -37
- data/lib/lono/s3/rollback.rb +8 -0
- data/lib/lono/s3/uploader.rb +33 -28
- data/lib/lono/script/build.rb +0 -5
- data/lib/lono/seeder.rb +38 -29
- data/lib/lono/user_data.rb +3 -1
- data/lib/lono/utils/sh.rb +32 -0
- data/lib/lono/utils.rb +5 -0
- data/lib/lono/version.rb +1 -1
- data/lib/lono/yamler/validator.rb +7 -22
- data/lib/lono.rb +8 -0
- data/lib/templates/configset/configset.rb +2 -16
- data/lib/templates/examples/configset/configset.rb +16 -0
- data/lib/templates/helper/%underscore_name%_helper.rb.tt +1 -1
- data/lib/templates/hook/config/hooks.rb.tt +14 -0
- data/lono.gemspec +1 -1
- metadata +99 -93
- data/lib/lono/app_file/base.rb +0 -28
- data/lib/lono/app_file/build/lambda_layer.rb +0 -20
- data/lib/lono/app_file/build.rb +0 -79
- data/lib/lono/app_file/registry/item.rb +0 -24
- data/lib/lono/app_file/registry.rb +0 -16
- data/lib/lono/app_file/upload.rb +0 -12
- data/lib/lono/builder/context/loader/load_files.rb +0 -23
- data/lib/lono/builder/context/loader.rb +0 -35
- data/lib/lono/builder/context/params.rb +0 -7
- data/lib/lono/builder/template/configset_injector.rb +0 -52
- data/lib/lono/builder/template/dsl/evaluator/helpers/core_helper.rb +0 -14
- data/lib/lono/builder/template/dsl/evaluator/helpers/file_helper.rb +0 -44
- data/lib/lono/builder/template/dsl/evaluator/helpers/s3_helper.rb +0 -16
- data/lib/lono/builder/template/dsl/evaluator/helpers.rb +0 -16
- data/lib/lono/builder/template/dsl/evaluator/squeezer.rb +0 -24
- data/lib/lono/builder/template/dsl/evaluator/syntax/extend_with.rb +0 -9
- data/lib/lono/builder/template/dsl/evaluator/syntax.rb +0 -11
- data/lib/lono/builder/template/dsl/evaluator.rb +0 -45
- data/lib/lono/builder/template/dsl/finalizer.rb +0 -12
- data/lib/lono/builder/template/evaluate.rb +0 -52
- data/lib/lono/builder/template/post_processor.rb +0 -67
- data/lib/lono/cli/build.rb +0 -101
- data/lib/lono/cli/code.rb +0 -22
- data/lib/lono/cli/help/blueprint/new.md +0 -56
- data/lib/lono/cli/new/extension.rb +0 -57
- data/lib/lono/configset/builder.rb +0 -59
- data/lib/lono/configset/combiner.rb +0 -164
- data/lib/lono/configset/evaluate_file.rb +0 -8
- data/lib/lono/configset/meta/dsl.rb +0 -12
- data/lib/lono/configset/meta.rb +0 -19
- data/lib/lono/configset/s3_file/build.rb +0 -34
- data/lib/lono/configset/s3_file/item.rb +0 -38
- data/lib/lono/configset/s3_file/registry.rb +0 -12
- data/lib/lono/configset/s3_file/upload.rb +0 -12
- data/lib/lono/configset/strategy/base.rb +0 -83
- data/lib/lono/configset/strategy/helpers/dsl/core.rb +0 -18
- data/lib/lono/configset/strategy/helpers/dsl.rb +0 -8
- data/lib/lono/configset/strategy/helpers/erb.rb +0 -9
- data/lib/lono/extensions/dsl.rb +0 -8
- data/lib/lono/extensions/loader.rb +0 -19
- data/lib/lono/extensions.rb +0 -18
- data/lib/lono/importer/base.rb +0 -48
- data/lib/lono/importer/converter.rb +0 -19
- data/lib/lono/importer/download.rb +0 -46
- data/lib/lono/importer/dsl.rb +0 -36
- data/lib/lono/importer/params.rb +0 -56
- data/lib/lono/importer/service/coder.rb +0 -81
- data/lib/lono/inspector/base.rb +0 -32
- data/lib/lono/lookup.rb +0 -12
- data/lib/lono/seeder/service_role.rb +0 -11
- data/lib/lono/utils/context.rb +0 -15
- data/lib/lono/utils/item/file_methods.rb +0 -29
- data/lib/lono/utils/item/zip.rb +0 -42
- data/lib/templates/extension/lib/%extension_name%/autoloader.rb.tt +0 -23
- data/lib/templates/extension/lib/%extension_name%/helpers/mappings.rb.tt +0 -24
- data/lib/templates/extension/lib/%extension_name%/helpers/outputs.rb.tt +0 -7
- data/lib/templates/extension/lib/%extension_name%/helpers/parameters.rb.tt +0 -10
- data/lib/templates/extension/lib/%extension_name%/helpers/resources/resource.rb.tt +0 -4
- data/lib/templates/extension/lib/%extension_name%/helpers/variables.rb.tt +0 -6
- data/lib/templates/extension/lib/%extension_name%/version.rb.tt +0 -3
- data/lib/templates/extension/lib/%extension_name%.rb.tt +0 -8
data/lib/lono/app_file/build.rb
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
require "thor"
|
2
|
-
|
3
|
-
module Lono::AppFile
|
4
|
-
class Build < Base
|
5
|
-
include Lono::Utils::Item::Zip
|
6
|
-
|
7
|
-
def initialize_variables
|
8
|
-
@output_files_path = "#{Lono.root}/output/#{@blueprint.name}/files"
|
9
|
-
end
|
10
|
-
|
11
|
-
def run
|
12
|
-
return unless detect_files?
|
13
|
-
logger.info "Building app/files"
|
14
|
-
build_all
|
15
|
-
end
|
16
|
-
|
17
|
-
def build_all
|
18
|
-
clean_output
|
19
|
-
validate_files!
|
20
|
-
copy_to_output
|
21
|
-
build_layers
|
22
|
-
compress_output
|
23
|
-
end
|
24
|
-
|
25
|
-
def validate_files!
|
26
|
-
items = Registry.items + Registry.layers
|
27
|
-
missing = items.select do |item|
|
28
|
-
!File.exist?(item.src_path)
|
29
|
-
end
|
30
|
-
missing_paths = missing.map { |item| item.src_path }.uniq
|
31
|
-
unless missing_paths.empty?
|
32
|
-
logger.info "ERROR: These app/files are missing were used by the s3_key method but are missing".color(:red)
|
33
|
-
missing_paths.each do |path|
|
34
|
-
logger.info " #{path}"
|
35
|
-
end
|
36
|
-
logger.info "Please double check that they exist."
|
37
|
-
exit 1
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def build_layers
|
42
|
-
layer_items = Registry.layers
|
43
|
-
layer_items.each do |item|
|
44
|
-
LambdaLayer.new(@blueprint, item).build
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def compress_output
|
49
|
-
Registry.items.each do |item|
|
50
|
-
# type can be lambda_layer or file
|
51
|
-
if item.type == "lambda_layer" || item.exist?
|
52
|
-
zip(item)
|
53
|
-
else
|
54
|
-
logger.info "WARN: #{item.src_path} does not exist. Double check that the path is correct in the s3_key call.".color(:yellow)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def copy_to_output
|
60
|
-
override_source_paths("#{@blueprint.root}/app/files")
|
61
|
-
self.destination_root = @output_files_path
|
62
|
-
directory(".", verbose: false, context: context.get_binding) # Thor::Action
|
63
|
-
end
|
64
|
-
|
65
|
-
def clean_output
|
66
|
-
FileUtils.rm_rf(@output_files_path)
|
67
|
-
end
|
68
|
-
|
69
|
-
def detect_files?
|
70
|
-
app_files = Dir["#{@blueprint.root}/app/files/*"]
|
71
|
-
if app_files.empty?
|
72
|
-
false
|
73
|
-
else
|
74
|
-
logger.info "Detected app/files"
|
75
|
-
true
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
class Lono::AppFile::Registry
|
2
|
-
# Holds metadata about the item in the regsitry.
|
3
|
-
class Item
|
4
|
-
include Lono::Utils::Item::FileMethods
|
5
|
-
|
6
|
-
attr_reader :name, :options, :type
|
7
|
-
def initialize(name, blueprint, options={})
|
8
|
-
@name, @blueprint.name, @options = name, blueprint, options
|
9
|
-
@type = options[:type] || "file"
|
10
|
-
end
|
11
|
-
|
12
|
-
def src_path
|
13
|
-
"#{@blueprint.root}/app/files/#{@name}"
|
14
|
-
end
|
15
|
-
|
16
|
-
def output_path
|
17
|
-
if @type == "file"
|
18
|
-
"#{Lono.root}/output/#{@blueprint.name}/files/#{@name}"
|
19
|
-
else
|
20
|
-
"#{Lono.root}/output/#{@blueprint.name}/lambda_layers/#{@name}/opt"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Lono::AppFile
|
2
|
-
class Registry
|
3
|
-
cattr_reader :items
|
4
|
-
@@items = []
|
5
|
-
|
6
|
-
class << self
|
7
|
-
def register(name, blueprint, options={})
|
8
|
-
@@items << Item.new(name, blueprint, options) unless @@items.detect { |i| i.name == name && i.type == options[:type] }
|
9
|
-
end
|
10
|
-
|
11
|
-
def layers
|
12
|
-
@@items.select { |i| i.type == "lambda_layer" }
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
data/lib/lono/app_file/upload.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
module Lono::Builder::Context::Loader
|
2
|
-
module LoadFiles
|
3
|
-
# Load custom helper methods from project
|
4
|
-
def load_files(dir)
|
5
|
-
paths = Dir.glob("#{dir}/**/*.rb")
|
6
|
-
paths.sort_by! { |p| p.size } # so namespaces are loaded first
|
7
|
-
paths.each do |path|
|
8
|
-
# helpers = blueprint or project extensions
|
9
|
-
filename = path.sub(%r{.*/helpers/},'').sub('.rb','')
|
10
|
-
module_name = filename.camelize
|
11
|
-
|
12
|
-
# Prepend a period so require works LONO_ROOT is set to a relative path without a period.
|
13
|
-
#
|
14
|
-
# Example: LONO_ROOT=tmp/lono_project
|
15
|
-
first_char = path[0..0]
|
16
|
-
path = "./#{path}" unless %w[. /].include?(first_char)
|
17
|
-
|
18
|
-
require path
|
19
|
-
self.class.send :include, module_name.constantize
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
class Lono::Builder::Context
|
2
|
-
module Loader
|
3
|
-
include LoadFiles
|
4
|
-
|
5
|
-
# Variables in base.rb are overridden by their environment specific variables
|
6
|
-
# file. Example, file LONO_ENV=dev:
|
7
|
-
#
|
8
|
-
# config/vars/base.rb
|
9
|
-
# config/vars/dev.rb - will override any variables in base.rb
|
10
|
-
# config/vars/base.rb
|
11
|
-
# config/vars/dev.rb - will override any variables in base.rb
|
12
|
-
#
|
13
|
-
def load_variables
|
14
|
-
layers = Lono::Layering::Layer.new(@blueprint, "vars").paths
|
15
|
-
layers.each do |layer|
|
16
|
-
evaluate_variables_file(layer)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
# Load the variables defined in config/vars/* to make available in lono scope.
|
21
|
-
#
|
22
|
-
# NOTE: Was only able to make instance variables avaialble with instance_eval, wasnt able to make local variables
|
23
|
-
# available.
|
24
|
-
def evaluate_variables_file(path)
|
25
|
-
return unless File.exist?(path)
|
26
|
-
instance_eval(IO.read(path), path)
|
27
|
-
end
|
28
|
-
|
29
|
-
# Load blueprint helpers
|
30
|
-
# blueprint helpers override extension helpers
|
31
|
-
def load_blueprint_helpers
|
32
|
-
load_files("#{@blueprint.root}/#{Lono.config.paths.helpers}")
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
class Lono::Builder::Template
|
2
|
-
class ConfigsetInjector < Lono::CLI::Base
|
3
|
-
def initialize(options={})
|
4
|
-
super
|
5
|
-
end
|
6
|
-
|
7
|
-
def run
|
8
|
-
@cfn = load_template # initial
|
9
|
-
@cfn = inject # overwrite
|
10
|
-
write(@cfn)
|
11
|
-
@cfn
|
12
|
-
end
|
13
|
-
|
14
|
-
def inject
|
15
|
-
metadata_map.each do |logical_id, metadata_configset|
|
16
|
-
resource = @cfn["Resources"][logical_id]
|
17
|
-
|
18
|
-
unless resource
|
19
|
-
logger.info "WARN: Resources.#{logical_id} not found in the template. Are you sure you are specifying the correct resource id in your configsets configs?".color(:yellow)
|
20
|
-
next
|
21
|
-
end
|
22
|
-
|
23
|
-
resource["Metadata"] ||= metadata_configset["Metadata"]
|
24
|
-
|
25
|
-
# metdata = resource["Metadata"] ||= {}
|
26
|
-
# metdata["AWS::CloudFormation::Init"] ||= {}
|
27
|
-
# # The metadata_configset has been combined with the original AWS::CloudFormation::Init if it exists
|
28
|
-
# metdata["AWS::CloudFormation::Init"] = metadata_configset["AWS::CloudFormation::Init"]
|
29
|
-
end
|
30
|
-
|
31
|
-
@cfn
|
32
|
-
end
|
33
|
-
|
34
|
-
def metadata_map
|
35
|
-
combiner = Lono::Configset::Combiner.new(@cfn, @options)
|
36
|
-
combiner.metadata_map
|
37
|
-
end
|
38
|
-
memoize :metadata_map
|
39
|
-
|
40
|
-
def write(cfn)
|
41
|
-
IO.write(template_path, YAML.dump(cfn))
|
42
|
-
end
|
43
|
-
|
44
|
-
def load_template
|
45
|
-
YAML.load_file(template_path)
|
46
|
-
end
|
47
|
-
|
48
|
-
def template_path
|
49
|
-
"#{Lono.root}/output/#{@blueprint.name}/templates/#{@template}.yml"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
module Lono::Builder::Template::Dsl::Evaluator::Helpers
|
2
|
-
module FileHelper
|
3
|
-
extend Memoist
|
4
|
-
|
5
|
-
def user_data(path)
|
6
|
-
render_file(Lono.config.paths.user_data, path)
|
7
|
-
end
|
8
|
-
|
9
|
-
def user_data_script
|
10
|
-
unless @user_data_script
|
11
|
-
return <<~EOL
|
12
|
-
# @user_data_script variable not set. IE: @user_data_script = "config/#{@blueprint.name}/user_data/boostrap.sh"
|
13
|
-
# Also, make sure that "config/#{@blueprint.name}/user_data/boostrap.sh" path you're using exists.
|
14
|
-
EOL
|
15
|
-
end
|
16
|
-
|
17
|
-
if File.exist?(@user_data_script)
|
18
|
-
render_path(@user_data_script)
|
19
|
-
else
|
20
|
-
message = "WARN: #{@user_data_script} not found"
|
21
|
-
logger.info message.color(:yellow)
|
22
|
-
"# #{message}"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def render_file(folder, path)
|
27
|
-
path = "#{folder}/#{path}"
|
28
|
-
if File.exist?(path)
|
29
|
-
render_path(path)
|
30
|
-
else
|
31
|
-
message = "WARNING: path #{path} not found"
|
32
|
-
logger.info message.color(:yellow)
|
33
|
-
logger.info "Called from:"
|
34
|
-
logger.info caller[2]
|
35
|
-
message
|
36
|
-
end
|
37
|
-
end
|
38
|
-
memoize :render_file
|
39
|
-
|
40
|
-
def render_path(path)
|
41
|
-
RenderMePretty.result(path, context: self)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Lono::Builder::Template::Dsl::Evaluator::Helpers
|
2
|
-
module S3Helper
|
3
|
-
def s3_bucket
|
4
|
-
Lono::S3::Bucket.name
|
5
|
-
end
|
6
|
-
alias_method :lono_bucket_name, :s3_bucket
|
7
|
-
|
8
|
-
def s3_key(name, options={})
|
9
|
-
default = {type: "file"}
|
10
|
-
options.reverse_merge!(default)
|
11
|
-
Lono::AppFile::Registry.register(name, @blueprint.name, options)
|
12
|
-
"file://app/files/#{options[:type]}/#{name}" # placeholder for post processing
|
13
|
-
end
|
14
|
-
alias_method :file_s3_key, :s3_key
|
15
|
-
end
|
16
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# Built-in helpers for the DSL form
|
2
|
-
class Lono::Builder::Template::Dsl::Evaluator
|
3
|
-
module Helpers
|
4
|
-
extend Memoist
|
5
|
-
|
6
|
-
# Auto include all modules in helpers folder
|
7
|
-
helpers_dir = File.expand_path("helpers", __dir__)
|
8
|
-
Dir.glob("#{helpers_dir}/**/*").each do |path|
|
9
|
-
next unless File.file?(path)
|
10
|
-
klass = path.gsub(%r{.*/lib/},'').sub(".rb",'').camelize
|
11
|
-
include klass.constantize
|
12
|
-
end
|
13
|
-
|
14
|
-
include Lono::Builder::Template::Helpers
|
15
|
-
end
|
16
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
class Lono::Builder::Template::Dsl::Evaluator
|
2
|
-
class Squeezer
|
3
|
-
def initialize(data)
|
4
|
-
@data = data
|
5
|
-
end
|
6
|
-
|
7
|
-
def squeeze(new_data=nil)
|
8
|
-
data = new_data.nil? ? @data : new_data
|
9
|
-
|
10
|
-
case data
|
11
|
-
when Array
|
12
|
-
data.map! { |v| squeeze(v) }
|
13
|
-
when Hash
|
14
|
-
data.each_with_object({}) do |(k,v), squeezed|
|
15
|
-
# only remove nil and empty Array values within Hash structures
|
16
|
-
squeezed[k] = squeeze(v) unless v.nil? || v.is_a?(Array) && v.empty?
|
17
|
-
squeezed
|
18
|
-
end
|
19
|
-
else
|
20
|
-
data # do not transform
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,9 +0,0 @@
|
|
1
|
-
module Lono::Builder::Template::Dsl::Evaluator::Syntax
|
2
|
-
module ExtendWith
|
3
|
-
def extend_with(extension)
|
4
|
-
# Do nothing during the main DSL evaluation. The extend_with logical actual runs during during the
|
5
|
-
# pre_evalation stage before project helpers are loaded. This allows project helper to override extend helpers.
|
6
|
-
# Define the method here it does not error though.
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
# Encapsulates syntax methods so they can be included in both the Evaluator and Context scope
|
2
|
-
class Lono::Builder::Template::Dsl::Evaluator
|
3
|
-
module Syntax
|
4
|
-
include Fn
|
5
|
-
include Lono::Builder::Template::Evaluate
|
6
|
-
include Section::Methods
|
7
|
-
include ParameterGroup
|
8
|
-
include ExtendWith
|
9
|
-
include Helpers # built-in helpers
|
10
|
-
end
|
11
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
class Lono::Builder::Template::Dsl
|
2
|
-
class Evaluator
|
3
|
-
include Lono::Extensions::Loader
|
4
|
-
include Lono::Utils::Context
|
5
|
-
include Lono::Builder::Context::Loader
|
6
|
-
|
7
|
-
include Syntax
|
8
|
-
extend Memoist
|
9
|
-
|
10
|
-
def initialize(options={})
|
11
|
-
@options = options
|
12
|
-
@blueprint = Lono::Blueprint.new(options)
|
13
|
-
@template_path = "#{@blueprint.root}/template.rb"
|
14
|
-
@parameters = [] # registry
|
15
|
-
@cfn = {}
|
16
|
-
end
|
17
|
-
|
18
|
-
def build
|
19
|
-
# TODO: load_all_extension_helpers # after Extensions::Preparer#run
|
20
|
-
load_variables unless seed? # both blueprint and project variables
|
21
|
-
load_blueprint_helpers
|
22
|
-
evaluate_template_paths(@template_path) # modifies @cfn
|
23
|
-
finalize
|
24
|
-
to_yaml
|
25
|
-
@cfn
|
26
|
-
end
|
27
|
-
|
28
|
-
def finalize
|
29
|
-
o = @options.merge(parameters: @parameters)
|
30
|
-
@cfn = Finalizer.new(@cfn, o).run
|
31
|
-
end
|
32
|
-
|
33
|
-
def to_yaml
|
34
|
-
# https://stackoverflow.com/questions/24508364/how-to-emit-yaml-in-ruby-expanding-aliases
|
35
|
-
# Trick to prevent YAML from emitting aliases
|
36
|
-
@cfn = YAML.load(@cfn.to_json)
|
37
|
-
end
|
38
|
-
|
39
|
-
# Dont want any existing files to prevent building the blueprint.
|
40
|
-
# This means that parameters cannot be based on vars. It's a trade-off.
|
41
|
-
def seed?
|
42
|
-
ARGV[0] == "seed"
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
class Lono::Builder::Template
|
2
|
-
module Evaluate
|
3
|
-
include Lono::Utils::Logging
|
4
|
-
|
5
|
-
# Example path: /full/path/to/project/app/blueprints/demo/template.rb
|
6
|
-
def evaluate_template_paths(path)
|
7
|
-
ext = File.extname(path)
|
8
|
-
folder = path.sub(ext, '')
|
9
|
-
expr = "#{folder}/**/*.rb"
|
10
|
-
evaluate_template_path(path) # process top-level template.rb first
|
11
|
-
Dir.glob(expr).each do |path|
|
12
|
-
evaluate_template_path(path)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def evaluate_template_path(path)
|
17
|
-
return unless File.exist?(path)
|
18
|
-
begin
|
19
|
-
instance_eval(File.read(path), path)
|
20
|
-
rescue Exception => e
|
21
|
-
template_evaluation_error(e)
|
22
|
-
logger.error "\nFull error:"
|
23
|
-
raise
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
# Prints out a user friendly task_definition error message
|
28
|
-
def template_evaluation_error(e)
|
29
|
-
lines = e.backtrace.reject { |l| l.include?("/lib/lono/") }
|
30
|
-
error_info = lines.first
|
31
|
-
path, line_no, _ = error_info.split(':')
|
32
|
-
line_no = line_no.to_i
|
33
|
-
logger.error "Error evaluating #{path}:".color(:red)
|
34
|
-
logger.error e.message
|
35
|
-
logger.error "Here's the line in #{path} with the error:\n\n"
|
36
|
-
|
37
|
-
contents = IO.read(path)
|
38
|
-
content_lines = contents.split("\n")
|
39
|
-
context = 5 # lines of context
|
40
|
-
top, bottom = [line_no-context-1, 0].max, line_no+context-1
|
41
|
-
spacing = content_lines.size.to_s.size
|
42
|
-
content_lines[top..bottom].each_with_index do |line_content, index|
|
43
|
-
line_number = top+index+1
|
44
|
-
if line_number == line_no
|
45
|
-
printf("%#{spacing}d %s\n".color(:red), line_number, line_content)
|
46
|
-
else
|
47
|
-
printf("%#{spacing}d %s\n", line_number, line_content)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
class Lono::Builder::Template
|
2
|
-
class PostProcessor < Lono::CLI::Base
|
3
|
-
def run
|
4
|
-
replacements.each do |placeholder, replacement|
|
5
|
-
update_template!(template)
|
6
|
-
end
|
7
|
-
write_template!
|
8
|
-
end
|
9
|
-
|
10
|
-
def write_template!
|
11
|
-
IO.write(template_path, YAML.dump(template)) # unless ENV['LONO_TEST'] # additional safeguard for testing
|
12
|
-
end
|
13
|
-
|
14
|
-
def replacements
|
15
|
-
map = {}
|
16
|
-
|
17
|
-
registry_items.each do |item|
|
18
|
-
if item.type == "lambda_layer"
|
19
|
-
placeholder = "file://app/files/lambda_layer/#{item.name}"
|
20
|
-
elsif item.directory? || item.file?
|
21
|
-
placeholder = "file://app/files/file/#{item.name}"
|
22
|
-
else
|
23
|
-
logger.info "WARN: PostProcessor replacements Cannot find file: #{item.output_path}"
|
24
|
-
next
|
25
|
-
end
|
26
|
-
map[placeholder] = item.s3_path
|
27
|
-
end
|
28
|
-
|
29
|
-
Lono::Configset::S3File::Registry.items.each do |item|
|
30
|
-
placeholder = "file://configset/#{item.configset}/#{item.name}"
|
31
|
-
# map[placeholder] = "https://s3.amazonaws.com/#{Lono::S3::Bucket.name}/#{item.s3_path}"
|
32
|
-
map[placeholder] = item.replacement_value
|
33
|
-
end
|
34
|
-
|
35
|
-
map
|
36
|
-
end
|
37
|
-
|
38
|
-
def update_template!(hash)
|
39
|
-
hash.each do |k, v|
|
40
|
-
if v.is_a?(String)
|
41
|
-
if v =~ %r{^file://}
|
42
|
-
v.replace(replacements[v]) # replace the placeholder
|
43
|
-
end
|
44
|
-
elsif v.is_a?(Hash)
|
45
|
-
update_template!(v) # recurse
|
46
|
-
elsif v.is_a?(Array)
|
47
|
-
v.each { |x| update_template!(x) if x.is_a?(Hash) }
|
48
|
-
end
|
49
|
-
end
|
50
|
-
hash
|
51
|
-
end
|
52
|
-
|
53
|
-
# Useful for specs
|
54
|
-
def registry_items
|
55
|
-
Lono::AppFile::Registry.items
|
56
|
-
end
|
57
|
-
|
58
|
-
def template
|
59
|
-
YAML.load_file(template_path)
|
60
|
-
end
|
61
|
-
memoize :template
|
62
|
-
|
63
|
-
def template_path
|
64
|
-
"#{Lono.root}/output/#{@blueprint.name}/templates/#{@template}.yml"
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
data/lib/lono/cli/build.rb
DELETED
@@ -1,101 +0,0 @@
|
|
1
|
-
class Lono::CLI
|
2
|
-
class Build < Base
|
3
|
-
delegate :param_path, to: :param_builder
|
4
|
-
|
5
|
-
# Use class variable to cache this only runs once across all classes. base.rb, diff.rb, preview.rb
|
6
|
-
def all
|
7
|
-
ensure_s3_bucket_exist unless build_only?
|
8
|
-
pre_build
|
9
|
-
build_template # build with some placeholders for build_files IE: file://app/files/my.rb
|
10
|
-
post_build
|
11
|
-
upload unless build_only?
|
12
|
-
|
13
|
-
parameters = param_builder.build # Writes the json file in CamelCase keys format
|
14
|
-
logger.info "" # newline
|
15
|
-
parameters
|
16
|
-
end
|
17
|
-
memoize :all
|
18
|
-
|
19
|
-
def parameters
|
20
|
-
all
|
21
|
-
end
|
22
|
-
|
23
|
-
def build_only?
|
24
|
-
ENV['LONO_BUILD_ONLY'] || @options[:build_only]
|
25
|
-
end
|
26
|
-
|
27
|
-
def pre_build
|
28
|
-
build_scripts
|
29
|
-
end
|
30
|
-
|
31
|
-
def post_build
|
32
|
-
return if @options[:source]
|
33
|
-
build_files # builds app/files to output/BLUEPRINT/files
|
34
|
-
post_process_template
|
35
|
-
end
|
36
|
-
|
37
|
-
def ensure_s3_bucket_exist
|
38
|
-
bucket = Lono::S3::Bucket.new
|
39
|
-
return if bucket.exist?
|
40
|
-
bucket.deploy
|
41
|
-
end
|
42
|
-
|
43
|
-
def build_scripts
|
44
|
-
Lono::Script::Build.new(@options).run
|
45
|
-
end
|
46
|
-
|
47
|
-
def build_files
|
48
|
-
Lono::AppFile::Build.new(@options).run
|
49
|
-
Lono::Configset::S3File::Build.new(@options).run # copies files to the output folder
|
50
|
-
end
|
51
|
-
|
52
|
-
def build_template
|
53
|
-
template_builder.run
|
54
|
-
inject_configsets
|
55
|
-
end
|
56
|
-
|
57
|
-
def inject_configsets
|
58
|
-
# The inject_configsets reads it back from disk. Leaving as-is instead of reading all in memory in case there's a reason.
|
59
|
-
# TODO Lono::Builder::Template::ConfigsetInjector.new(@options).run
|
60
|
-
end
|
61
|
-
|
62
|
-
def post_process_template
|
63
|
-
# support for file://app/files/lambda_layer replacement
|
64
|
-
# TODO: Lono::Builder::Template::PostProcessor.new(@options).run
|
65
|
-
end
|
66
|
-
|
67
|
-
def upload
|
68
|
-
upload_files
|
69
|
-
upload_scripts
|
70
|
-
upload_templates
|
71
|
-
end
|
72
|
-
|
73
|
-
def upload_templates
|
74
|
-
Lono::Builder::Template::Upload.new(@options).run
|
75
|
-
end
|
76
|
-
|
77
|
-
def upload_scripts
|
78
|
-
Lono::Script::Upload.new(@options).run
|
79
|
-
end
|
80
|
-
|
81
|
-
def upload_files
|
82
|
-
Lono::AppFile::Upload.new(@options).upload
|
83
|
-
Lono::Configset::S3File::Upload.new(@options).upload
|
84
|
-
end
|
85
|
-
|
86
|
-
def param_builder
|
87
|
-
o = {
|
88
|
-
regenerate: true,
|
89
|
-
allow_not_exists: true,
|
90
|
-
}.merge(@options)
|
91
|
-
o = HashWithIndifferentAccess.new(o)
|
92
|
-
Lono::Builder::Param.new(o)
|
93
|
-
end
|
94
|
-
memoize :param_builder
|
95
|
-
|
96
|
-
def template_builder
|
97
|
-
Lono::Builder::Template.new(@options) # write templates to disk
|
98
|
-
end
|
99
|
-
memoize :template_builder
|
100
|
-
end
|
101
|
-
end
|