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/script/base.rb
CHANGED
@@ -1,14 +1,5 @@
|
|
1
1
|
class Lono::Script
|
2
|
-
class Base
|
2
|
+
class Base < Lono::AbstractBase
|
3
3
|
SCRIPTS_INFO_PATH = "#{Lono.config.output_path}/data/scripts_info.txt"
|
4
|
-
include Lono::Blueprint::Root
|
5
|
-
|
6
|
-
def initialize(blueprint, options={})
|
7
|
-
@blueprint, @options = blueprint, options
|
8
|
-
@template = @options[:template] || @blueprint
|
9
|
-
Lono::ProjectChecker.check
|
10
|
-
set_blueprint_root(@blueprint)
|
11
|
-
Lono::ProjectChecker.empty_templates
|
12
|
-
end
|
13
4
|
end
|
14
5
|
end
|
data/lib/lono/script/upload.rb
CHANGED
@@ -3,6 +3,7 @@ require "filesize"
|
|
3
3
|
class Lono::Script
|
4
4
|
class Upload < Base
|
5
5
|
include Lono::AwsServices
|
6
|
+
include Lono::Utils::PrettyTime
|
6
7
|
|
7
8
|
def run
|
8
9
|
Lono::ProjectChecker.check
|
@@ -18,7 +19,7 @@ class Lono::Script
|
|
18
19
|
start_time = Time.now
|
19
20
|
obj.upload_file(tarball_path)
|
20
21
|
time_took = pretty_time(Time.now-start_time).color(:green)
|
21
|
-
puts "Time to upload code to s3: #{time_took}"
|
22
|
+
puts "Time took to upload code to s3: #{time_took}"
|
22
23
|
end
|
23
24
|
|
24
25
|
def filesize
|
@@ -50,16 +51,5 @@ class Lono::Script
|
|
50
51
|
def tarball_path
|
51
52
|
IO.read(SCRIPTS_INFO_PATH).strip
|
52
53
|
end
|
53
|
-
|
54
|
-
# http://stackoverflow.com/questions/4175733/convert-duration-to-hoursminutesseconds-or-similar-in-rails-3-or-ruby
|
55
|
-
def pretty_time(total_seconds)
|
56
|
-
minutes = (total_seconds / 60) % 60
|
57
|
-
seconds = total_seconds % 60
|
58
|
-
if total_seconds < 60
|
59
|
-
"#{seconds.to_i}s"
|
60
|
-
else
|
61
|
-
"#{minutes.to_i}m #{seconds.to_i}s"
|
62
|
-
end
|
63
|
-
end
|
64
54
|
end
|
65
55
|
end
|
data/lib/lono/seed.rb
CHANGED
@@ -1,18 +1,9 @@
|
|
1
1
|
module Lono
|
2
|
-
class Seed
|
3
|
-
include Lono::Blueprint::Root
|
4
|
-
include Lono::Conventions
|
5
|
-
|
6
|
-
def initialize(blueprint, options={})
|
7
|
-
@blueprint, @options = blueprint, options
|
8
|
-
set_blueprint_root(@blueprint)
|
9
|
-
@template, @param = template_param_convention(options)
|
10
|
-
end
|
11
|
-
|
2
|
+
class Seed < AbstractBase
|
12
3
|
def create
|
13
4
|
puts "Creating starter config files for #{@blueprint}"
|
14
5
|
configs_class = load_configs_class # ::Configs or Lono::Seed::Base
|
15
|
-
configs = configs_class.new(@
|
6
|
+
configs = configs_class.new(@options)
|
16
7
|
# The Configs class implements: variables
|
17
8
|
configs.run # setup the instance variables
|
18
9
|
end
|
data/lib/lono/seed/base.rb
CHANGED
@@ -12,27 +12,23 @@ require "yaml"
|
|
12
12
|
# Note there is no params method to hook. The Base class handles params well.
|
13
13
|
#
|
14
14
|
class Lono::Seed
|
15
|
-
class Base
|
16
|
-
include Lono::Blueprint::Root
|
15
|
+
class Base < Lono::AbstractBase
|
17
16
|
include Lono::AwsServices
|
18
|
-
include Lono::Conventions
|
19
17
|
include ServiceRole
|
20
18
|
|
21
19
|
# What's needed for a Thor::Group or "Sequence"
|
22
20
|
# Gives us Thor::Actions commands like create_file
|
23
21
|
include Thor::Actions
|
24
22
|
include Thor::Base
|
23
|
+
# Override Thor::Base initialize
|
24
|
+
def initialize(options={})
|
25
|
+
reinitialize(options)
|
26
|
+
end
|
25
27
|
|
26
28
|
extend Memoist
|
27
29
|
|
28
|
-
# attr_reader :options
|
29
|
-
def initialize(blueprint, options)
|
30
|
-
@blueprint, @options = blueprint, options
|
31
|
-
@template, @param = template_param_convention(options)
|
32
|
-
end
|
33
|
-
|
34
30
|
def run
|
35
|
-
|
31
|
+
generate_template
|
36
32
|
setup
|
37
33
|
self.destination_root = Dir.pwd # Thor::Actions require destination_root to be set
|
38
34
|
create_params
|
@@ -40,74 +36,71 @@ class Lono::Seed
|
|
40
36
|
finish
|
41
37
|
end
|
42
38
|
|
43
|
-
def
|
44
|
-
|
45
|
-
|
46
|
-
# Only supporting the main blueprint for now
|
47
|
-
path = "#{Lono.config.templates_path}/#{@blueprint}.rb"
|
48
|
-
if File.exist?(path)
|
49
|
-
create_param_file(path)
|
50
|
-
end
|
51
|
-
|
52
|
-
# TODO: detect and write multiple templates to different paths
|
53
|
-
# with_each_template do |path|
|
54
|
-
# create_param_file(path)
|
55
|
-
# end
|
39
|
+
def generate_template
|
40
|
+
Lono::Template::Generator.new(@options).run
|
56
41
|
end
|
57
42
|
|
58
|
-
def
|
59
|
-
|
43
|
+
def create_params
|
44
|
+
return unless params
|
45
|
+
create_param_file
|
60
46
|
end
|
61
47
|
|
62
|
-
def create_param_file
|
63
|
-
|
64
|
-
|
65
|
-
lines = []
|
66
|
-
required = required(parameters)
|
67
|
-
lines << "# Required parameters:" unless required.empty?
|
68
|
-
required.each do |name, data|
|
69
|
-
example = description_example(data["Description"])
|
70
|
-
lines << "#{name}=#{example}"
|
71
|
-
end
|
72
|
-
optional = optional(parameters)
|
73
|
-
lines << "# Optional parameters:" unless optional.empty?
|
74
|
-
optional.each do |name, data|
|
75
|
-
value = default_value(data)
|
76
|
-
lines << "# #{name}=#{value}"
|
77
|
-
end
|
78
|
-
|
79
|
-
if lines.empty?
|
48
|
+
def create_param_file
|
49
|
+
@output_template = Lono::Output::Template.new(@blueprint, @template)
|
50
|
+
if @output_template.parameters.empty?
|
80
51
|
puts "Template has no parameters."
|
81
52
|
return
|
82
53
|
end
|
83
54
|
|
84
|
-
|
55
|
+
# Generate by parameter group first
|
56
|
+
lines, shown = [], []
|
57
|
+
@output_template.parameter_groups.each do |label, parameters|
|
58
|
+
lines << "# Parameter Group: #{label}"
|
59
|
+
parameters.each do |name|
|
60
|
+
lines << parameter_line(name)
|
61
|
+
shown << name
|
62
|
+
end
|
63
|
+
lines << ""
|
64
|
+
end if @output_template.parameter_groups
|
65
|
+
|
66
|
+
# Then generate the rest
|
67
|
+
@output_template.parameters.each do |name, data|
|
68
|
+
lines << parameter_line(name) unless shown.include?(name)
|
69
|
+
end
|
70
|
+
|
71
|
+
content = lines.join("\n")
|
85
72
|
dest_path = "configs/#{@blueprint}/params/#{Lono.env}.txt" # only support environment level parameters for now
|
86
73
|
create_file(dest_path, content) # Thor::Action
|
87
74
|
end
|
88
75
|
|
89
|
-
def
|
90
|
-
|
91
|
-
|
92
|
-
|
76
|
+
def parameter_line(name)
|
77
|
+
data = @output_template.parameters[name]
|
78
|
+
example = description_example(data["Description"])
|
79
|
+
if data["Default"].nil?
|
80
|
+
line = "#{name}=#{example} # (required)"
|
81
|
+
else
|
82
|
+
default = data["Default"]
|
83
|
+
line = "# #{name}=#{default}"
|
84
|
+
line = "#{line} # #{example}" if example
|
85
|
+
end
|
86
|
+
line
|
93
87
|
end
|
94
88
|
|
95
|
-
def
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
exit 1
|
101
|
-
end
|
89
|
+
def description_example(description)
|
90
|
+
return unless description
|
91
|
+
md = description.match(/(Example|IE): (.*)/)
|
92
|
+
return unless md
|
93
|
+
md[2]
|
102
94
|
end
|
103
95
|
|
104
|
-
def
|
105
|
-
|
106
|
-
|
107
|
-
return false unless File.exist?(meta_config)
|
96
|
+
def params
|
97
|
+
true
|
98
|
+
end
|
108
99
|
|
109
|
-
|
110
|
-
|
100
|
+
def create_variables
|
101
|
+
return unless variables
|
102
|
+
dest_path = "configs/#{@blueprint}/variables/#{Lono.env}.rb"
|
103
|
+
create_file(dest_path, variables) # Thor::Action
|
111
104
|
end
|
112
105
|
|
113
106
|
def setup; end
|
@@ -118,53 +111,5 @@ class Lono::Seed
|
|
118
111
|
def variables
|
119
112
|
false
|
120
113
|
end
|
121
|
-
|
122
|
-
def write(path, content)
|
123
|
-
FileUtils.mkdir_p(File.dirname(path))
|
124
|
-
IO.write(path, content)
|
125
|
-
end
|
126
|
-
|
127
|
-
def description_example(description)
|
128
|
-
default = ''
|
129
|
-
return default unless description
|
130
|
-
md = description.match(/(Example|IE): (.*)/)
|
131
|
-
return default unless md
|
132
|
-
md[2]
|
133
|
-
end
|
134
|
-
|
135
|
-
def default_value(data)
|
136
|
-
value = data["Default"]
|
137
|
-
# Dont use !blank? since there can be false optional values
|
138
|
-
# Also dont use .empty? since value can be an Integer
|
139
|
-
if value.nil? || value == ''
|
140
|
-
description_example(data["Description"])
|
141
|
-
else
|
142
|
-
value
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
def parameters(app_template_path)
|
147
|
-
builder = Lono::Template::Dsl::Builder.new(app_template_path, @blueprint, quiet: false)
|
148
|
-
template = builder.template
|
149
|
-
template["Parameters"] || []
|
150
|
-
end
|
151
|
-
memoize :parameters
|
152
|
-
|
153
|
-
def required(parameters)
|
154
|
-
parameters.select { |logical_id, p| p["Default"].nil? } # allow for false
|
155
|
-
end
|
156
|
-
|
157
|
-
def optional(parameters)
|
158
|
-
parameters.select { |logical_id, p| !p["Default"].nil? } # allow for false
|
159
|
-
end
|
160
|
-
|
161
|
-
private
|
162
|
-
def with_each_template
|
163
|
-
paths = Dir.glob("#{Lono.config.templates_path}/**/*.rb")
|
164
|
-
files = paths.select{ |e| File.file?(e) }
|
165
|
-
files.each do |path|
|
166
|
-
yield(path)
|
167
|
-
end
|
168
|
-
end
|
169
114
|
end
|
170
|
-
end
|
115
|
+
end
|
data/lib/lono/sets.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
module Lono
|
2
|
+
class Sets < Command
|
3
|
+
opts = Opts.new(self)
|
4
|
+
|
5
|
+
desc "deploy STACK_SET", "Deploy CloudFormation stack set."
|
6
|
+
long_desc Help.text("sets/deploy")
|
7
|
+
opts.deploy
|
8
|
+
def deploy(stack)
|
9
|
+
Deploy.new(options.merge(stack: stack)).run
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "status STACK_SET", "Show current status of stack set."
|
13
|
+
long_desc Help.text("sets/status")
|
14
|
+
def status(stack)
|
15
|
+
status = Status.new(@options.merge(stack: stack, delay_for_threads: false))
|
16
|
+
success = status.show
|
17
|
+
exit 3 unless success
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "delete STACK_SET", "Delete CloudFormation stack set."
|
21
|
+
long_desc Lono::Help.text("sets/delete")
|
22
|
+
option :sure, type: :boolean, desc: "Skips are you sure prompt"
|
23
|
+
def delete(stack)
|
24
|
+
Delete.new(options.merge(stack: stack)).run
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "list", "List CloudFormation stack sets."
|
28
|
+
long_desc Lono::Help.text("sets/list")
|
29
|
+
option :status, default: "active", desc: "active, all or deleted"
|
30
|
+
def list
|
31
|
+
List.new(options).run
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "instances SUBCOMMAND", "instances subcommands"
|
35
|
+
long_desc Help.text("sets/instances")
|
36
|
+
subcommand "instances", Instances
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
class Lono::Sets
|
2
|
+
class Base < Lono::Cfn::Base
|
3
|
+
def run
|
4
|
+
generate_all
|
5
|
+
save
|
6
|
+
end
|
7
|
+
|
8
|
+
def exit_unless_updatable!
|
9
|
+
return true if ENV['LONO_ENV']
|
10
|
+
return false if @options[:noop]
|
11
|
+
|
12
|
+
status = Status.new(@options) # using status for completed?
|
13
|
+
return if status.stack_instances.empty?
|
14
|
+
completed = status.completed?(status.stack_set_status)
|
15
|
+
unless completed
|
16
|
+
puts "Cannot update stack set because #{@stack} is not in an updatable state. Stack set status: #{status.stack_set_status}".color(:red)
|
17
|
+
quit(1)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def build_options
|
22
|
+
parameters = generate_all
|
23
|
+
options = {
|
24
|
+
stack_set_name: @stack,
|
25
|
+
parameters: parameters,
|
26
|
+
capabilities: capabilities, # ["CAPABILITY_IAM", "CAPABILITY_NAMED_IAM"]
|
27
|
+
}
|
28
|
+
options[:tags] = tags unless tags.empty?
|
29
|
+
options[:operation_preferences] = operation_preferences unless operation_preferences.empty?
|
30
|
+
options.reject! {|k, v| v.nil? }
|
31
|
+
set_template_url!(options)
|
32
|
+
options
|
33
|
+
end
|
34
|
+
|
35
|
+
def operation_preferences
|
36
|
+
o = {}
|
37
|
+
o[:failure_tolerance_count] = @options[:failure_tolerance_count]
|
38
|
+
o[:failure_tolerance_percentage] = @options[:failure_tolerance_percentage]
|
39
|
+
o[:max_concurrent_count] = @options[:max_concurrent_count]
|
40
|
+
o[:max_concurrent_percentage] = @options[:max_concurrent_percentage]
|
41
|
+
o.reject! {|k, v| v.nil? }
|
42
|
+
o
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class Lono::Sets
|
2
|
+
class Create < Base
|
3
|
+
def save
|
4
|
+
message = "Creating #{@stack.color(:green)} stack set."
|
5
|
+
if @options[:noop]
|
6
|
+
puts "NOOP #{message}"
|
7
|
+
return
|
8
|
+
end
|
9
|
+
|
10
|
+
if stack_set_exists?(@stack)
|
11
|
+
puts "Cannot create #{@stack.color(:green)} stack set because it already exists.".color(:red)
|
12
|
+
return
|
13
|
+
end
|
14
|
+
|
15
|
+
unless File.exist?(template_path)
|
16
|
+
puts "Cannot create #{@stack.color(:green)} template not found: #{template_path}."
|
17
|
+
return
|
18
|
+
end
|
19
|
+
|
20
|
+
options = build_options
|
21
|
+
show_options(options, "cfn.create_stack_set")
|
22
|
+
|
23
|
+
sure?("Are you sure you want to create the #{@stack} stack set?")
|
24
|
+
|
25
|
+
cfn.create_stack_set(options) # resp.stack_set_id => String. There is no resp.operation_id
|
26
|
+
puts message unless @options[:mute]
|
27
|
+
true # There is no resp.operation_id
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
class Lono::Sets
|
2
|
+
class Delete
|
3
|
+
include Lono::AwsServices
|
4
|
+
include Lono::Sets::Summarize
|
5
|
+
include Lono::Utils::Sure
|
6
|
+
|
7
|
+
def initialize(options={})
|
8
|
+
@options = options
|
9
|
+
@stack = options.delete(:stack)
|
10
|
+
end
|
11
|
+
|
12
|
+
def run
|
13
|
+
message = "Deleting #{@stack} stack set."
|
14
|
+
if @options[:noop]
|
15
|
+
puts "NOOP #{message}"
|
16
|
+
else
|
17
|
+
sure?("Are you sure you want to delete the #{@stack} stack set?", "Be sure that it emptied of stack instances first.")
|
18
|
+
|
19
|
+
if stack_set_exists?(@stack)
|
20
|
+
cfn.delete_stack_set(stack_set_name: @stack) # resp is an Empty structure, so much get operation_id from status
|
21
|
+
puts message
|
22
|
+
else
|
23
|
+
puts "#{@stack.inspect} stack set does not exist".color(:red)
|
24
|
+
return
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
return true if @options[:noop] || !@options[:wait]
|
29
|
+
|
30
|
+
status = Status.new(@options)
|
31
|
+
success = status.wait
|
32
|
+
operation_id = status.operation_id # getting operation_id from status because cfn.delete_stack_set resp is an Empty structure
|
33
|
+
summarize(operation_id)
|
34
|
+
exit 1 unless success
|
35
|
+
|
36
|
+
rescue Aws::CloudFormation::Errors::StackSetNotEmptyException => e
|
37
|
+
puts "ERROR: #{e.class}: #{e.message}".color(:red)
|
38
|
+
puts <<~EOL
|
39
|
+
The stack set must be empty before deleting. Cannot delete stack set until all stack instances are first
|
40
|
+
deleted. If you want to delete all stack instances you can use:
|
41
|
+
|
42
|
+
lono sets instances delete #{@stack} --all
|
43
|
+
|
44
|
+
EOL
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|