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/builder.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
module Lono
|
2
|
+
class Builder < Lono::CLI::Base
|
3
|
+
include Lono::Hooks::Concern
|
4
|
+
|
5
|
+
def all
|
6
|
+
check_allow!
|
7
|
+
|
8
|
+
parameters = nil
|
9
|
+
run_hooks("build") do
|
10
|
+
clean
|
11
|
+
template_builder.run # build with placeholders IE: LONO://app/files/index.rb
|
12
|
+
parameters = param_builder.build # Writes the json file in CamelCase keys format
|
13
|
+
end
|
14
|
+
|
15
|
+
logger.info "" # newline
|
16
|
+
parameters
|
17
|
+
end
|
18
|
+
memoize :all
|
19
|
+
alias_method :parameters, :all
|
20
|
+
|
21
|
+
def clean
|
22
|
+
Lono::CLI::Clean.new(@options.merge(mute: true)).run
|
23
|
+
end
|
24
|
+
|
25
|
+
def check_allow!
|
26
|
+
Lono::Builder::Allow.new(@options).check!
|
27
|
+
end
|
28
|
+
|
29
|
+
def param_builder
|
30
|
+
Lono::Builder::Param.new(@options)
|
31
|
+
end
|
32
|
+
memoize :param_builder
|
33
|
+
|
34
|
+
def template_builder
|
35
|
+
Lono::Builder::Template.new(@options) # write templates to disk
|
36
|
+
end
|
37
|
+
memoize :template_builder
|
38
|
+
end
|
39
|
+
end
|
@@ -1,22 +1,7 @@
|
|
1
1
|
module Lono::Bundler::Util
|
2
2
|
module Git
|
3
3
|
include Logging
|
4
|
-
|
5
|
-
def sh(command)
|
6
|
-
command = "#{command} 2>&1" # always need output for the sha
|
7
|
-
logger.debug "=> #{command}"
|
8
|
-
out = `#{command}`
|
9
|
-
unless $?.success?
|
10
|
-
if command.include?("git")
|
11
|
-
raise LB::GitError.new("#{command}\n#{out}")
|
12
|
-
else
|
13
|
-
logger.error "ERROR: running #{command}".color(:red)
|
14
|
-
logger.error out
|
15
|
-
exit $?.exitstatus
|
16
|
-
end
|
17
|
-
end
|
18
|
-
out
|
19
|
-
end
|
4
|
+
include Lono::Utils::Sh
|
20
5
|
|
21
6
|
def git(command)
|
22
7
|
sh("git #{command}")
|
@@ -33,5 +18,22 @@ module Lono::Bundler::Util
|
|
33
18
|
end
|
34
19
|
exit 1
|
35
20
|
end
|
21
|
+
|
22
|
+
# Different from Lono::Utils::Sh
|
23
|
+
def sh(command)
|
24
|
+
command = "#{command} 2>&1" # always need output for the sha
|
25
|
+
logger.debug "=> #{command}"
|
26
|
+
out = `#{command}`
|
27
|
+
unless $?.success?
|
28
|
+
if command.include?("git")
|
29
|
+
raise LB::GitError.new("#{command}\n#{out}")
|
30
|
+
else
|
31
|
+
logger.error "ERROR: running #{command}".color(:red)
|
32
|
+
logger.error out
|
33
|
+
exit $?.exitstatus
|
34
|
+
end
|
35
|
+
end
|
36
|
+
out
|
37
|
+
end
|
36
38
|
end
|
37
39
|
end
|
data/lib/lono/cfn/base.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
module Lono::Cfn
|
2
2
|
class Base < Lono::CLI::Base
|
3
3
|
extend Memoist
|
4
|
-
|
5
4
|
include Lono::AwsServices
|
6
|
-
include Lono::
|
5
|
+
include Lono::Hooks::Concern
|
7
6
|
include Lono::Utils::Logging
|
8
7
|
include Lono::Utils::Pretty
|
9
8
|
include Lono::Utils::Quit
|
9
|
+
include Lono::Utils::Sure
|
10
10
|
|
11
11
|
include Concerns
|
12
12
|
|
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/delete.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
module Lono::Cfn
|
2
2
|
class Delete < Base
|
3
3
|
def run
|
4
|
+
logger.info "Will delete stack #{@stack.color(:green)}"
|
4
5
|
plan.for_delete
|
5
|
-
sure?("Are you sure you want to delete the
|
6
|
-
|
6
|
+
sure?("Are you sure you want to delete the stack?")
|
7
|
+
run_hooks("down") do
|
8
|
+
cfn.delete_stack(stack_name: @stack)
|
9
|
+
end
|
7
10
|
if @options[:wait]
|
8
11
|
status.wait
|
9
12
|
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
|
@@ -3,7 +3,7 @@ class Lono::Cfn::Deploy
|
|
3
3
|
def check!
|
4
4
|
status = stack_status
|
5
5
|
unless status =~ /_COMPLETE$/ || status == "UPDATE_ROLLBACK_FAILED"
|
6
|
-
logger.info "Cannot
|
6
|
+
logger.info "Cannot run operation on stack #{@stack} is not in an updatable state. Stack status: #{status}".color(:red)
|
7
7
|
quit 1
|
8
8
|
end
|
9
9
|
end
|
@@ -11,10 +11,8 @@ class Lono::Cfn::Deploy
|
|
11
11
|
|
12
12
|
def continue_update
|
13
13
|
continue_update?
|
14
|
-
options = {stack_name: @stack}
|
15
|
-
show_options(options, "continue_update_rollback")
|
16
14
|
begin
|
17
|
-
cfn.continue_update_rollback(
|
15
|
+
cfn.continue_update_rollback(stack_name: @stack)
|
18
16
|
rescue Aws::CloudFormation::Errors::ValidationError => e
|
19
17
|
logger.info "ERROR: Continue update: #{e.message}".color(:red)
|
20
18
|
quit 1
|
data/lib/lono/cfn/deploy.rb
CHANGED
@@ -2,7 +2,9 @@ module Lono::Cfn
|
|
2
2
|
class Deploy < Base
|
3
3
|
def run
|
4
4
|
start_message
|
5
|
-
|
5
|
+
run_hooks("up") do
|
6
|
+
perform # create or update
|
7
|
+
end
|
6
8
|
success = status.wait
|
7
9
|
if success
|
8
10
|
finish_message
|
@@ -20,20 +22,36 @@ module Lono::Cfn
|
|
20
22
|
yes = iam.rerun?(e)
|
21
23
|
retry if yes
|
22
24
|
rescue Aws::CloudFormation::Errors::ValidationError => e
|
23
|
-
|
25
|
+
case e.message
|
26
|
+
when /No updates/ # No updates are to be performed.
|
24
27
|
logger.info "WARN: #{e.message}".color(:yellow)
|
25
|
-
|
28
|
+
when /UPDATE_ROLLBACK_FAILED/ # https://amzn.to/2IiEjc5
|
26
29
|
rollback.continue_update
|
30
|
+
when /YAML not well-formed/ # happens if a value is a serialize Ruby Object. See: https://gist.github.com/tongueroo/737531d0bc8c92d92b5cd00493e15d9e
|
31
|
+
# e.message: Template format error: YAML not well-formed. (line 207, column 9)
|
32
|
+
print_code(e)
|
27
33
|
else
|
28
|
-
logger.info "ERROR: #{e.message}".color(:red)
|
34
|
+
logger.info "ERROR: Deploy#perform #{e.class} #{e.message}".color(:red)
|
35
|
+
logger.info "Check: #{pretty_path(@blueprint.output_path)}"
|
29
36
|
quit 1
|
30
37
|
end
|
31
38
|
end
|
32
39
|
|
40
|
+
def print_code(exception)
|
41
|
+
md = exception.message.match(/line (\d+),/)
|
42
|
+
line_number = md[1]
|
43
|
+
logger.error "Template for debugging: #{pretty_path(@blueprint.output_path)}"
|
44
|
+
if md
|
45
|
+
DslEvaluator.print_code(@blueprint.output_path, line_number)
|
46
|
+
exit 1
|
47
|
+
else
|
48
|
+
raise
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
33
52
|
def create
|
34
53
|
plan.for_create
|
35
54
|
@sure || sure?("Going to create stack #{@stack} with blueprint #{@blueprint.name}.")
|
36
|
-
|
37
55
|
options = {
|
38
56
|
stack_name: @stack,
|
39
57
|
parameters: build.parameters,
|
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
|
@@ -36,7 +36,7 @@ class Lono::Cfn::Plan
|
|
36
36
|
change_set = describe_change_set
|
37
37
|
sleep 1
|
38
38
|
unless newline_needed
|
39
|
-
logger.print "
|
39
|
+
logger.print "Calculating Change Set"
|
40
40
|
end
|
41
41
|
newline_needed = true
|
42
42
|
logger.print '.'
|
@@ -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
@@ -1,6 +1,7 @@
|
|
1
1
|
module Lono::Cfn
|
2
2
|
class Plan < Base
|
3
3
|
def run
|
4
|
+
build.all
|
4
5
|
if stack_exists?(@stack)
|
5
6
|
for_update
|
6
7
|
else
|
@@ -9,6 +10,7 @@ module Lono::Cfn
|
|
9
10
|
end
|
10
11
|
|
11
12
|
def for_update
|
13
|
+
upload_all
|
12
14
|
# Allow passing down of the build object from Cfn::Deploy so build.all only runs once.
|
13
15
|
# Fallback to creating new build object but still pass one build object instance down.
|
14
16
|
@options[:build] ||= build
|
@@ -23,11 +25,35 @@ module Lono::Cfn
|
|
23
25
|
end
|
24
26
|
|
25
27
|
def for_create
|
28
|
+
upload_all
|
26
29
|
New.new(@options).run
|
27
30
|
end
|
28
31
|
|
29
32
|
def for_delete
|
30
33
|
Delete.new(@options).run
|
31
34
|
end
|
35
|
+
|
36
|
+
# important to call before for_update and for_create
|
37
|
+
# since changeset requires the template to already be uploaded to s3
|
38
|
+
def upload_all
|
39
|
+
upload_templates
|
40
|
+
upload_files
|
41
|
+
end
|
42
|
+
|
43
|
+
def upload_templates
|
44
|
+
Lono::Builder::Template::Upload.new(@options).run
|
45
|
+
end
|
46
|
+
|
47
|
+
# Upload files right before create_stack or execute_change_set
|
48
|
+
# Its better to upload here as part of a deploy vs a build
|
49
|
+
# IE: lono build should try not to do a remote write to s3 if possible
|
50
|
+
def upload_files
|
51
|
+
# Files built and compressed in
|
52
|
+
# Lono::Builder::Dsl::Finalizer::Files::Build#build_files
|
53
|
+
Lono::Files.files.each do |file| # using singular file, but is like a "file_list"
|
54
|
+
file.upload
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
32
58
|
end
|
33
59
|
end
|
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,12 @@
|
|
1
1
|
class Lono::CLI
|
2
2
|
class Base < Abstract
|
3
|
-
|
3
|
+
include Lono::Concerns::Names
|
4
|
+
include Lono::Utils::Sh
|
5
|
+
|
6
|
+
def initialize(options={})
|
4
7
|
super
|
5
|
-
@blueprint = Lono::Blueprint.new(options)
|
6
|
-
@stack =
|
8
|
+
@blueprint = Lono::Blueprint.new(options.merge(name: options[:blueprint]))
|
9
|
+
@stack = names.stack
|
7
10
|
end
|
8
11
|
end
|
9
12
|
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
|
@@ -0,0 +1,27 @@
|
|
1
|
+
## Blueprint Helpers
|
2
|
+
|
3
|
+
When the `--blueprint` option is used a blueprint helper is generated.
|
4
|
+
|
5
|
+
The default name is custom
|
6
|
+
|
7
|
+
$ lono new helper --blueprint demo
|
8
|
+
create app/blueprints/demo/helpers/custom_helper.rb
|
9
|
+
|
10
|
+
Here's an example with a helper named vars.
|
11
|
+
|
12
|
+
$ lono new helper vars --blueprint demo
|
13
|
+
create app/blueprints/demo/helpers/vars_helper.rb
|
14
|
+
|
15
|
+
## Project Helpers
|
16
|
+
|
17
|
+
When no `--blueprint` option is used a project helper is generated.
|
18
|
+
|
19
|
+
The default name is custom.
|
20
|
+
|
21
|
+
$ lono new helper
|
22
|
+
create app/helpers/custom/custom_helper.rb
|
23
|
+
|
24
|
+
Here's an example with a helper named common.
|
25
|
+
|
26
|
+
$ lono new helper common
|
27
|
+
create app/helpers/common/common_helper.rb
|
@@ -0,0 +1,14 @@
|
|
1
|
+
## Blueprint Hooks
|
2
|
+
|
3
|
+
When the `--blueprint` option is used a blueprint hook is generated.
|
4
|
+
|
5
|
+
$ lono new helper --blueprint demo
|
6
|
+
create app/blueprints/demo/config/hooks.rb
|
7
|
+
|
8
|
+
## Project Helpers
|
9
|
+
|
10
|
+
When no `--blueprint` option is used a project hook is generated.
|
11
|
+
|
12
|
+
$ lono new helper
|
13
|
+
create app/config/hooks.rb
|
14
|
+
|
@@ -1,22 +1,15 @@
|
|
1
1
|
## Example
|
2
2
|
|
3
3
|
$ lono new project infra
|
4
|
+
Other infra
|
4
5
|
=> Creating new project called infra.
|
5
6
|
create infra
|
6
7
|
create infra/.gitignore
|
7
8
|
create infra/Gemfile
|
8
9
|
create infra/README.md
|
9
10
|
create infra/config/app.rb
|
10
|
-
=> Initialize git repo
|
11
|
-
run git init from "."
|
12
|
-
Initialized empty Git repository in /home/ec2-user/environment/infra/.git/
|
13
11
|
=> Installing dependencies with: bundle install
|
14
|
-
|
15
|
-
............................
|
16
|
-
Using concurrent-ruby 1.1.9
|
17
|
-
...
|
18
|
-
Bundle complete! 1 Gemfile dependency, 40 gems now installed.
|
19
|
-
Use `bundle info [gemname]` to see where a bundled gem is installed.
|
12
|
+
Bundle complete! 2 Gemfile dependencies, 47 gems now installed.
|
20
13
|
================================================================
|
21
14
|
Congrats 🎉 You have successfully created a lono project.
|
22
15
|
|
@@ -31,4 +24,4 @@
|
|
31
24
|
lono up demo
|
32
25
|
|
33
26
|
More info: https://lono.cloud/
|
34
|
-
$
|
27
|
+
$
|
data/lib/lono/cli/iam.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
class Lono::CLI
|
2
|
+
class Iam < Base
|
3
|
+
include Lono::Cfn::Concerns::Build
|
4
|
+
include Lono::Cfn::Concerns::TemplateOutput
|
5
|
+
|
6
|
+
def run
|
7
|
+
build.template_builder.run
|
8
|
+
resources = template_output.data['Resources']
|
9
|
+
types = resources.map { |logical_id, attrs| attrs['Type'] }
|
10
|
+
actions = types.map do |t|
|
11
|
+
service = t.split('::')[1]
|
12
|
+
"#{service.downcase}:*"
|
13
|
+
end.uniq
|
14
|
+
text =<<~EOL
|
15
|
+
Version: 2012-10-17
|
16
|
+
Statement:
|
17
|
+
- Sid: #{@blueprint.name}
|
18
|
+
Effect: Allow
|
19
|
+
Resource: "*"
|
20
|
+
EOL
|
21
|
+
policy = YAML.load(text)
|
22
|
+
policy['Statement'][0]['Action'] = actions
|
23
|
+
puts "IAM Policy Example for blueprint #{@blueprint.name}".color(:green)
|
24
|
+
puts JSON.pretty_generate(policy)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
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,9 +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"],
|
8
|
-
[:
|
7
|
+
[:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"],
|
9
8
|
]
|
10
9
|
end
|
11
10
|
cli_options.each do |args|
|
@@ -20,14 +19,9 @@ class Lono::CLI::New
|
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
23
|
-
# for specs
|
24
|
-
def set_dest
|
25
|
-
@dest = [@options[:project], "app/blueprints"].compact.join('/')
|
26
|
-
end
|
27
|
-
|
28
22
|
def create_blueprint
|
29
|
-
logger.info "=> Creating new blueprint
|
30
|
-
directory ".", "
|
23
|
+
logger.info "=> Creating new blueprint: #{name}"
|
24
|
+
directory ".", "app/blueprints/#{name}"
|
31
25
|
end
|
32
26
|
end
|
33
27
|
end
|
@@ -1,56 +1,27 @@
|
|
1
1
|
class Lono::CLI::New
|
2
2
|
class Configset < Sequence
|
3
|
-
argument :
|
4
|
-
|
5
|
-
def self.source_root
|
6
|
-
templates = File.expand_path("../../templates", File.dirname(__FILE__))
|
7
|
-
"#{templates}/configset"
|
8
|
-
end
|
9
|
-
|
3
|
+
argument :name
|
10
4
|
def self.cli_options
|
11
5
|
[
|
12
|
-
[:
|
13
|
-
[:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files
|
6
|
+
[:examples, type: :boolean, desc: "Whether not to generate examples"],
|
7
|
+
[:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"],
|
14
8
|
]
|
15
9
|
end
|
16
|
-
|
17
10
|
cli_options.each do |args|
|
18
11
|
class_option(*args)
|
19
12
|
end
|
20
13
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
def set_variables
|
27
|
-
@demo = @options[:demo]
|
28
|
-
@demo = false if ENV["LONO_ORG"] # overrides --demo CLI option
|
29
|
-
end
|
30
|
-
|
31
|
-
def create_project
|
32
|
-
puts "=> Creating new configset called #{configset_name}."
|
33
|
-
if @demo
|
34
|
-
options = {}
|
14
|
+
def set_source
|
15
|
+
if @options[:examples]
|
16
|
+
set_template_source "examples/configset"
|
35
17
|
else
|
36
|
-
|
37
|
-
options = {exclude_pattern: %r{configset\.rb}}
|
18
|
+
set_template_source "configset"
|
38
19
|
end
|
39
|
-
|
40
|
-
directory ".", "#{@cwd}/#{configset_name}", options
|
41
|
-
end
|
42
|
-
|
43
|
-
def create_license
|
44
|
-
return unless ENV['LONO_LICENSE_FILE']
|
45
|
-
copy_file ENV['LONO_LICENSE_FILE'], "#{@cwd}/#{configset_name}/LICENSE.txt"
|
46
20
|
end
|
47
21
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
self.destination_root = destination_root
|
52
|
-
@old_dir = Dir.pwd # for reset_current_dir
|
53
|
-
FileUtils.cd(self.destination_root)
|
22
|
+
def create_configset
|
23
|
+
dest = "#{Lono.root}/app/configsets"
|
24
|
+
directory ".", "#{dest}/#{name}"
|
54
25
|
end
|
55
26
|
|
56
27
|
def welcome_message
|
@@ -58,11 +29,7 @@ class Lono::CLI::New
|
|
58
29
|
#{"="*64}
|
59
30
|
Congrats 🎉 You have successfully created a lono configset.
|
60
31
|
|
61
|
-
|
62
|
-
|
63
|
-
cd #{configset_name}
|
64
|
-
|
65
|
-
More info: https://lono.cloud/docs/core/configsets
|
32
|
+
More info: https://lono.cloud/docs/configsets
|
66
33
|
|
67
34
|
EOL
|
68
35
|
end
|