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.
- checksums.yaml +4 -4
- 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 +56 -2
- data/Gemfile +1 -3
- 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 -23
- 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 +40 -0
- data/lib/lono/builder/dsl/evaluator.rb +6 -55
- data/lib/lono/builder/dsl/finalizer/base.rb +8 -0
- data/lib/lono/builder/dsl/finalizer/configsets.rb +7 -28
- 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/dsl/finalizer/parameter_groups.rb +4 -3
- data/lib/lono/builder/dsl/finalizer.rb +4 -2
- data/lib/lono/builder/dsl/helpers/ec2.rb +16 -3
- data/lib/lono/builder/dsl/helpers/files.rb +7 -0
- data/lib/lono/builder/dsl/helpers/partials.rb +48 -53
- data/lib/lono/builder/dsl/helpers/s3.rb +5 -7
- data/lib/lono/builder/dsl/helpers/ssm/fetcher.rb +3 -1
- data/lib/lono/builder/dsl/helpers/stack.rb +2 -4
- data/lib/lono/builder/dsl/helpers/template_file.rb +23 -29
- data/lib/lono/builder/dsl/helpers.rb +1 -11
- data/lib/lono/builder/dsl/syntax/core/resource/property_mover.rb +11 -1
- data/lib/lono/builder/dsl/syntax/core/squeezer.rb +19 -3
- data/lib/lono/builder/dsl/syntax/fn.rb +0 -2
- data/lib/lono/builder/dsl.rb +2 -2
- data/lib/lono/builder/param.rb +7 -2
- data/lib/lono/builder/template/upload.rb +2 -15
- data/lib/lono/builder/template.rb +1 -3
- data/lib/lono/builder.rb +39 -0
- 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 -1
- data/lib/lono/cfn/deploy/operable.rb +1 -1
- data/lib/lono/cfn/deploy/rollback.rb +1 -3
- data/lib/lono/cfn/deploy.rb +23 -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/param.rb +1 -1
- data/lib/lono/cfn/plan/template.rb +2 -2
- data/lib/lono/cfn/plan.rb +26 -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/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/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/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 +15 -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 +1 -3
- data/lib/lono/names.rb +7 -10
- data/lib/lono/s3/bucket.rb +17 -11
- data/lib/lono/s3/uploader.rb +33 -28
- data/lib/lono/script/build.rb +0 -5
- data/lib/lono/seeder.rb +19 -28
- data/lib/lono/user_data.rb +3 -1
- data/lib/lono/utils/call_line.rb +9 -0
- 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/lib/templates/project/Gemfile.tt +2 -7
- data/lono.gemspec +1 -1
- metadata +73 -62
- 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/generic.rb +0 -11
- data/lib/lono/builder/context/loaders/load_files.rb +0 -23
- data/lib/lono/builder/context/loaders.rb +0 -35
- data/lib/lono/builder/context/params.rb +0 -6
- data/lib/lono/builder/context/template.rb +0 -4
- data/lib/lono/builder/template/post_processor.rb +0 -67
- data/lib/lono/cli/build.rb +0 -91
- 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/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 -85
- 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/contexts.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/cli/new/helper.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
class Lono::CLI::New
|
2
|
-
class Helper < Sequence
|
2
|
+
class Helper < Lono::CLI::New::Sequence
|
3
3
|
def self.cli_options
|
4
|
+
# required for name => underscore_name => app/blueprints/demo/helpers/%underscore_name%_helper.rb.tt
|
5
|
+
argument :name, default: "custom", desc: "Helper name"
|
6
|
+
|
4
7
|
[
|
5
8
|
[:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"],
|
6
|
-
[:blueprint,
|
7
|
-
[:name, default: "custom", desc: "Helper name"],
|
9
|
+
[:blueprint, aliases: :b, desc: "Blueprint name. Only use you want a blueprint helper. Otherwise a project helper is generated"],
|
8
10
|
]
|
9
11
|
end
|
10
12
|
cli_options.each do |args|
|
@@ -15,18 +17,24 @@ class Lono::CLI::New
|
|
15
17
|
set_template_source "helper"
|
16
18
|
end
|
17
19
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
20
|
+
def create_helper
|
21
|
+
if @options[:blueprint]
|
22
|
+
create_blueprint_helper
|
23
|
+
else
|
24
|
+
create_project_helper
|
25
|
+
end
|
21
26
|
end
|
22
27
|
|
23
|
-
|
24
|
-
|
25
|
-
|
28
|
+
private
|
29
|
+
def create_blueprint_helper
|
30
|
+
@blueprint = @options[:blueprint] # allows %underscore_name%_helper.rb.tt to access @blueprint
|
31
|
+
logger.info "=> Generating #{underscore_name}_helper.rb"
|
26
32
|
directory ".", "app/blueprints/#{@blueprint}/helpers"
|
27
33
|
end
|
28
34
|
|
29
|
-
|
30
|
-
|
35
|
+
def create_project_helper
|
36
|
+
logger.info "=> Generating #{underscore_name}_helper.rb"
|
37
|
+
directory ".", "app/helpers/#{underscore_name}"
|
38
|
+
end
|
31
39
|
end
|
32
40
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class Lono::CLI::New
|
2
|
+
class Hook < Lono::CLI::New::Sequence
|
3
|
+
def self.cli_options
|
4
|
+
[
|
5
|
+
[:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"],
|
6
|
+
[:blueprint, aliases: :b, desc: "Blueprint name. Only use you want a blueprint helper. Otherwise a project helper is generated"],
|
7
|
+
]
|
8
|
+
end
|
9
|
+
cli_options.each do |args|
|
10
|
+
class_option(*args)
|
11
|
+
end
|
12
|
+
|
13
|
+
def set_source
|
14
|
+
set_template_source "hook"
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_hook
|
18
|
+
logger.info "=> Generating hook"
|
19
|
+
if blueprint
|
20
|
+
directory ".", "app/blueprints/#{blueprint}"
|
21
|
+
else
|
22
|
+
directory ".", "."
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
# So templates/hooks/config/hooks.rb.tt has access to blueprint
|
28
|
+
def blueprint
|
29
|
+
@options[:blueprint]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -12,7 +12,8 @@ class Lono::CLI::New
|
|
12
12
|
|
13
13
|
private
|
14
14
|
def self.set_template_source(folder)
|
15
|
-
|
15
|
+
path = File.expand_path("../../../templates/#{folder}", __dir__)
|
16
|
+
source_root path
|
16
17
|
end
|
17
18
|
|
18
19
|
def set_template_source(*paths)
|
@@ -47,5 +48,9 @@ class Lono::CLI::New
|
|
47
48
|
puts "=> Initialize git repo"
|
48
49
|
run("git init")
|
49
50
|
end
|
51
|
+
|
52
|
+
def env
|
53
|
+
Lono.env # allows for seed/vars/%env%.rb.tt
|
54
|
+
end
|
50
55
|
end
|
51
56
|
end
|
data/lib/lono/cli/new.rb
CHANGED
@@ -2,27 +2,27 @@ class Lono::CLI
|
|
2
2
|
class New < Lono::Command
|
3
3
|
long_desc Help.text("new/blueprint")
|
4
4
|
Blueprint.cli_options.each { |args| option(*args) }
|
5
|
-
register(Blueprint, "blueprint", "blueprint NAME", "
|
5
|
+
register(Blueprint, "blueprint", "blueprint NAME", "Generate new blueprint")
|
6
6
|
|
7
7
|
long_desc Help.text("new/configset")
|
8
8
|
Configset.cli_options.each { |args| option(*args) }
|
9
|
-
register(Configset, "configset", "configset NAME", "
|
10
|
-
|
11
|
-
long_desc Help.text("new/extension")
|
12
|
-
Extension.cli_options.each { |args| option(*args) }
|
13
|
-
register(Extension, "extension", "extension NAME", "Generates new extension.")
|
9
|
+
register(Configset, "configset", "configset NAME", "Generate new configset")
|
14
10
|
|
15
11
|
long_desc Help.text("new/helper")
|
16
12
|
Helper.cli_options.each { |args| option(*args) }
|
17
|
-
register(Helper, "helper", "helper NAME", "
|
13
|
+
register(Helper, "helper", "helper NAME", "Generate new helper")
|
14
|
+
|
15
|
+
long_desc Help.text("new/hook")
|
16
|
+
Hook.cli_options.each { |args| option(*args) }
|
17
|
+
register(Hook, "hook", "hook NAME", "Generate new hook")
|
18
18
|
|
19
19
|
long_desc Help.text("new/project")
|
20
20
|
Project.cli_options.each { |args| option(*args) }
|
21
|
-
register(Project, "project", "project NAME", "
|
21
|
+
register(Project, "project", "project NAME", "Generate new project")
|
22
22
|
|
23
23
|
long_desc Help.text("new/shim")
|
24
24
|
Shim.cli_options.each { |args| option(*args) }
|
25
|
-
register(Shim, "shim", "shim NAME", "
|
25
|
+
register(Shim, "shim", "shim NAME", "Generate new shim")
|
26
26
|
|
27
27
|
desc "test SUBCOMMAND", "test subcommands"
|
28
28
|
long_desc Help.text(:test)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Lono::CLI
|
2
|
+
class Status < Lono::CLI::Base
|
3
|
+
include Lono::AwsServices
|
4
|
+
|
5
|
+
def run
|
6
|
+
names = Lono::Names.new(@options)
|
7
|
+
stack = find_stack(@stack)
|
8
|
+
if stack
|
9
|
+
status = Lono::Cfn::Status.new(@stack, @options)
|
10
|
+
success = status.run
|
11
|
+
exit 1 unless success
|
12
|
+
else
|
13
|
+
logger.error "ERROR: stack #{@stack} not found".color(:red)
|
14
|
+
exit 1
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -1,32 +1,27 @@
|
|
1
|
-
|
1
|
+
class Lono::CLI
|
2
2
|
class Summary < Base
|
3
|
+
include Lono::Cfn::Concerns::Build
|
3
4
|
include Lono::Cfn::Concerns::TemplateOutput
|
4
5
|
|
5
|
-
def
|
6
|
-
|
7
|
-
@template = template
|
8
|
-
|
9
|
-
logger.info "=> CloudFormation Template Summary for template #{@template.color(:sienna)}:"
|
10
|
-
return if ENV['LONO_NOOP']
|
11
|
-
|
6
|
+
def run
|
7
|
+
build.all
|
12
8
|
print_parameters_summary
|
13
|
-
logger.info "# Resources:"
|
14
9
|
print_resource_types
|
15
10
|
end
|
16
11
|
|
17
12
|
def print_parameters_summary
|
18
13
|
parameters = template_output.parameters
|
14
|
+
logger.info "Parameters (#{parameters.size})".color(:green)
|
19
15
|
parameter_groups = template_output.parameter_groups
|
20
16
|
|
21
17
|
if parameters.empty?
|
22
|
-
logger.info "
|
18
|
+
logger.info "No parameters"
|
23
19
|
return
|
24
20
|
end
|
25
21
|
|
26
22
|
shown = []
|
27
|
-
|
28
|
-
|
29
|
-
logger.info "# Parameter Group (#{parameters.size}): #{label}".color(:sienna)
|
23
|
+
parameter_groups.each do |parameter_group_label, parameters|
|
24
|
+
logger.info parameter_group_label
|
30
25
|
parameters.each do |name|
|
31
26
|
logger.info parameter_line(name)
|
32
27
|
shown << name
|
@@ -40,13 +35,11 @@ module Lono::Inspector
|
|
40
35
|
|
41
36
|
def parameter_line(name)
|
42
37
|
data = template_output.parameters[name]
|
43
|
-
example = description_example(data["Description"])
|
44
38
|
if data["Default"].nil?
|
45
|
-
line = "#{name}
|
39
|
+
line = " #{name} (required)"
|
46
40
|
else
|
47
41
|
default = data["Default"]
|
48
|
-
line = "# #{name}=#{default}"
|
49
|
-
line = "#{line} # #{example}" if example
|
42
|
+
line = default.blank? ? " #{name}" : " #{name}=#{default}"
|
50
43
|
end
|
51
44
|
line
|
52
45
|
end
|
@@ -59,18 +52,9 @@ module Lono::Inspector
|
|
59
52
|
md[2]
|
60
53
|
end
|
61
54
|
|
62
|
-
def resource_types
|
63
|
-
resources = template_output.data["Resources"]
|
64
|
-
return unless resources
|
65
|
-
|
66
|
-
types = Hash.new(0)
|
67
|
-
resources.each do |logical_id, resource|
|
68
|
-
types[resource["Type"]] += 1
|
69
|
-
end
|
70
|
-
types
|
71
|
-
end
|
72
|
-
|
73
55
|
def print_resource_types
|
56
|
+
total = template_output.data["Resources"].size
|
57
|
+
logger.info "Resources (#{total})".color(:green)
|
74
58
|
unless resource_types
|
75
59
|
logger.info "No resources found."
|
76
60
|
return
|
@@ -79,15 +63,21 @@ module Lono::Inspector
|
|
79
63
|
types = resource_types.sort_by {|r| r[1] * -1} # Hash -> 2D Array
|
80
64
|
types.each do |a|
|
81
65
|
type, count = a
|
82
|
-
printf "%
|
66
|
+
printf "%5s %s\n", count, type
|
83
67
|
end
|
84
68
|
total = types.inject(0) { |sum,(type,count)| sum += count }
|
85
|
-
printf "%
|
69
|
+
printf "%5s %s\n", total, "Total"
|
86
70
|
end
|
87
71
|
|
88
|
-
def
|
89
|
-
|
72
|
+
def resource_types
|
73
|
+
resources = template_output.data["Resources"]
|
74
|
+
return unless resources
|
75
|
+
|
76
|
+
types = Hash.new(0)
|
77
|
+
resources.each do |logical_id, resource|
|
78
|
+
types[resource["Type"]] += 1
|
79
|
+
end
|
80
|
+
types
|
90
81
|
end
|
91
|
-
memoize :template_output
|
92
82
|
end
|
93
83
|
end
|
data/lib/lono/cli.rb
CHANGED
@@ -5,12 +5,12 @@ module Lono
|
|
5
5
|
opts = Opts.new(self)
|
6
6
|
cfn_opts = Lono::CLI::Cfn::Opts.new(self)
|
7
7
|
|
8
|
-
desc "build BLUEPRINT", "Build
|
8
|
+
desc "build BLUEPRINT", "Build template"
|
9
9
|
long_desc Help.text(:build)
|
10
10
|
option :quiet, type: :boolean, desc: "silence the output"
|
11
11
|
opts.clean
|
12
12
|
def build(blueprint)
|
13
|
-
|
13
|
+
Lono::Builder.new(options.merge(blueprint: blueprint, build_only: true)).all
|
14
14
|
end
|
15
15
|
|
16
16
|
desc "bundle", "Bundle with Lonofile."
|
@@ -25,14 +25,20 @@ module Lono
|
|
25
25
|
Clean.new(options).run
|
26
26
|
end
|
27
27
|
|
28
|
-
desc "down BLUEPRINT", "Delete
|
28
|
+
desc "down BLUEPRINT", "Delete stack"
|
29
29
|
long_desc Help.text(:down)
|
30
30
|
cfn_opts.delete
|
31
31
|
def down(blueprint)
|
32
32
|
Lono::Cfn::Delete.new(options.merge(blueprint: blueprint)).run
|
33
33
|
end
|
34
34
|
|
35
|
-
desc "
|
35
|
+
desc "iam BLUEPRINT", "Generate IAM policy"
|
36
|
+
long_desc Help.text(:down)
|
37
|
+
def iam(blueprint)
|
38
|
+
Iam.new(options.merge(blueprint: blueprint)).run
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "list", "List blueprints"
|
36
42
|
long_desc Help.text(:list)
|
37
43
|
option :type, aliases: :t, desc: "Type: IE: blueprint, configset, extension. Defaults to all"
|
38
44
|
def list
|
@@ -41,12 +47,12 @@ module Lono
|
|
41
47
|
|
42
48
|
desc "output BLUEPRINT", "output or preview of the deploy"
|
43
49
|
long_desc Help.text(:output)
|
44
|
-
option :format, desc: "Output formats: #{CliFormat.formats.join(', ')}"
|
50
|
+
option :format, aliases: :f, desc: "Output formats: #{CliFormat.formats.join(', ')}"
|
45
51
|
def output(blueprint)
|
46
52
|
Lono::Cfn::Output.new(options.merge(blueprint: blueprint)).run
|
47
53
|
end
|
48
54
|
|
49
|
-
desc "plan BLUEPRINT", "
|
55
|
+
desc "plan BLUEPRINT", "Preview deploy"
|
50
56
|
long_desc Help.text(:plan)
|
51
57
|
option :out, aliases: :o, desc: "Write Change Set info to path"
|
52
58
|
def plan(blueprint)
|
@@ -71,16 +77,13 @@ module Lono
|
|
71
77
|
desc "status BLUEPRINT", "Shows current status of blueprint."
|
72
78
|
long_desc Help.text(:status)
|
73
79
|
def status(blueprint)
|
74
|
-
|
75
|
-
status = Lono::Cfn::Status.new(names.stack, options)
|
76
|
-
success = status.run
|
77
|
-
exit 3 unless success
|
80
|
+
Status.new(options.merge(blueprint: blueprint)).run
|
78
81
|
end
|
79
82
|
|
80
83
|
desc "summary BLUEPRINT", "Prints summary of CloudFormation template"
|
81
84
|
long_desc Help.text("summary")
|
82
85
|
def summary(blueprint)
|
83
|
-
|
86
|
+
Summary.new(options.merge(blueprint: blueprint)).run
|
84
87
|
end
|
85
88
|
|
86
89
|
desc "test", "Run test."
|
@@ -89,7 +92,7 @@ module Lono
|
|
89
92
|
Test.new(options).run
|
90
93
|
end
|
91
94
|
|
92
|
-
desc "up BLUEPRINT", "Deploy
|
95
|
+
desc "up BLUEPRINT", "Deploy stack"
|
93
96
|
long_desc Help.text(:up)
|
94
97
|
cfn_opts.deploy
|
95
98
|
def up(blueprint)
|
@@ -125,10 +128,6 @@ module Lono
|
|
125
128
|
long_desc Help.text(:cfn)
|
126
129
|
subcommand "cfn", Cfn
|
127
130
|
|
128
|
-
desc "code SUBCOMMAND", "code subcommands"
|
129
|
-
long_desc Help.text(:code)
|
130
|
-
subcommand "code", Code
|
131
|
-
|
132
131
|
desc "new SUBCOMMAND", "new subcommands"
|
133
132
|
long_desc Help.text(:new)
|
134
133
|
subcommand "new", New
|
data/lib/lono/command.rb
CHANGED
@@ -37,6 +37,7 @@ module Lono
|
|
37
37
|
# Lono.argv provides consistency when lono is being called by rspec-lono test harness
|
38
38
|
Lono.argv = args.clone # important to clone since Thor removes the first argv
|
39
39
|
|
40
|
+
check_version_structure!
|
40
41
|
check_project!(args.first)
|
41
42
|
|
42
43
|
# Allow calling for help via:
|
@@ -48,7 +49,6 @@ module Lono
|
|
48
49
|
# as well thor's normal way:
|
49
50
|
#
|
50
51
|
# lono help command
|
51
|
-
help_flags = Thor::HELP_MAPPINGS + ["help"]
|
52
52
|
if args.length > 1 && !(args & help_flags).empty?
|
53
53
|
args -= help_flags
|
54
54
|
args.insert(-2, "help")
|
@@ -69,13 +69,39 @@ module Lono
|
|
69
69
|
return if subcommand?
|
70
70
|
return if command_name.nil?
|
71
71
|
return if help_flags.include?(Lono.argv.last) # IE: -h help
|
72
|
-
return if
|
72
|
+
return if non_project_command?
|
73
73
|
return if File.exist?("#{Lono.root}/config/app.rb")
|
74
74
|
return unless Lono.check_project
|
75
75
|
logger.error "ERROR: It doesnt look like this is a lono project. Are you sure you are in a lono project?".color(:red)
|
76
76
|
ENV['LONO_TEST'] ? raise : exit(1)
|
77
77
|
end
|
78
78
|
|
79
|
+
# Also, using ARGV instead of args because args is called by thor in multiple passes
|
80
|
+
# For `lono new project`:
|
81
|
+
# * 1st pass: "new"
|
82
|
+
# * 2nd pass: "project"
|
83
|
+
def non_project_command?
|
84
|
+
commands = %w[-h -v --version completion completion_script help new test version]
|
85
|
+
commands.include?(ARGV[0])
|
86
|
+
end
|
87
|
+
|
88
|
+
def check_version_structure!
|
89
|
+
return if non_project_command?
|
90
|
+
return unless File.exist?('configs')
|
91
|
+
puts "ERROR: Old lono project structure detected".color(:red)
|
92
|
+
puts <<~EOL
|
93
|
+
It looks like this Lono project with an old structure.
|
94
|
+
The old structure does not work with this version of Lono.
|
95
|
+
|
96
|
+
Current Installed Lono Version: #{Lono::VERSION}
|
97
|
+
|
98
|
+
Please upgrade the lono project structure.
|
99
|
+
|
100
|
+
See: https://lono.com/docs/upgrading/version8/
|
101
|
+
EOL
|
102
|
+
exit 1
|
103
|
+
end
|
104
|
+
|
79
105
|
def help_flags
|
80
106
|
Thor::HELP_MAPPINGS + ["help"]
|
81
107
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Lono
|
2
|
+
class Component
|
3
|
+
attr_reader :name
|
4
|
+
def initialize(options={})
|
5
|
+
@options = options
|
6
|
+
@name = options[:name]
|
7
|
+
end
|
8
|
+
|
9
|
+
def type
|
10
|
+
self.class.name.to_s.split('::').last.underscore # IE: blueprint
|
11
|
+
end
|
12
|
+
|
13
|
+
def exist?
|
14
|
+
!root.nil?
|
15
|
+
end
|
16
|
+
|
17
|
+
def type_dir
|
18
|
+
type.pluralize # IE: blueprints
|
19
|
+
end
|
20
|
+
|
21
|
+
def root
|
22
|
+
paths = Dir.glob("#{Lono.root}/{app,vendor}/#{type_dir}/*")
|
23
|
+
paths.find do |path|
|
24
|
+
found = path.sub(%r{.*/(app|vendor)/}, '')
|
25
|
+
found == "#{type_dir}/#{@name}" # exact match
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Dont name AwsData. Think prefer AwsInfo vs AwsConcern
|
2
|
+
module Lono::Concerns
|
3
|
+
module AwsInfo
|
4
|
+
extend Memoist
|
5
|
+
delegate :region, to: :aws_data
|
6
|
+
alias_method :aws_region, :region
|
7
|
+
alias_method :current_region, :region
|
8
|
+
|
9
|
+
def aws_data
|
10
|
+
AwsData.new
|
11
|
+
end
|
12
|
+
memoize :aws_data
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Lono
|
2
|
+
class Configset < Component
|
3
|
+
attr_reader :resource
|
4
|
+
attr_accessor :metadata
|
5
|
+
def initialize(options={})
|
6
|
+
super
|
7
|
+
@resource = options[:resource]
|
8
|
+
end
|
9
|
+
|
10
|
+
def path
|
11
|
+
return unless root
|
12
|
+
exts = %w[rb yml json] # rb highest precedence
|
13
|
+
paths = exts.map { |ext| "#{root}/configset.#{ext}" }
|
14
|
+
paths.find { |p| File.exist?(p) }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/lono/core.rb
CHANGED
@@ -19,11 +19,21 @@ module Lono
|
|
19
19
|
end
|
20
20
|
memoize :app
|
21
21
|
|
22
|
+
def role
|
23
|
+
ENV['LONO_ROLE']
|
24
|
+
end
|
25
|
+
memoize :role
|
26
|
+
|
22
27
|
def env
|
23
28
|
ENV['LONO_ENV'] || 'dev'
|
24
29
|
end
|
25
30
|
memoize :env
|
26
31
|
|
32
|
+
def extra
|
33
|
+
ENV['LONO_EXTRA']
|
34
|
+
end
|
35
|
+
memoize :extra
|
36
|
+
|
27
37
|
def tmp_root
|
28
38
|
ENV['LONO_TMP_ROOT'] || "/tmp/lono"
|
29
39
|
end
|
@@ -37,7 +47,7 @@ module Lono
|
|
37
47
|
App.instance.configure(&block)
|
38
48
|
end
|
39
49
|
|
40
|
-
# Generally, use the
|
50
|
+
# Generally, use the Lono.config instead of App.instance.config since it guarantees the load_project_config call
|
41
51
|
def config
|
42
52
|
App.instance.load_project_config
|
43
53
|
App.instance.config
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class Module
|
2
|
+
# Include all modules within the relative folder. IE: for dsl/syntax/mod/*
|
3
|
+
#
|
4
|
+
# include Common
|
5
|
+
# include Provider
|
6
|
+
# # etc
|
7
|
+
#
|
8
|
+
# Caller lines are different for OSes:
|
9
|
+
#
|
10
|
+
# windows: "C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/lono-1.1.1/lib/lono/builder.rb:34:in `build'"
|
11
|
+
# linux: "/home/ec2-user/.rvm/gems/ruby-3.0.3/gems/lono-1.1.1/lib/lono/compiler/dsl/syntax/mod.rb:4:in `<module:Mod>'"
|
12
|
+
#
|
13
|
+
def include_modules(dir)
|
14
|
+
caller_line = caller[0]
|
15
|
+
parts = caller_line.split(':')
|
16
|
+
calling_file = caller_line.match(/^[a-zA-Z]:/) ? parts[1] : parts[0]
|
17
|
+
parent_dir = File.dirname(calling_file)
|
18
|
+
|
19
|
+
full_dir = "#{parent_dir}/#{dir}"
|
20
|
+
paths = Dir.glob("#{full_dir}/**/*.rb")
|
21
|
+
if paths.empty?
|
22
|
+
raise "Empty include_modules full_dir: #{full_dir}"
|
23
|
+
end
|
24
|
+
paths.each do |path|
|
25
|
+
regexp = Regexp.new(".*/lib/")
|
26
|
+
mod = path.sub(regexp, '').sub('.rb','').camelize
|
27
|
+
c = mod.constantize
|
28
|
+
include c if c.class == Module
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class Object
|
2
|
+
# Load custom helper methods from project
|
3
|
+
def load_helper_files(dir, type: :blueprint)
|
4
|
+
paths = Dir.glob("#{dir}/**/*.rb")
|
5
|
+
paths.sort_by! { |p| p.size } # so namespaces are loaded first
|
6
|
+
paths.each do |path|
|
7
|
+
next unless File.file?(path)
|
8
|
+
|
9
|
+
filename = if type == :project
|
10
|
+
path.sub(%r{.*/helpers/[a-zA-Z\-_]+/},'').sub('.rb','')
|
11
|
+
else # blueprint, configset
|
12
|
+
path.sub(%r{.*/helpers/},'').sub('.rb','')
|
13
|
+
end
|
14
|
+
module_name = filename.camelize
|
15
|
+
|
16
|
+
# Prepend a period so require works when LONO_ROOT is set to a relative path without a period.
|
17
|
+
# Example: LONO_ROOT=tmp/lono_project
|
18
|
+
first_char = path[0..0]
|
19
|
+
path = "./#{path}" unless %w[. /].include?(first_char)
|
20
|
+
|
21
|
+
# Examples:
|
22
|
+
# project:
|
23
|
+
# path: app/helpers/custom/custom_helper.rb
|
24
|
+
# module_name: CustomHelper
|
25
|
+
# blueprint:
|
26
|
+
# path: app/blueprints/demo/helpers/outputs.rb
|
27
|
+
# module_name: Outputs
|
28
|
+
require path
|
29
|
+
self.class.send :include, module_name.constantize
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/lono/ext.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
class Lono::Files
|
2
|
+
class Base < Lono::CLI::Base
|
3
|
+
delegate :full_path, :output_path, :zip_name, :zip_path, to: :files
|
4
|
+
attr_reader :files
|
5
|
+
def initialize(options={})
|
6
|
+
super
|
7
|
+
# @files is reference to Lono::Files self instance
|
8
|
+
# IE: Lono::Files instance is the caller
|
9
|
+
@files = options[:files]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -1,13 +1,11 @@
|
|
1
1
|
require 'shellwords'
|
2
2
|
|
3
|
-
|
3
|
+
class Lono::Files::Builder::LambdaLayer
|
4
4
|
module Rsync
|
5
|
-
include Lono::Utils::Logging
|
6
|
-
|
7
5
|
def sh(command)
|
8
|
-
logger.
|
6
|
+
logger.debug "=> #{command}"
|
9
7
|
out = `#{command}`
|
10
|
-
logger.
|
8
|
+
logger.debug out
|
11
9
|
success = $?.success?
|
12
10
|
raise("ERROR: running command #{command}").color(:red) unless success
|
13
11
|
success
|