lono 8.0.0.pre.rc2 → 8.0.0.pre.rc3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -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 +22 -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 +29 -0
- data/lib/lono/{configset/strategy/helpers/dsl → builder/configset/definition/dsl/syntax}/auth.rb +1 -1
- data/lib/lono/{configset/strategy/helpers/dsl/core.rb → builder/configset/definition/dsl/syntax/content.rb} +12 -4
- 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 +58 -0
- data/lib/lono/builder/dsl/finalizer/files/replace.rb +31 -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/files.rb +7 -0
- data/lib/lono/builder/dsl/helpers/partials.rb +48 -53
- data/lib/lono/builder/dsl/helpers/s3.rb +1 -1
- data/lib/lono/builder/dsl/helpers/ssm/fetcher.rb +3 -1
- data/lib/lono/builder/dsl/helpers/template_file.rb +18 -6
- 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 +16 -2
- data/lib/lono/builder/dsl.rb +1 -1
- data/lib/lono/builder/param.rb +4 -1
- data/lib/lono/builder/template/upload.rb +2 -15
- data/lib/lono/cfn/cancel.rb +5 -5
- data/lib/lono/cfn/deploy/iam.rb +1 -1
- data/lib/lono/cfn/deploy.rb +32 -3
- data/lib/lono/cfn/download.rb +0 -1
- data/lib/lono/cfn/plan/changeset.rb +2 -2
- 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 +1 -0
- data/lib/lono/cli/abstract.rb +0 -6
- data/lib/lono/cli/base.rb +5 -3
- data/lib/lono/cli/build.rb +16 -60
- data/lib/lono/cli/clean.rb +3 -2
- data/lib/lono/cli/code.rb +12 -12
- data/lib/lono/cli/help/new/helper/blueprint.md +17 -0
- data/lib/lono/cli/help/new/helper/project.md +16 -0
- data/lib/lono/cli/list.rb +3 -6
- data/lib/lono/cli/new/blueprint.rb +3 -7
- data/lib/lono/cli/new/configset.rb +11 -44
- data/lib/lono/cli/new/helper/blueprint.rb +26 -0
- data/lib/lono/cli/new/helper/project.rb +24 -0
- data/lib/lono/cli/new/helper.rb +8 -27
- data/lib/lono/cli/new/sequence.rb +6 -1
- data/lib/lono/cli/new.rb +8 -12
- data/lib/lono/cli/status.rb +18 -0
- data/lib/lono/cli.rb +6 -9
- data/lib/lono/command.rb +0 -1
- 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 +1 -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/files/builder.rb +37 -0
- data/lib/lono/files/compressor.rb +53 -0
- data/lib/lono/files/concerns/post_processing.rb +35 -0
- data/lib/lono/files/concerns/registration.rb +13 -0
- data/lib/lono/files/registry.rb +6 -0
- data/lib/lono/files.rb +37 -0
- data/lib/lono/importer/base.rb +1 -1
- data/lib/lono/inspector/summary.rb +0 -3
- data/lib/lono/layering/layer.rb +3 -17
- data/lib/lono/logger.rb +1 -3
- data/lib/lono/names.rb +1 -1
- data/lib/lono/s3/uploader.rb +29 -28
- data/lib/lono/seeder.rb +18 -27
- data/lib/lono/user_data.rb +3 -1
- 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/lono.gemspec +1 -1
- metadata +52 -39
- data/lib/lono/app_file/base.rb +0 -28
- data/lib/lono/app_file/build/lambda_layer/ruby_packager.rb +0 -153
- 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/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.rb +0 -8
- data/lib/lono/configset/strategy/helpers/erb.rb +0 -9
- 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
@@ -15,8 +15,8 @@ module Lono::Builder::Dsl::Helpers
|
|
15
15
|
|
16
16
|
# Caller lines are different for OSes:
|
17
17
|
#
|
18
|
-
# windows: "C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/
|
19
|
-
# linux: "/home/ec2-user/.rvm/gems/ruby-3.0.3/gems/
|
18
|
+
# windows: "C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/lono-1.1.1/lib/lono/builder.rb:34:in `build'"
|
19
|
+
# 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>'"
|
20
20
|
#
|
21
21
|
class TempleFileNotFoundError < StandardError; end
|
22
22
|
def template_file_missing(path)
|
@@ -30,15 +30,27 @@ module Lono::Builder::Dsl::Helpers
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def render_file(path)
|
33
|
-
|
33
|
+
if File.exist?(path)
|
34
|
+
RenderMePretty.result(path, context: self)
|
35
|
+
else
|
36
|
+
lines = caller.select { |l| l.include?(Lono.root.to_s) } # TODO: show code itself
|
37
|
+
caller_line = pretty_path(lines.first)
|
38
|
+
message =<<~EOL
|
39
|
+
WARN: #{pretty_path(path)} does not exist
|
40
|
+
Called from: #{caller_line}
|
41
|
+
EOL
|
42
|
+
logger.info message.color(:yellow)
|
43
|
+
message
|
44
|
+
end
|
34
45
|
end
|
35
|
-
|
46
|
+
alias_method :render_path, :render_file
|
36
47
|
|
37
48
|
def user_data_script
|
38
49
|
unless @user_data_script
|
50
|
+
script_example = pretty_path("#{@blueprint.root}/template/user_data.sh")
|
39
51
|
return <<~EOL
|
40
|
-
# @user_data_script variable not set. IE: @user_data_script = "#{
|
41
|
-
# Also, make sure that "
|
52
|
+
# @user_data_script variable not set. IE: @user_data_script = "#{script_example}"
|
53
|
+
# Also, make sure that "#{script_example}" exists.
|
42
54
|
EOL
|
43
55
|
end
|
44
56
|
|
@@ -1,15 +1,5 @@
|
|
1
|
-
# Built-in helpers for the DSL form
|
2
1
|
class Lono::Builder::Dsl
|
3
2
|
module Helpers
|
4
|
-
|
5
|
-
|
6
|
-
# Auto include all modules in helpers folder
|
7
|
-
# only load one level deep. IE: ssm/fetcher is a class
|
8
|
-
helpers_dir = File.expand_path("helpers", __dir__)
|
9
|
-
Dir.glob("#{helpers_dir}/*.rb").each do |path|
|
10
|
-
next unless File.file?(path)
|
11
|
-
klass = path.gsub(%r{.*/lib/},'').sub(".rb",'').camelize
|
12
|
-
include klass.constantize
|
13
|
-
end
|
3
|
+
include_modules("helpers")
|
14
4
|
end
|
15
5
|
end
|
@@ -5,8 +5,18 @@ class Lono::Builder::Dsl::Syntax::Core::Resource
|
|
5
5
|
@resource, @logical_id, @properties = resource, logical_id, properties
|
6
6
|
end
|
7
7
|
|
8
|
+
# AWS Docs: Resource attribute reference
|
9
|
+
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-product-attribute-reference.html
|
8
10
|
def move!
|
9
|
-
%w[
|
11
|
+
%w[
|
12
|
+
Condition
|
13
|
+
CreationPolicy
|
14
|
+
DeletionPolicy
|
15
|
+
DependsOn
|
16
|
+
Metadata
|
17
|
+
UpdatePolicy
|
18
|
+
UpdateReplacePolicy
|
19
|
+
].each do |attribute_name|
|
10
20
|
# Account for camelize, underscore, String, and Symbol
|
11
21
|
move(attribute_name.to_sym)
|
12
22
|
move(attribute_name.camelize.to_sym)
|
@@ -4,7 +4,7 @@ module Lono::Builder::Dsl::Syntax::Core
|
|
4
4
|
@data = data
|
5
5
|
end
|
6
6
|
|
7
|
-
def squeeze(new_data=nil)
|
7
|
+
def squeeze(new_data=nil, previous_key=nil)
|
8
8
|
data = new_data.nil? ? @data : new_data
|
9
9
|
|
10
10
|
case data
|
@@ -13,12 +13,26 @@ module Lono::Builder::Dsl::Syntax::Core
|
|
13
13
|
when Hash
|
14
14
|
data.each_with_object({}) do |(k,v), squeezed|
|
15
15
|
# only remove nil and empty Array values within Hash structures
|
16
|
-
squeezed[k] = squeeze(v) unless v.nil? ||
|
16
|
+
squeezed[k] = squeeze(v, k) unless v.nil? # || empty_array?(v, previous_key)
|
17
17
|
squeezed
|
18
18
|
end
|
19
19
|
else
|
20
20
|
data # do not transform
|
21
21
|
end
|
22
22
|
end
|
23
|
+
|
24
|
+
# Special case do not squeeze empty Array when previous_key is "yum". Handles:
|
25
|
+
#
|
26
|
+
# Metadata:
|
27
|
+
# AWS::CloudFormation::Init:
|
28
|
+
# config:
|
29
|
+
# packages:
|
30
|
+
# yum:
|
31
|
+
# httpd: []
|
32
|
+
#
|
33
|
+
def empty_array?(v, previous_key)
|
34
|
+
return false if previous_key.to_s == "yum"
|
35
|
+
v.is_a?(Array) && v.empty?
|
36
|
+
end
|
23
37
|
end
|
24
38
|
end
|
data/lib/lono/builder/dsl.rb
CHANGED
data/lib/lono/builder/param.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
module Lono::Builder
|
2
2
|
class Param < Lono::CLI::Base
|
3
3
|
attr_reader :env_path, :base_path # set when build is called
|
4
|
+
include Lono::Builder::Dsl::Syntax
|
5
|
+
# Overriding output resource DSL method
|
6
|
+
alias_method :output, :stack_output
|
4
7
|
|
5
8
|
def build
|
6
9
|
logger.info "Building parameters"
|
@@ -36,7 +39,7 @@ module Lono::Builder
|
|
36
39
|
def render_erb(path)
|
37
40
|
return unless path
|
38
41
|
if File.exist?(path)
|
39
|
-
RenderMePretty.result(path, context:
|
42
|
+
RenderMePretty.result(path, context: self)
|
40
43
|
end
|
41
44
|
end
|
42
45
|
|
@@ -1,21 +1,8 @@
|
|
1
|
-
require 'erb'
|
2
|
-
require 'json'
|
3
|
-
require 'base64'
|
4
|
-
require 'digest'
|
5
|
-
|
6
1
|
class Lono::Builder::Template
|
7
2
|
class Upload < Lono::CLI::Base
|
8
|
-
def initialize(options={})
|
9
|
-
super
|
10
|
-
@checksums = {}
|
11
|
-
@prefix = Lono.env # s3://s3-bucket/development
|
12
|
-
end
|
13
|
-
|
14
3
|
def run
|
15
|
-
|
16
|
-
|
17
|
-
Lono::S3::Uploader.new(path).upload
|
18
|
-
end
|
4
|
+
path = "#{Lono.root}/output/#{@blueprint.name}/template.yml"
|
5
|
+
Lono::S3::Uploader.new(path).upload
|
19
6
|
end
|
20
7
|
end
|
21
8
|
end
|
data/lib/lono/cfn/cancel.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
module Lono::Cfn
|
2
2
|
class Cancel < Base
|
3
3
|
def run
|
4
|
-
stack = find_stack(@
|
4
|
+
stack = find_stack(@stack_name)
|
5
5
|
unless stack
|
6
|
-
logger.info "The '#{@
|
6
|
+
logger.info "The '#{@stack_name}' stack does not exist. Unable to cancel"
|
7
7
|
quit 1
|
8
8
|
end
|
9
9
|
|
10
|
-
logger.info "Canceling updates to #{@
|
10
|
+
logger.info "Canceling updates to #{@stack_name}."
|
11
11
|
logger.info "Current stack status: #{stack.stack_status}"
|
12
12
|
if stack.stack_status == "CREATE_IN_PROGRESS"
|
13
|
-
cfn.delete_stack(stack_name: @
|
13
|
+
cfn.delete_stack(stack_name: @stack_name)
|
14
14
|
logger.info "Canceling stack creation."
|
15
15
|
elsif stack.stack_status == "UPDATE_IN_PROGRESS"
|
16
|
-
cfn.cancel_update_stack(stack_name: @
|
16
|
+
cfn.cancel_update_stack(stack_name: @stack_name)
|
17
17
|
logger.info "Canceling stack update."
|
18
18
|
status.wait if @options[:wait]
|
19
19
|
else
|
data/lib/lono/cfn/deploy/iam.rb
CHANGED
@@ -23,7 +23,7 @@ class Lono::Cfn::Deploy
|
|
23
23
|
|
24
24
|
#{command_with_iam(capabilities)}
|
25
25
|
|
26
|
-
You can also avoid this prompt
|
26
|
+
You can also avoid this prompt by setting config.up.capabilities in config/app.rb
|
27
27
|
See: https://lono.cloud/docs/config/reference/
|
28
28
|
|
29
29
|
EOL
|
data/lib/lono/cfn/deploy.rb
CHANGED
@@ -20,20 +20,37 @@ module Lono::Cfn
|
|
20
20
|
yes = iam.rerun?(e)
|
21
21
|
retry if yes
|
22
22
|
rescue Aws::CloudFormation::Errors::ValidationError => e
|
23
|
-
|
23
|
+
case e.message
|
24
|
+
when /No updates/ # No updates are to be performed.
|
24
25
|
logger.info "WARN: #{e.message}".color(:yellow)
|
25
|
-
|
26
|
+
when /UPDATE_ROLLBACK_FAILED/ # https://amzn.to/2IiEjc5
|
26
27
|
rollback.continue_update
|
28
|
+
when /YAML not well-formed/ # happens if a value is a serialize Ruby Object. See: https://gist.github.com/tongueroo/737531d0bc8c92d92b5cd00493e15d9e
|
29
|
+
# e.message: Template format error: YAML not well-formed. (line 207, column 9)
|
30
|
+
print_code(e)
|
27
31
|
else
|
28
32
|
logger.info "ERROR: #{e.message}".color(:red)
|
33
|
+
logger.info "Check: #{pretty_path(@blueprint.output_path)}"
|
29
34
|
quit 1
|
30
35
|
end
|
31
36
|
end
|
32
37
|
|
38
|
+
def print_code(exception)
|
39
|
+
md = exception.message.match(/line (\d+),/)
|
40
|
+
line_number = md[1]
|
41
|
+
logger.error "Template for debugging: #{pretty_path(@blueprint.output_path)}"
|
42
|
+
if md
|
43
|
+
DslEvaluator.print_code(@blueprint.output_path, line_number)
|
44
|
+
exit 1
|
45
|
+
else
|
46
|
+
raise
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
33
50
|
def create
|
34
51
|
plan.for_create
|
35
52
|
@sure || sure?("Going to create stack #{@stack} with blueprint #{@blueprint.name}.")
|
36
|
-
|
53
|
+
upload_files
|
37
54
|
options = {
|
38
55
|
stack_name: @stack,
|
39
56
|
parameters: build.parameters,
|
@@ -53,9 +70,21 @@ module Lono::Cfn
|
|
53
70
|
operable.check!
|
54
71
|
changeset = plan.for_update
|
55
72
|
!changeset.changed? || @sure || sure?("Are you sure you want to update the #{@stack} stack?")
|
73
|
+
upload_files
|
56
74
|
changeset.execute_change_set
|
57
75
|
end
|
58
76
|
|
77
|
+
# Upload files right before create_stack or execute_change_set
|
78
|
+
# Its better to upload here as part of a deploy vs a build
|
79
|
+
# IE: lono build should try not to do a remote write to s3 if possible
|
80
|
+
def upload_files
|
81
|
+
# Files built and compressed in
|
82
|
+
# Lono::Builder::Dsl::Finalizer::Files::Build#build_files
|
83
|
+
Lono::Files.files.each do |file| # using singular file, but is like a "file_list"
|
84
|
+
file.upload
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
59
88
|
def create?
|
60
89
|
!stack_exists?(@stack)
|
61
90
|
end
|
data/lib/lono/cfn/download.rb
CHANGED
@@ -8,7 +8,7 @@ class Lono::Cfn::Plan
|
|
8
8
|
def create
|
9
9
|
@build.all
|
10
10
|
@changed = false
|
11
|
-
logger.info "Change Set Changes:".color(:green) if Lono.config.
|
11
|
+
logger.info "Change Set Changes:".color(:green) if Lono.config.plan.changeset
|
12
12
|
preview_change_set
|
13
13
|
logger.info "" # newline
|
14
14
|
end
|
@@ -83,7 +83,7 @@ class Lono::Cfn::Plan
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def display(change_set)
|
86
|
-
return unless Lono.config.
|
86
|
+
return unless Lono.config.plan.changeset
|
87
87
|
case change_set.status
|
88
88
|
when "CREATE_COMPLETE"
|
89
89
|
display_changes(change_set)
|
@@ -29,7 +29,7 @@ module Lono::Cfn::Plan::Diff
|
|
29
29
|
unless @modified_keys.empty?
|
30
30
|
logger.info "Modified:"
|
31
31
|
@modified_keys.each do |k|
|
32
|
-
logger.info " #{k}: #{@old[k]} -> #{@new[k]}"
|
32
|
+
logger.info " #{k}: #{show_old(@old[k])} -> #{@new[k]}"
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -38,6 +38,16 @@ module Lono::Cfn::Plan::Diff
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
def show_old(v)
|
42
|
+
if v.nil?
|
43
|
+
'(unset)'
|
44
|
+
elsif v == ''
|
45
|
+
"''"
|
46
|
+
else
|
47
|
+
v
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
41
51
|
def calculate
|
42
52
|
@added_keys = @new.keys - @old.keys
|
43
53
|
@removed_keys = @old.keys - @new.keys
|
data/lib/lono/cfn/plan/param.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
class Lono::Cfn::Plan
|
2
2
|
class Param < Base
|
3
3
|
def run
|
4
|
-
return unless Lono.config.
|
4
|
+
return unless Lono.config.plan.params && stack_exists?(@stack)
|
5
5
|
logger.info "Parameter Changes:".color(:green)
|
6
6
|
write_to_tmp(existing_path, existing_params)
|
7
7
|
write_to_tmp(new_path, new_params)
|
@@ -1,11 +1,11 @@
|
|
1
1
|
class Lono::Cfn::Plan
|
2
2
|
class Template < Base
|
3
3
|
def run
|
4
|
-
return unless Lono.config.
|
4
|
+
return unless Lono.config.plan.template
|
5
5
|
@build.all
|
6
6
|
logger.info "Template Changes:".color(:green)
|
7
7
|
download_existing_cfn_template
|
8
|
-
diff = Diff::File.new(mode: Lono.config.
|
8
|
+
diff = Diff::File.new(mode: Lono.config.plan.template)
|
9
9
|
diff.show(existing_template_path, new_cfn_template)
|
10
10
|
logger.info "" # newline
|
11
11
|
end
|
data/lib/lono/cfn/plan.rb
CHANGED
data/lib/lono/cli/abstract.rb
CHANGED
@@ -1,16 +1,10 @@
|
|
1
1
|
class Lono::CLI
|
2
2
|
class Abstract
|
3
3
|
extend Memoist
|
4
|
-
include Lono::Utils::Contexts
|
5
4
|
include Lono::Utils::Logging
|
6
5
|
include Lono::Utils::Pretty
|
7
6
|
|
8
7
|
def initialize(options={})
|
9
|
-
reinitialize(options)
|
10
|
-
end
|
11
|
-
|
12
|
-
# Hack so that we can use include Thor::Base
|
13
|
-
def reinitialize(options)
|
14
8
|
@options = options
|
15
9
|
end
|
16
10
|
end
|
data/lib/lono/cli/base.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
class Lono::CLI
|
2
2
|
class Base < Abstract
|
3
|
-
|
3
|
+
include Lono::Concerns::Names
|
4
|
+
|
5
|
+
def initialize(options={})
|
4
6
|
super
|
5
|
-
@blueprint = Lono::Blueprint.new(options)
|
6
|
-
@stack =
|
7
|
+
@blueprint = Lono::Blueprint.new(options.merge(name: options[:blueprint]))
|
8
|
+
@stack = names.stack
|
7
9
|
end
|
8
10
|
end
|
9
11
|
end
|
data/lib/lono/cli/build.rb
CHANGED
@@ -1,85 +1,36 @@
|
|
1
1
|
class Lono::CLI
|
2
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
3
|
def all
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
4
|
+
check_allow!
|
5
|
+
Clean.new(@options.merge(mute: true)).run
|
6
|
+
ensure_s3_bucket_exist
|
7
|
+
template_builder.run # build with placeholders IE: file://app/files/index.rb
|
8
|
+
upload_templates
|
13
9
|
parameters = param_builder.build # Writes the json file in CamelCase keys format
|
14
10
|
logger.info "" # newline
|
15
11
|
parameters
|
16
12
|
end
|
17
13
|
memoize :all
|
14
|
+
alias_method :parameters, :all
|
18
15
|
|
19
|
-
def
|
20
|
-
|
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
|
16
|
+
def check_allow!
|
17
|
+
Lono::Builder::Allow.new(@options).check!
|
35
18
|
end
|
36
19
|
|
37
20
|
def ensure_s3_bucket_exist
|
21
|
+
return unless upload?
|
38
22
|
bucket = Lono::S3::Bucket.new
|
39
23
|
return if bucket.exist?
|
40
24
|
bucket.deploy
|
41
25
|
end
|
42
26
|
|
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 post_process_template
|
53
|
-
# support for file://app/files/lambda_layer replacement
|
54
|
-
# TODO: Lono::Builder::Template::PostProcessor.new(@options).run
|
55
|
-
end
|
56
|
-
|
57
|
-
def upload
|
58
|
-
upload_files
|
59
|
-
upload_scripts
|
60
|
-
upload_templates
|
61
|
-
end
|
62
|
-
|
63
27
|
def upload_templates
|
28
|
+
return unless upload?
|
64
29
|
Lono::Builder::Template::Upload.new(@options).run
|
65
30
|
end
|
66
31
|
|
67
|
-
def upload_scripts
|
68
|
-
Lono::Script::Upload.new(@options).run
|
69
|
-
end
|
70
|
-
|
71
|
-
def upload_files
|
72
|
-
Lono::AppFile::Upload.new(@options).upload
|
73
|
-
Lono::Configset::S3File::Upload.new(@options).upload
|
74
|
-
end
|
75
|
-
|
76
32
|
def param_builder
|
77
|
-
|
78
|
-
regenerate: true,
|
79
|
-
allow_not_exists: true,
|
80
|
-
}.merge(@options)
|
81
|
-
o = HashWithIndifferentAccess.new(o)
|
82
|
-
Lono::Builder::Param.new(o)
|
33
|
+
Lono::Builder::Param.new(@options)
|
83
34
|
end
|
84
35
|
memoize :param_builder
|
85
36
|
|
@@ -87,5 +38,10 @@ class Lono::CLI
|
|
87
38
|
Lono::Builder::Template.new(@options) # write templates to disk
|
88
39
|
end
|
89
40
|
memoize :template_builder
|
41
|
+
|
42
|
+
# Useful for dev and debugging
|
43
|
+
def upload?
|
44
|
+
ENV['LONO_UPLOAD'] != '0'
|
45
|
+
end
|
90
46
|
end
|
91
47
|
end
|
data/lib/lono/cli/clean.rb
CHANGED
@@ -8,15 +8,16 @@ class Lono::CLI
|
|
8
8
|
attr_reader :options
|
9
9
|
def initialize(options={})
|
10
10
|
@options = options
|
11
|
+
@mute = options[:mute] # used by CLI::Build at beginning to clear out the output folder
|
11
12
|
end
|
12
13
|
|
13
14
|
def run
|
14
15
|
folders = %w[output tmp]
|
15
|
-
sure?("Will remove folders: #{folders.join(' ')}")
|
16
|
+
@mute || sure?("Will remove folders: #{folders.join(' ')}")
|
16
17
|
folders.each do |folder|
|
17
18
|
FileUtils.rm_rf("#{Lono.root}/#{folder}")
|
18
19
|
end
|
19
|
-
logger.info "Removed folders: #{folders.join(' ')}"
|
20
|
+
logger.info "Removed folders: #{folders.join(' ')}" unless @mute
|
20
21
|
end
|
21
22
|
end
|
22
23
|
end
|
data/lib/lono/cli/code.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
class Lono::CLI
|
2
2
|
class Code < Lono::Command
|
3
|
-
desc "import SOURCE", "Imports CloudFormation template and converts it to Ruby code."
|
4
|
-
long_desc Help.text("code/import")
|
5
|
-
option :blueprint, default: nil, desc: "final blueprint name"
|
6
|
-
option :casing, default: "as-is", desc: "Controls casing of logical ids. IE: as-is, camelcase or underscore"
|
7
|
-
option :summary, default: true, type: :boolean, desc: "provide template summary after import"
|
8
|
-
option :template, default: nil, desc: "final template name of downloaded template without extension"
|
9
|
-
option :template_name_casing, default: "dasherize", desc: "camelcase or dasherize the template name"
|
10
|
-
option :type, default: "dsl", desc: "import as a DSL or ERB template"
|
11
|
-
def import(source)
|
12
|
-
|
13
|
-
end
|
3
|
+
# desc "import SOURCE", "Imports CloudFormation template and converts it to Ruby code."
|
4
|
+
# long_desc Help.text("code/import")
|
5
|
+
# option :blueprint, default: nil, desc: "final blueprint name"
|
6
|
+
# option :casing, default: "as-is", desc: "Controls casing of logical ids. IE: as-is, camelcase or underscore"
|
7
|
+
# option :summary, default: true, type: :boolean, desc: "provide template summary after import"
|
8
|
+
# option :template, default: nil, desc: "final template name of downloaded template without extension"
|
9
|
+
# option :template_name_casing, default: "dasherize", desc: "camelcase or dasherize the template name"
|
10
|
+
# option :type, default: "dsl", desc: "import as a DSL or ERB template"
|
11
|
+
# def import(source)
|
12
|
+
# Importer.new(options.merge(source: source)).run
|
13
|
+
# end
|
14
14
|
|
15
15
|
desc "convert SOURCE", "Converts snippet of JSON or YAML CloudFormation template to Ruby code."
|
16
16
|
long_desc Help.text("code/convert")
|
17
17
|
option :casing, default: "as-is", desc: "Controls casing of logical ids. IE: as-is, camelcase or underscore"
|
18
18
|
def convert(source)
|
19
|
-
Importer::Converter.new(options.merge(source: source)).run
|
19
|
+
Lono::Importer::Converter.new(options.merge(source: source)).run
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
## Example
|
2
|
+
|
3
|
+
The default helper name is `custom`.
|
4
|
+
|
5
|
+
$ lono new helper blueprint --blueprint demo
|
6
|
+
=> Generating custom_helper.rb
|
7
|
+
create app/blueprints/demo/helpers
|
8
|
+
create app/blueprints/demo/helpers/custom_helper.rb
|
9
|
+
|
10
|
+
|
11
|
+
You can override the helper name with the first argument.
|
12
|
+
|
13
|
+
$ lono new helper blueprint vars --blueprint demo
|
14
|
+
=> Generating vars_helper.rb
|
15
|
+
create app/blueprints/demo/helpers
|
16
|
+
create app/blueprints/demo/helpers/vars_helper.rb
|
17
|
+
$
|
@@ -0,0 +1,16 @@
|
|
1
|
+
## Examples
|
2
|
+
|
3
|
+
The default helper name is `custom`.
|
4
|
+
|
5
|
+
$ lono new helper project
|
6
|
+
=> Generating custom_helper.rb
|
7
|
+
create app/helpers/custom
|
8
|
+
create app/helpers/custom/custom_helper.rb
|
9
|
+
|
10
|
+
You can override the helper name with the first argument.
|
11
|
+
|
12
|
+
$ lono new helper project asg
|
13
|
+
=> Generating asg_helper.rb
|
14
|
+
create app/helpers/asg
|
15
|
+
create app/helpers/asg/asg_helper.rb
|
16
|
+
$
|
data/lib/lono/cli/list.rb
CHANGED
@@ -13,14 +13,11 @@ class Lono::CLI
|
|
13
13
|
|
14
14
|
private
|
15
15
|
def list_type(type)
|
16
|
-
|
16
|
+
Dir.glob("#{Lono.root}/{app,vendor}/#{type}/*").each do |path|
|
17
|
+
logger.info pretty_path(path)
|
18
|
+
end
|
17
19
|
end
|
18
20
|
|
19
|
-
def lookup
|
20
|
-
Lono::Lookup.new
|
21
|
-
end
|
22
|
-
memoize :lookup
|
23
|
-
|
24
21
|
def show?(type)
|
25
22
|
@options[:type] == type || @options[:type].nil? || @options[:type] == "all"
|
26
23
|
end
|
@@ -3,8 +3,8 @@ class Lono::CLI::New
|
|
3
3
|
argument :name
|
4
4
|
def self.cli_options
|
5
5
|
[
|
6
|
-
[:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"],
|
7
6
|
[:examples, type: :boolean, desc: "Whether not to generate examples"],
|
7
|
+
[:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"],
|
8
8
|
[:project, desc: "Project name"],
|
9
9
|
]
|
10
10
|
end
|
@@ -20,14 +20,10 @@ class Lono::CLI::New
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
# for specs
|
24
|
-
def set_dest
|
25
|
-
@dest = [@options[:project], "app/blueprints"].compact.join('/')
|
26
|
-
end
|
27
|
-
|
28
23
|
def create_blueprint
|
29
24
|
logger.info "=> Creating new blueprint called #{name}."
|
30
|
-
|
25
|
+
dest = [@options[:project], "app/blueprints"].compact.join('/')
|
26
|
+
directory ".", "#{dest}/#{name}"
|
31
27
|
end
|
32
28
|
end
|
33
29
|
end
|