lono 6.1.11 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.cody/acceptance.sh +19 -3
- data/.gitignore +2 -2
- data/CHANGELOG.md +16 -1
- data/README.md +18 -20
- data/Rakefile +1 -0
- data/lib/lono.rb +7 -5
- data/lib/lono/abstract_base.rb +25 -0
- data/lib/lono/api/client.rb +30 -0
- data/lib/lono/api/proxy.rb +58 -0
- data/lib/lono/api/repos.rb +8 -0
- data/lib/lono/api/verify.rb +13 -0
- data/lib/lono/app_file/base.rb +4 -11
- data/lib/lono/app_file/build.rb +1 -1
- data/lib/lono/app_file/upload.rb +1 -4
- data/lib/lono/autoloader.rb +3 -1
- data/lib/lono/aws_services.rb +9 -9
- data/lib/lono/aws_services/helper.rb +14 -0
- data/lib/lono/aws_services/{util.rb → stack.rb} +1 -9
- data/lib/lono/aws_services/stack_set.rb +41 -0
- data/lib/lono/blueprint.rb +2 -2
- data/lib/lono/blueprint/configset/loader.rb +7 -0
- data/lib/lono/blueprint/helper.rb +8 -2
- data/lib/lono/blueprint/meta.rb +4 -12
- data/lib/lono/blueprint/new.rb +3 -3
- data/lib/lono/blueprint/root.rb +6 -26
- data/lib/lono/bundle.rb +54 -0
- data/lib/lono/cfn.rb +31 -75
- data/lib/lono/cfn/base.rb +39 -136
- data/lib/lono/cfn/cancel.rb +14 -9
- data/lib/lono/cfn/create.rb +15 -19
- data/lib/lono/cfn/delete.rb +9 -9
- data/lib/lono/cfn/deploy.rb +4 -4
- data/lib/lono/cfn/download.rb +27 -9
- data/lib/lono/cfn/opts.rb +80 -0
- data/lib/lono/cfn/preview/changeset.rb +23 -23
- data/lib/lono/cfn/preview/codediff.rb +5 -6
- data/lib/lono/cfn/preview/param.rb +10 -10
- data/lib/lono/cfn/rollback.rb +5 -5
- data/lib/lono/cfn/status.rb +0 -10
- data/lib/lono/cfn/update.rb +22 -27
- data/lib/lono/clean.rb +3 -3
- data/lib/lono/cli.rb +69 -34
- data/lib/lono/code.rb +22 -0
- data/lib/lono/command.rb +7 -0
- data/lib/lono/config_location.rb +6 -13
- data/lib/lono/configset.rb +9 -0
- data/lib/lono/configset/combiner.rb +128 -0
- data/lib/lono/configset/evaluate_file.rb +8 -0
- data/lib/lono/configset/list.rb +67 -0
- data/lib/lono/configset/loader.rb +98 -0
- data/lib/lono/configset/loader/dsl.rb +9 -0
- data/lib/lono/configset/materializer/final.rb +10 -0
- data/lib/lono/configset/materializer/gems_builder.rb +81 -0
- data/lib/lono/configset/materializer/jade.rb +15 -0
- data/lib/lono/configset/materializer/source.rb +54 -0
- data/lib/lono/configset/meta.rb +19 -0
- data/lib/lono/configset/meta/dsl.rb +12 -0
- data/lib/lono/configset/new.rb +84 -0
- data/lib/lono/configset/preparer.rb +44 -0
- data/lib/lono/configset/register/base.rb +121 -0
- data/lib/lono/configset/register/blueprint.rb +16 -0
- data/lib/lono/configset/register/dsl.rb +15 -0
- data/lib/lono/configset/register/project.rb +12 -0
- data/lib/lono/configset/registry.rb +34 -0
- data/lib/lono/configset/resolver.rb +42 -0
- data/lib/lono/conventions.rb +18 -7
- data/lib/lono/core.rb +16 -20
- data/lib/lono/default/settings.yml +2 -3
- data/lib/lono/ext/bundler.rb +7 -0
- data/lib/lono/file_uploader.rb +8 -5
- data/lib/lono/finder/base.rb +140 -0
- data/lib/lono/finder/blueprint.rb +11 -0
- data/lib/lono/finder/blueprint/configset.rb +17 -0
- data/lib/lono/finder/configset.rb +11 -0
- data/lib/lono/generate.rb +93 -0
- data/lib/lono/help/blueprint/new.md +0 -1
- data/lib/lono/help/cfn/delete.md +1 -1
- data/lib/lono/help/cfn/deploy.md +5 -76
- data/lib/lono/help/cfn/status.md +0 -4
- data/lib/lono/help/cfn/update.md +1 -1
- data/lib/lono/help/code/convert.md +51 -0
- data/lib/lono/help/code/import.md +30 -0
- data/lib/lono/help/configsets.md +24 -0
- data/lib/lono/help/generate.md +4 -4
- data/lib/lono/help/new.md +1 -2
- data/lib/lono/help/sets/delete.md +8 -0
- data/lib/lono/help/sets/deploy.md +76 -0
- data/lib/lono/help/sets/instances/delete.md +21 -0
- data/lib/lono/help/sets/instances/list.md +14 -0
- data/lib/lono/help/sets/instances/status.md +15 -0
- data/lib/lono/help/sets/instances/sync.md +88 -0
- data/lib/lono/help/sets/status.md +23 -0
- data/lib/lono/help/upgrade.md +1 -0
- data/lib/lono/importer.rb +22 -0
- data/lib/lono/importer/base.rb +59 -0
- data/lib/lono/importer/converter.rb +19 -0
- data/lib/lono/importer/download.rb +46 -0
- data/lib/lono/importer/dsl.rb +36 -0
- data/lib/lono/importer/erb.rb +31 -0
- data/lib/lono/importer/params.rb +56 -0
- data/lib/lono/importer/service/coder.rb +81 -0
- data/lib/lono/inspector/base.rb +12 -22
- data/lib/lono/inspector/graph.rb +1 -1
- data/lib/lono/inspector/summary.rb +41 -17
- data/lib/lono/jade.rb +103 -0
- data/lib/lono/jade/circular.rb +26 -0
- data/lib/lono/jadespec.rb +41 -0
- data/lib/lono/new.rb +2 -2
- data/lib/lono/opts.rb +43 -0
- data/lib/lono/output/template.rb +48 -0
- data/lib/lono/param.rb +3 -5
- data/lib/lono/param/generator.rb +13 -33
- data/lib/lono/pro.rb +15 -0
- data/lib/lono/pro/base.rb +16 -0
- data/lib/lono/pro/repo.rb +27 -0
- data/lib/lono/project_checker.rb +4 -29
- data/lib/lono/registration.rb +15 -0
- data/lib/lono/registration/base.rb +37 -0
- data/lib/lono/registration/check.rb +15 -0
- data/lib/lono/registration/temp.rb +60 -0
- data/lib/lono/registration/user.rb +54 -0
- data/lib/lono/script/base.rb +1 -10
- data/lib/lono/script/upload.rb +2 -12
- data/lib/lono/seed.rb +2 -11
- data/lib/lono/seed/base.rb +55 -110
- data/lib/lono/sets.rb +38 -0
- data/lib/lono/sets/base.rb +45 -0
- data/lib/lono/sets/create.rb +30 -0
- data/lib/lono/sets/delete.rb +47 -0
- data/lib/lono/sets/deploy.rb +11 -0
- data/lib/lono/sets/instances.rb +33 -0
- data/lib/lono/sets/instances/base.rb +30 -0
- data/lib/lono/sets/instances/delete.rb +69 -0
- data/lib/lono/sets/instances/list.rb +13 -0
- data/lib/lono/sets/instances/opts.rb +29 -0
- data/lib/lono/sets/instances/status.rb +12 -0
- data/lib/lono/sets/instances/sync.rb +182 -0
- data/lib/lono/sets/list.rb +35 -0
- data/lib/lono/sets/opts.rb +18 -0
- data/lib/lono/sets/preview/codediff.rb +35 -0
- data/lib/lono/sets/preview/param.rb +32 -0
- data/lib/lono/sets/status.rb +116 -0
- data/lib/lono/sets/status/instance.rb +20 -0
- data/lib/lono/sets/status/instance/base.rb +120 -0
- data/lib/lono/sets/status/instance/completed.rb +35 -0
- data/lib/lono/sets/status/instance/deleted.rb +32 -0
- data/lib/lono/sets/status/instance/show.rb +7 -0
- data/lib/lono/sets/status/instances.rb +111 -0
- data/lib/lono/sets/summarize.rb +20 -0
- data/lib/lono/sets/time_spent.rb +11 -0
- data/lib/lono/sets/update.rb +81 -0
- data/lib/lono/template.rb +5 -7
- data/lib/lono/template/configset_injector.rb +50 -0
- data/lib/lono/template/context.rb +4 -4
- data/lib/lono/template/context/loader.rb +4 -16
- data/lib/lono/template/evaluate.rb +2 -1
- data/lib/lono/template/generator.rb +17 -15
- data/lib/lono/template/helper.rb +7 -7
- data/lib/lono/template/post_processor.rb +2 -12
- data/lib/lono/template/strategy/base.rb +4 -0
- data/lib/lono/template/{dsl.rb → strategy/dsl.rb} +4 -6
- data/lib/lono/template/{dsl → strategy/dsl}/builder.rb +11 -15
- data/lib/lono/template/{dsl → strategy/dsl}/builder/fn.rb +1 -1
- data/lib/lono/template/strategy/dsl/builder/helpers.rb +11 -0
- data/lib/lono/template/strategy/dsl/builder/helpers/core_helper.rb +14 -0
- data/lib/lono/template/strategy/dsl/builder/helpers/file_helper.rb +48 -0
- data/lib/lono/template/strategy/dsl/builder/helpers/lookup_helper.rb +27 -0
- data/lib/lono/template/strategy/dsl/builder/helpers/s3_helper.rb +13 -0
- data/lib/lono/template/strategy/dsl/builder/helpers/tags_helper.rb +39 -0
- data/lib/lono/template/{dsl/builder → strategy/dsl/builder/section}/base.rb +6 -17
- data/lib/lono/template/{dsl/builder → strategy/dsl/builder/section}/condition.rb +1 -1
- data/lib/lono/template/strategy/dsl/builder/section/extensions.rb +9 -0
- data/lib/lono/template/{dsl/builder → strategy/dsl/builder/section}/mapping.rb +1 -1
- data/lib/lono/template/{dsl/builder/section_methods.rb → strategy/dsl/builder/section/methods.rb} +9 -2
- data/lib/lono/template/{dsl/builder → strategy/dsl/builder/section}/output.rb +1 -1
- data/lib/lono/template/strategy/dsl/builder/section/parameter.rb +69 -0
- data/lib/lono/template/{dsl/builder → strategy/dsl/builder/section}/resource.rb +1 -1
- data/lib/lono/template/{dsl/builder → strategy/dsl/builder/section}/resource/property_mover.rb +1 -1
- data/lib/lono/template/{dsl/builder → strategy/dsl/builder/section}/section.rb +1 -1
- data/lib/lono/template/{dsl → strategy/dsl}/builder/squeezer.rb +1 -1
- data/lib/lono/template/strategy/dsl/builder/stringify.rb +15 -0
- data/lib/lono/template/{dsl → strategy/dsl}/builder/syntax.rb +3 -2
- data/lib/lono/template/strategy/dsl/finalizer.rb +12 -0
- data/lib/lono/template/strategy/dsl/finalizer/parameter_groups.rb +56 -0
- data/lib/lono/template/{erb.rb → strategy/erb.rb} +5 -5
- data/lib/lono/template/strategy/source.rb +8 -0
- data/lib/lono/template/template.rb +1 -1
- data/lib/lono/template/upload.rb +4 -9
- data/lib/lono/template/util.rb +0 -40
- data/lib/lono/upgrade.rb +12 -10
- data/lib/lono/user_data.rb +4 -4
- data/lib/lono/utils/pretty_time.rb +14 -0
- data/lib/lono/utils/sure.rb +23 -0
- data/lib/lono/version.rb +1 -1
- data/lib/lono/yamler/loader.rb +52 -0
- data/lib/lono/yamler/validator.rb +51 -0
- data/lib/templates/blueprint/%blueprint_name%.gemspec.tt +4 -0
- data/lib/templates/blueprint/README.md.tt +1 -1
- data/lib/templates/blueprint/seed/configs.rb +2 -2
- data/lib/templates/blueprint_types/dsl/app/templates/%blueprint_name%.rb +17 -18
- data/lib/templates/blueprint_types/erb/app/templates/%blueprint_name%.yml +63 -4
- data/lib/templates/configset/%configset_name%.gemspec.tt +41 -0
- data/lib/templates/configset/.gitignore +11 -0
- data/lib/templates/configset/CHANGELOG.md +7 -0
- data/lib/templates/configset/Gemfile +4 -0
- data/lib/templates/configset/README.md.tt +3 -0
- data/lib/templates/configset/Rakefile.tt +9 -0
- data/lib/templates/configset/lib/configset.yml +20 -0
- data/lib/templates/skeleton/.gitignore +1 -0
- data/lib/templates/skeleton/Gemfile +0 -1
- data/lib/templates/skeleton/README.md +4 -4
- data/lib/templates/skeleton/configs/settings.yml +1 -1
- data/lono.gemspec +1 -4
- metadata +146 -79
- data/Guardfile +0 -19
- data/lib/lono/app_file.rb +0 -5
- data/lib/lono/blueprint/find.rb +0 -90
- data/lib/lono/blueprint/info.rb +0 -10
- data/lib/lono/blueprint/list.rb +0 -14
- data/lib/lono/cfn/current.rb +0 -95
- data/lib/lono/cfn/preview.rb +0 -4
- data/lib/lono/cfn/suffix.rb +0 -67
- data/lib/lono/cfn/util.rb +0 -27
- data/lib/lono/help/cfn/current.md +0 -18
- data/lib/lono/help/upgrade4.md +0 -25
- data/lib/lono/inspector.rb +0 -4
- data/lib/lono/output_template.rb +0 -35
- data/lib/lono/template/base.rb +0 -13
- data/lib/lono/template/dsl/builder/helpers.rb +0 -8
- data/lib/lono/template/dsl/builder/helpers/core_helper.rb +0 -107
- data/lib/lono/template/dsl/builder/helpers/param_helper.rb +0 -61
- data/lib/lono/template/dsl/builder/parameter.rb +0 -39
- data/lib/lono/upgrade/upgrade4.rb +0 -175
- data/lib/lono/upgrade/upgrade42.rb +0 -36
- data/lib/lono/upgrade/upgrade5.rb +0 -55
- data/lib/templates/blueprint/.meta/config.yml.tt +0 -4
- data/lib/templates/skeleton/Guardfile +0 -12
- data/lib/templates/upgrade5/blueprints/main/.lono/config.yml +0 -3
- data/lib/templates/upgrade5/blueprints/main/.meta/config.yml +0 -3
data/lib/lono/cfn/rollback.rb
CHANGED
@@ -3,15 +3,15 @@ class Lono::Cfn
|
|
3
3
|
extend Memoist
|
4
4
|
include Lono::AwsServices
|
5
5
|
|
6
|
-
def initialize(
|
7
|
-
@
|
6
|
+
def initialize(stack)
|
7
|
+
@stack = stack
|
8
8
|
end
|
9
9
|
|
10
10
|
def delete_stack
|
11
|
-
stack = find_stack(@
|
11
|
+
stack = find_stack(@stack)
|
12
12
|
if stack && rollback_complete?(stack)
|
13
13
|
puts "Existing stack in ROLLBACK_COMPLETE state. Deleting stack before continuing."
|
14
|
-
cfn.delete_stack(stack_name: @
|
14
|
+
cfn.delete_stack(stack_name: @stack)
|
15
15
|
status.wait
|
16
16
|
status.reset
|
17
17
|
true
|
@@ -19,7 +19,7 @@ class Lono::Cfn
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def status
|
22
|
-
Lono::Cfn::Status.new(@
|
22
|
+
Lono::Cfn::Status.new(@stack)
|
23
23
|
end
|
24
24
|
memoize :status
|
25
25
|
end
|
data/lib/lono/cfn/status.rb
CHANGED
@@ -1,14 +1,4 @@
|
|
1
1
|
class Lono::Cfn
|
2
2
|
class Status < CfnStatus
|
3
|
-
include Util
|
4
|
-
|
5
|
-
def initialize(stack_name, options={})
|
6
|
-
super
|
7
|
-
@stack_name = switch_current(stack_name)
|
8
|
-
end
|
9
|
-
|
10
|
-
def switch_current(stack_name)
|
11
|
-
Lono::Cfn::Current.name!(stack_name)
|
12
|
-
end
|
13
3
|
end
|
14
4
|
end
|
data/lib/lono/cfn/update.rb
CHANGED
@@ -1,13 +1,9 @@
|
|
1
1
|
class Lono::Cfn
|
2
2
|
class Update < Base
|
3
|
-
#
|
4
|
-
def save_stack(params)
|
5
|
-
update_stack(params)
|
6
|
-
end
|
7
|
-
|
3
|
+
# save is the interface method
|
8
4
|
# aws cloudformation update-stack --stack-name prod-hi-123456789 --parameters file://output/params/prod-hi-123456789.json --template-body file://output/prod-hi.json
|
9
|
-
def
|
10
|
-
message = "Updating #{@
|
5
|
+
def save(parameters)
|
6
|
+
message = "Updating #{@stack} stack"
|
11
7
|
if @options[:noop]
|
12
8
|
puts "NOOP #{message}"
|
13
9
|
return
|
@@ -15,60 +11,59 @@ class Lono::Cfn
|
|
15
11
|
|
16
12
|
deleted = delete_rollback_stack
|
17
13
|
if deleted
|
18
|
-
Create.new(@
|
14
|
+
Create.new(@options).save(parameters)
|
19
15
|
return
|
20
16
|
end
|
21
17
|
|
22
|
-
unless stack_exists?(@
|
23
|
-
puts "Cannot update a stack because the #{@
|
18
|
+
unless stack_exists?(@stack)
|
19
|
+
puts "Cannot update a stack because the #{@stack} does not exists."
|
24
20
|
return
|
25
21
|
end
|
26
|
-
exit_unless_updatable!
|
22
|
+
exit_unless_updatable!
|
27
23
|
|
28
24
|
options = @options.merge(mute_params: true, mute_using: true, keep: true)
|
29
25
|
# create new copy of preview when update_stack is called because of IAM retry logic
|
30
|
-
changeset_preview = Lono::Cfn::Preview::Changeset.new(
|
26
|
+
changeset_preview = Lono::Cfn::Preview::Changeset.new(options)
|
31
27
|
|
32
|
-
error = nil
|
33
28
|
param_preview.run if @options[:param_preview]
|
34
29
|
codediff_preview.run if @options[:codediff_preview]
|
35
30
|
changeset_preview.run if @options[:changeset_preview]
|
36
|
-
|
31
|
+
sure?("Are you sure you want to update the #{@stack} stack?")
|
37
32
|
|
38
33
|
if @options[:change_set] # defaults to this
|
39
34
|
message << " via change set: #{changeset_preview.change_set_name}"
|
40
35
|
changeset_preview.execute_change_set
|
41
36
|
else
|
42
|
-
standard_update(
|
37
|
+
standard_update(parameters)
|
43
38
|
end
|
44
|
-
puts message unless @options[:mute]
|
39
|
+
puts message unless @options[:mute]
|
45
40
|
end
|
46
41
|
|
47
|
-
def standard_update(
|
48
|
-
|
49
|
-
stack_name: @
|
50
|
-
parameters:
|
42
|
+
def standard_update(parameters)
|
43
|
+
options = {
|
44
|
+
stack_name: @stack,
|
45
|
+
parameters: parameters,
|
51
46
|
capabilities: capabilities, # ["CAPABILITY_IAM", "CAPABILITY_NAMED_IAM"]
|
52
47
|
disable_rollback: !@options[:rollback],
|
53
48
|
}
|
54
|
-
|
55
|
-
|
56
|
-
|
49
|
+
options[:tags] = tags unless tags.empty?
|
50
|
+
set_template_url!(options)
|
51
|
+
show_options(options, "cfn.update_stack")
|
57
52
|
begin
|
58
|
-
cfn.update_stack(
|
53
|
+
cfn.update_stack(options)
|
59
54
|
rescue Aws::CloudFormation::Errors::ValidationError => e
|
60
|
-
puts "ERROR: #{e.message}".red
|
55
|
+
puts "ERROR: #{e.message}".color(:red)
|
61
56
|
false
|
62
57
|
end
|
63
58
|
end
|
64
59
|
|
65
60
|
def codediff_preview
|
66
|
-
Lono::Cfn::Preview::Codediff.new(@
|
61
|
+
Lono::Cfn::Preview::Codediff.new(@options.merge(mute_params: true, mute_using: true))
|
67
62
|
end
|
68
63
|
memoize :codediff_preview
|
69
64
|
|
70
65
|
def param_preview
|
71
|
-
Lono::Cfn::Preview::Param.new(@
|
66
|
+
Lono::Cfn::Preview::Param.new(@options)
|
72
67
|
end
|
73
68
|
memoize :param_preview
|
74
69
|
end
|
data/lib/lono/clean.rb
CHANGED
@@ -2,13 +2,13 @@ require "fileutils"
|
|
2
2
|
|
3
3
|
class Lono::Clean
|
4
4
|
attr_reader :options
|
5
|
-
def initialize(options)
|
5
|
+
def initialize(options={})
|
6
6
|
@options = options
|
7
7
|
end
|
8
8
|
|
9
9
|
def run
|
10
|
-
puts "
|
11
|
-
puts "Removing output/ folder"
|
10
|
+
puts "Clean: removing output/ and tmp/ folder"
|
12
11
|
FileUtils.rm_rf("#{Lono.config.output_path}")
|
12
|
+
FileUtils.rm_rf("#{Lono.root}/tmp")
|
13
13
|
end
|
14
14
|
end
|
data/lib/lono/cli.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module Lono
|
2
2
|
class CLI < Command
|
3
3
|
include Thor::Actions # for add_runtime_options
|
4
|
+
opts = Opts.new(self)
|
4
5
|
|
5
6
|
long_desc Help.text(:new)
|
6
7
|
New.cli_options.each do |args|
|
@@ -8,58 +9,71 @@ module Lono
|
|
8
9
|
end
|
9
10
|
register(New, "new", "new NAME", "Generates new lono project.")
|
10
11
|
|
11
|
-
desc "blueprints", "Lists
|
12
|
+
desc "blueprints", "Lists blueprints"
|
12
13
|
long_desc Help.text(:blueprints)
|
13
14
|
def blueprints
|
14
|
-
Blueprint
|
15
|
+
Finder::Blueprint.list
|
15
16
|
end
|
16
17
|
|
17
|
-
desc "
|
18
|
+
desc "configsets [BLUEPRINT]", "Lists configsets"
|
19
|
+
long_desc Help.text(:configsets)
|
20
|
+
opts.source
|
21
|
+
opts.stack
|
22
|
+
def configsets(blueprint=nil)
|
23
|
+
Configset::List.new(options.merge(blueprint: blueprint)).run
|
24
|
+
end
|
25
|
+
|
26
|
+
desc "generate BLUEPRINT", "Generate both CloudFormation templates and parameters files."
|
18
27
|
long_desc Help.text(:generate)
|
19
|
-
option :clean, type: :boolean, default: false, desc: "remove all output files before generating"
|
20
28
|
option :quiet, type: :boolean, desc: "silence the output"
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
29
|
+
opts.clean
|
30
|
+
opts.source
|
31
|
+
opts.stack
|
32
|
+
opts.template
|
33
|
+
def generate(blueprint)
|
34
|
+
o = options.merge(blueprint: blueprint)
|
35
|
+
Script::Build.new(o).run
|
36
|
+
Template::Generator.new(o).run
|
37
|
+
Param::Generator.new(o).generate
|
28
38
|
end
|
29
39
|
|
30
40
|
desc "user_data NAME", "Generates user_data script for debugging."
|
31
41
|
long_desc Help.text(:user_data)
|
32
|
-
|
42
|
+
opts.clean
|
33
43
|
def user_data(blueprint, name)
|
34
44
|
Script::Build.new(blueprint, options).run
|
35
45
|
UserData.new(blueprint, options.merge(name: name)).generate
|
36
46
|
end
|
37
47
|
|
38
|
-
desc "summary BLUEPRINT
|
48
|
+
desc "summary BLUEPRINT", "Prints summary of CloudFormation templates."
|
39
49
|
long_desc Help.text("summary")
|
40
|
-
|
41
|
-
|
50
|
+
opts.source
|
51
|
+
opts.template
|
52
|
+
def summary(blueprint)
|
53
|
+
Lono::Inspector::Summary.new(options.merge(blueprint: blueprint)).run
|
42
54
|
end
|
43
55
|
|
44
56
|
desc "xgraph STACK", "Graphs dependencies tree of CloudFormation template resources."
|
45
57
|
long_desc Help.text("xgraph")
|
46
58
|
option :display, type: :string, desc: "graph or text", default: "graph"
|
47
59
|
option :noop, type: :boolean, desc: "noop mode"
|
48
|
-
|
49
|
-
|
50
|
-
|
60
|
+
opts.source
|
61
|
+
opts.template
|
62
|
+
def xgraph(blueprint)
|
63
|
+
Lono::Inspector::Graph.new(options.merge(blueprint: blueprint)).run
|
51
64
|
end
|
52
65
|
|
53
66
|
desc "seed BLUEPRINT", "Generates starter configs for a blueprint."
|
54
67
|
long_desc Help.text("seed")
|
55
68
|
option :param, desc: "override convention and specify the param file to use"
|
56
|
-
|
69
|
+
opts.source
|
70
|
+
opts.template
|
57
71
|
add_runtime_options! # Thor::Action options like --force
|
58
72
|
def seed(blueprint)
|
59
|
-
Seed.new(blueprint
|
73
|
+
Seed.new(options.merge(blueprint: blueprint)).create
|
60
74
|
end
|
61
75
|
|
62
|
-
desc "app_files BLUEPRINT", "Builds app files"
|
76
|
+
desc "app_files BLUEPRINT", "Builds app files", hide: true
|
63
77
|
long_desc Help.text("app_files")
|
64
78
|
add_runtime_options! # Thor::Action options like --force
|
65
79
|
def app_files(blueprint)
|
@@ -71,6 +85,12 @@ module Lono
|
|
71
85
|
Clean.new(options).run
|
72
86
|
end
|
73
87
|
|
88
|
+
desc "upgrade", "Upgrade lono"
|
89
|
+
long_desc Help.text("upgrade")
|
90
|
+
def upgrade
|
91
|
+
Upgrade.new(options).run
|
92
|
+
end
|
93
|
+
|
74
94
|
desc "completion *PARAMS", "Prints words for auto-completion."
|
75
95
|
long_desc Help.text("completion")
|
76
96
|
def completion(*params)
|
@@ -86,35 +106,50 @@ module Lono
|
|
86
106
|
desc "version", "Prints version"
|
87
107
|
def version
|
88
108
|
puts "Lono: #{VERSION}"
|
89
|
-
puts "Lono Pro Addon: #{Lono.pro_version}"
|
90
109
|
end
|
91
110
|
|
92
|
-
desc "
|
93
|
-
long_desc Help.text(:
|
94
|
-
subcommand "
|
111
|
+
desc "blueprint SUBCOMMAND", "blueprint subcommands"
|
112
|
+
long_desc Help.text(:blueprint)
|
113
|
+
subcommand "blueprint", Blueprint
|
95
114
|
|
96
115
|
desc "cfn SUBCOMMAND", "cfn subcommands"
|
97
116
|
long_desc Help.text(:cfn)
|
98
117
|
subcommand "cfn", Cfn
|
99
118
|
|
119
|
+
desc "code SUBCOMMAND", "code subcommands"
|
120
|
+
long_desc Help.text(:code)
|
121
|
+
subcommand "code", Code
|
122
|
+
|
123
|
+
desc "configset SUBCOMMAND", "configset subcommands"
|
124
|
+
long_desc Help.text(:configset)
|
125
|
+
subcommand "configset", Configset
|
126
|
+
|
100
127
|
desc "param SUBCOMMAND", "param subcommands"
|
101
128
|
long_desc Help.text(:param)
|
102
129
|
subcommand "param", Param
|
103
130
|
|
104
|
-
desc "
|
105
|
-
long_desc Help.text(:
|
106
|
-
subcommand "
|
131
|
+
desc "pro SUBCOMMAND", "pro subcommands"
|
132
|
+
long_desc Help.text(:pro)
|
133
|
+
subcommand "pro", Pro
|
107
134
|
|
108
|
-
desc "
|
109
|
-
long_desc Help.text(:
|
110
|
-
subcommand "
|
135
|
+
desc "registration SUBCOMMAND", "registration subcommands"
|
136
|
+
long_desc Help.text(:registration)
|
137
|
+
subcommand "registration", Registration
|
111
138
|
|
112
139
|
desc "s3 SUBCOMMAND", "s3 subcommands"
|
113
140
|
long_desc Help.text(:s3)
|
114
141
|
subcommand "s3", S3
|
115
142
|
|
116
|
-
desc "
|
117
|
-
long_desc Help.text(:
|
118
|
-
subcommand "
|
143
|
+
desc "script SUBCOMMAND", "script subcommands"
|
144
|
+
long_desc Help.text(:script)
|
145
|
+
subcommand "script", Script
|
146
|
+
|
147
|
+
desc "sets SUBCOMMAND", "sets subcommands"
|
148
|
+
long_desc Help.text(:sets)
|
149
|
+
subcommand "sets", Sets
|
150
|
+
|
151
|
+
desc "template SUBCOMMAND", "template subcommands"
|
152
|
+
long_desc Help.text(:template)
|
153
|
+
subcommand "template", Template
|
119
154
|
end
|
120
155
|
end
|
data/lib/lono/code.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Lono
|
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
|
+
Importer.new(options.merge(source: source)).run
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "convert SOURCE", "Converts snippet of JSON or YAML CloudFormation templates to Ruby code."
|
16
|
+
long_desc Help.text("code/convert")
|
17
|
+
option :casing, default: "as-is", desc: "Controls casing of logical ids. IE: as-is, camelcase or underscore"
|
18
|
+
def convert(source)
|
19
|
+
Importer::Converter.new(options.merge(source: source)).run
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/lono/command.rb
CHANGED
@@ -91,6 +91,13 @@ module Lono
|
|
91
91
|
def website
|
92
92
|
"http://lono.cloud"
|
93
93
|
end
|
94
|
+
|
95
|
+
# https://github.com/erikhuda/thor/issues/244
|
96
|
+
# Deprecation warning: Thor exit with status 0 on errors. To keep this behavior, you must define `exit_on_failure?` in `Lono::CLI`
|
97
|
+
# You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.
|
98
|
+
def exit_on_failure?
|
99
|
+
true
|
100
|
+
end
|
94
101
|
end
|
95
102
|
end
|
96
103
|
end
|
data/lib/lono/config_location.rb
CHANGED
@@ -1,16 +1,11 @@
|
|
1
1
|
module Lono
|
2
|
-
class ConfigLocation
|
2
|
+
class ConfigLocation < AbstractBase
|
3
3
|
extend Memoist
|
4
|
-
include Lono::Conventions
|
5
4
|
|
6
5
|
def initialize(config, options={}, env=Lono.env, root=Lono.root)
|
6
|
+
super(options)
|
7
7
|
# config can be params or variables
|
8
|
-
@config, @options, @
|
9
|
-
|
10
|
-
@stack = options[:stack]
|
11
|
-
@blueprint = options[:blueprint] || @stack
|
12
|
-
@template, @param = template_param_convention(options)
|
13
|
-
|
8
|
+
@config, @options, @env, @root = config, options, env, root
|
14
9
|
@requested = determine_requested
|
15
10
|
end
|
16
11
|
|
@@ -73,14 +68,12 @@ module Lono
|
|
73
68
|
def determine_requested
|
74
69
|
# param is usually set from the convention. when set from convention stack name takes higher precedence
|
75
70
|
config_key = @config.singularize.to_sym # param or variable
|
76
|
-
@options[config_key] || @options[:config] || @
|
71
|
+
@options[config_key] || @options[:config] || @stack
|
77
72
|
end
|
78
73
|
|
79
74
|
def requested_file(path)
|
80
|
-
# List of paths to consider from initial path provided
|
81
|
-
paths =
|
82
|
-
[path, "#{path}.txt", "#{path}.sh"] :
|
83
|
-
[path, "#{path}.rb"]
|
75
|
+
# List of paths to consider from initial path provided. Combine params and variables possible paths for simplicity.
|
76
|
+
paths = [path, "#{path}.txt", "#{path}.sh", "#{path}.rb"].compact
|
84
77
|
paths.find { |p| File.file?(p) }
|
85
78
|
end
|
86
79
|
memoize :requested_file
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require "yaml"
|
2
|
+
|
3
|
+
class Lono::Configset
|
4
|
+
class Combiner
|
5
|
+
def initialize(cfn, options={})
|
6
|
+
@cfn, @options = cfn, options
|
7
|
+
|
8
|
+
@sets = []
|
9
|
+
@map = {} # stores resource logical id => metadata cfn-init
|
10
|
+
end
|
11
|
+
|
12
|
+
def metadata_map
|
13
|
+
return {} unless additional_configsets?
|
14
|
+
|
15
|
+
existing_configsets.each do |data|
|
16
|
+
add(data[:registry], data[:metdata_configset])
|
17
|
+
end
|
18
|
+
|
19
|
+
Register::Blueprint.configsets.each do |registry|
|
20
|
+
loader = Lono::Blueprint::Configset::Loader.new(registry, @options)
|
21
|
+
add(registry, loader.metdata_configset)
|
22
|
+
end
|
23
|
+
Register::Project.configsets.each do |registry|
|
24
|
+
loader = Loader.new(registry, @options)
|
25
|
+
add(registry, loader.metdata_configset)
|
26
|
+
end
|
27
|
+
|
28
|
+
combine
|
29
|
+
Register::Blueprint.clear! # in case of lono generate for all templates
|
30
|
+
Register::Project.clear! # in case of lono generate for all templates
|
31
|
+
@map
|
32
|
+
end
|
33
|
+
|
34
|
+
def add(registry, metadata)
|
35
|
+
@sets << [registry, metadata.dup]
|
36
|
+
end
|
37
|
+
|
38
|
+
def additional_configsets?
|
39
|
+
!Register::Blueprint.configsets.empty? || !Register::Project.configsets.empty?
|
40
|
+
end
|
41
|
+
|
42
|
+
# Normalized/convert cfn template to mimic the registry format
|
43
|
+
def existing_configsets
|
44
|
+
configsets = []
|
45
|
+
@cfn["Resources"].each do |logical_id, attributes|
|
46
|
+
init = attributes.dig("Metadata", "AWS::CloudFormation::Init")
|
47
|
+
|
48
|
+
next unless init
|
49
|
+
|
50
|
+
data = {
|
51
|
+
registry: Lono::Configset::Registry.new(["#{logical_id}OriginalConfigset"], resource: logical_id),
|
52
|
+
metdata_configset: attributes["Metadata"]
|
53
|
+
}
|
54
|
+
configsets << data
|
55
|
+
end
|
56
|
+
configsets
|
57
|
+
end
|
58
|
+
|
59
|
+
def combine
|
60
|
+
# Remove duplicate configsets. Can happen if same configset is in blueprint and project.
|
61
|
+
# Ugly because of the sets structure.
|
62
|
+
@sets.uniq! do |array|
|
63
|
+
registry, _ = array
|
64
|
+
registry.name
|
65
|
+
end
|
66
|
+
|
67
|
+
metadata_map = {}
|
68
|
+
|
69
|
+
@sets.each_with_index do |array, i|
|
70
|
+
padded_i = "%03d" % i
|
71
|
+
registry, metadata = array
|
72
|
+
name, resource = registry.name, registry.resource
|
73
|
+
|
74
|
+
metadata_map[resource] ||= {"AWS::CloudFormation::Init" => {"configSets" => {}}}
|
75
|
+
configSets = metadata_map[resource]["AWS::CloudFormation::Init"]["configSets"]
|
76
|
+
|
77
|
+
configSets["default"] ||= []
|
78
|
+
configSets["default"] << {"ConfigSet" => name}
|
79
|
+
|
80
|
+
validate_structure!(name, metadata)
|
81
|
+
init = metadata["AWS::CloudFormation::Init"]
|
82
|
+
|
83
|
+
if init.key?("configSets")
|
84
|
+
cs = init.delete("configSets") # Only support configSets with simple Array of Strings
|
85
|
+
validate_simple!(registry, cs)
|
86
|
+
configSets[name] = cs["default"].map {|c| "#{padded_i}_#{c}" }
|
87
|
+
init.transform_keys! { |c| "#{padded_i}_#{c}" }
|
88
|
+
else # simple config
|
89
|
+
config_key = "#{padded_i}_single_generated"
|
90
|
+
configSets[name] = [config_key]
|
91
|
+
init = {config_key => init["config"]}
|
92
|
+
end
|
93
|
+
|
94
|
+
metadata_map[resource]["AWS::CloudFormation::Init"].merge!(init)
|
95
|
+
@map[resource] = metadata_map[resource]
|
96
|
+
end
|
97
|
+
@map
|
98
|
+
end
|
99
|
+
|
100
|
+
def validate_structure!(name, metadata)
|
101
|
+
return if metadata.is_a?(Hash) && metadata.key?("AWS::CloudFormation::Init")
|
102
|
+
|
103
|
+
puts "ERROR: The #{name} configset does not appear to have a AWS::CloudFormation::Init key".color(:red)
|
104
|
+
puts "Please double check the #{name} configset.yml structure"
|
105
|
+
exit 1
|
106
|
+
end
|
107
|
+
|
108
|
+
def validate_simple!(registry, cs)
|
109
|
+
has_complex_type = cs["default"].detect { |s| !s.is_a?(String) }
|
110
|
+
if has_complex_type
|
111
|
+
message =<<~EOL
|
112
|
+
ERROR: The configset #{registry.name} has a configSets property with a complex type.
|
113
|
+
configSets:
|
114
|
+
|
115
|
+
#{cs}
|
116
|
+
|
117
|
+
lono configsets only supports combining configSets with an Array of Strings.
|
118
|
+
EOL
|
119
|
+
if ENV['LONO_TEST']
|
120
|
+
raise message
|
121
|
+
else
|
122
|
+
puts message.color(:red)
|
123
|
+
exit 1
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|