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
@@ -0,0 +1,44 @@
|
|
1
|
+
class Lono::Configset
|
2
|
+
class Preparer < Lono::AbstractBase
|
3
|
+
def initialize(options={})
|
4
|
+
super
|
5
|
+
@blueprint = Register::Blueprint.new(options)
|
6
|
+
@project = Register::Project.new(options)
|
7
|
+
@meta = Meta.new(options)
|
8
|
+
@resolver = Resolver.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def run
|
12
|
+
register
|
13
|
+
resolve_dependencies
|
14
|
+
register_dependencies
|
15
|
+
materialize
|
16
|
+
validate_all! # run after final materializer
|
17
|
+
end
|
18
|
+
|
19
|
+
# Stores configsets registry items
|
20
|
+
def register
|
21
|
+
@project.register # IE: evaluates configs/BLUEPRINT/configsets/base.rb
|
22
|
+
@blueprint.register # IE: evaluates BLUEPRINT/config/configsets.rb
|
23
|
+
end
|
24
|
+
|
25
|
+
def resolve_dependencies
|
26
|
+
jades = Lono::Jade.tracked # at this point only top-level
|
27
|
+
@resolver.resolve(jades)
|
28
|
+
end
|
29
|
+
|
30
|
+
def register_dependencies
|
31
|
+
@resolver.register
|
32
|
+
end
|
33
|
+
|
34
|
+
def materialize
|
35
|
+
jades = Lono::Jade.downloaded
|
36
|
+
Materializer::Final.new.build(jades)
|
37
|
+
end
|
38
|
+
|
39
|
+
def validate_all!
|
40
|
+
@blueprint.validate!
|
41
|
+
@project.validate!
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
# Subclasses must implement:
|
2
|
+
#
|
3
|
+
# evaluate
|
4
|
+
#
|
5
|
+
module Lono::Configset::Register
|
6
|
+
class Base < Lono::AbstractBase
|
7
|
+
class_attribute :configsets
|
8
|
+
class_attribute :validations
|
9
|
+
class_attribute :source
|
10
|
+
|
11
|
+
include Dsl
|
12
|
+
include Lono::Configset::EvaluateFile
|
13
|
+
|
14
|
+
def register
|
15
|
+
evaluate
|
16
|
+
jadify
|
17
|
+
end
|
18
|
+
|
19
|
+
def jadify
|
20
|
+
self.class.configsets.each do |registry|
|
21
|
+
Lono::Jade.new(registry.name, jade_type, registry)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def jade_type
|
26
|
+
finder_class.to_s.sub('Lono::Finder::','').underscore
|
27
|
+
end
|
28
|
+
|
29
|
+
# Used in Base#validate!
|
30
|
+
def finder_class
|
31
|
+
case self
|
32
|
+
when Lono::Configset::Register::Blueprint
|
33
|
+
Lono::Finder::Blueprint::Configset
|
34
|
+
when Lono::Configset::Register::Project
|
35
|
+
Lono::Finder::Configset
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Store to be able to provide the validation errors altogether later.
|
40
|
+
def store_for_validation(registry)
|
41
|
+
# save caller line to use later for pointing to exactly line
|
42
|
+
caller_line = caller.grep(/evaluate_file/).first
|
43
|
+
registry.caller_line = caller_line
|
44
|
+
# huge performance improvement by only validating the first configset registration of duplicate gems
|
45
|
+
names = self.class.validations.map {|r| r.name }
|
46
|
+
self.class.validations << registry unless names.include?(registry.name)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Validate the configset before building templates. So user finds out about errors early.
|
50
|
+
def validate!
|
51
|
+
errors = []
|
52
|
+
self.class.validations.each do |registry|
|
53
|
+
config = finder_class.find(registry.name) # finder_class implemented in subclass
|
54
|
+
errors << [:finder_missing, registry] unless config
|
55
|
+
|
56
|
+
if registry.depends_on.nil? && registry.resource.nil?
|
57
|
+
errors << [:resource_missing, registry]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
return if errors.empty? # all good
|
62
|
+
show_errors_and_exit!(errors)
|
63
|
+
end
|
64
|
+
|
65
|
+
def show_errors_and_exit!(errors)
|
66
|
+
errors.each do |error_type, registry|
|
67
|
+
name, caller_line = registry.name, registry.caller_line
|
68
|
+
case error_type
|
69
|
+
when :finder_missing
|
70
|
+
puts "ERROR: Configset with name #{name} not found. Please double check Gemfile and configs/#{@blueprint}/configsets files.".color(:red)
|
71
|
+
pretty_trace(caller_line)
|
72
|
+
when :resource_missing
|
73
|
+
puts "ERROR: Configset with name #{name} does not specify resource. The resource key is required.".color(:red)
|
74
|
+
pretty_trace(caller_line)
|
75
|
+
raise
|
76
|
+
end
|
77
|
+
end
|
78
|
+
exit 1
|
79
|
+
end
|
80
|
+
|
81
|
+
def pretty_trace(caller_line)
|
82
|
+
md = caller_line.match(/(.*\.rb):(\d+):/)
|
83
|
+
path, error_line_number = md[1], md[2].to_i
|
84
|
+
|
85
|
+
context = 5 # lines of context
|
86
|
+
top, bottom = [error_line_number-context-1, 0].max, error_line_number+context-1
|
87
|
+
|
88
|
+
puts "Showing file: #{path}"
|
89
|
+
lines = IO.read(path).split("\n")
|
90
|
+
spacing = lines.size.to_s.size
|
91
|
+
lines[top..bottom].each_with_index do |line_content, index|
|
92
|
+
current_line_number = top+index+1
|
93
|
+
if current_line_number == error_line_number
|
94
|
+
printf("%#{spacing}d %s\n".color(:red), current_line_number, line_content)
|
95
|
+
else
|
96
|
+
printf("%#{spacing}d %s\n", current_line_number, line_content)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
public
|
102
|
+
class << self
|
103
|
+
def clear!
|
104
|
+
self.configsets = []
|
105
|
+
self.validations = []
|
106
|
+
end
|
107
|
+
|
108
|
+
def prepend(registry)
|
109
|
+
self.configsets.unshift(registry) unless has?(registry)
|
110
|
+
end
|
111
|
+
|
112
|
+
def append(registry)
|
113
|
+
self.configsets << registry unless has?(registry)
|
114
|
+
end
|
115
|
+
|
116
|
+
def has?(registry)
|
117
|
+
configsets.detect { |r| r.name == registry.name && r.args == registry.args }
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Lono::Configset::Register
|
2
|
+
class Blueprint < Base
|
3
|
+
self.configsets = []
|
4
|
+
self.validations = []
|
5
|
+
|
6
|
+
def evaluate
|
7
|
+
path = find_configsets
|
8
|
+
evaluate_file(path)
|
9
|
+
end
|
10
|
+
|
11
|
+
def find_configsets
|
12
|
+
path = "#{Lono.blueprint_root}/config/configsets.rb"
|
13
|
+
path if File.exist?(path)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Lono::Configset::Register
|
2
|
+
module Dsl
|
3
|
+
def configset(*args)
|
4
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
5
|
+
registry = Lono::Configset::Registry.new(args, options)
|
6
|
+
self.class.append(registry)
|
7
|
+
store_for_validation(registry)
|
8
|
+
end
|
9
|
+
|
10
|
+
# DSL
|
11
|
+
def source(v)
|
12
|
+
self.class.source = v
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Lono::Configset::Register
|
2
|
+
class Project < Base
|
3
|
+
self.configsets = []
|
4
|
+
self.validations = []
|
5
|
+
|
6
|
+
def evaluate
|
7
|
+
location = Lono::ConfigLocation.new("configsets", @options, Lono.env)
|
8
|
+
evaluate_file(location.lookup_base) if location.lookup_base
|
9
|
+
evaluate_file(location.lookup) if location.lookup # config file
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class Lono::Configset
|
2
|
+
class Registry
|
3
|
+
attr_reader :args, :options
|
4
|
+
attr_accessor :caller_line, :parent, :depends_on
|
5
|
+
def initialize(args, options)
|
6
|
+
@args, @options = args, options
|
7
|
+
end
|
8
|
+
|
9
|
+
def name
|
10
|
+
@args.first
|
11
|
+
end
|
12
|
+
|
13
|
+
def resource
|
14
|
+
@options[:resource]
|
15
|
+
end
|
16
|
+
|
17
|
+
def resource=(v)
|
18
|
+
@options[:resource] = v
|
19
|
+
end
|
20
|
+
|
21
|
+
def gem_options
|
22
|
+
options = @options.dup
|
23
|
+
# Delete special options that is not supported by bundler Gemfile
|
24
|
+
options.delete(:repo)
|
25
|
+
options.delete(:resource)
|
26
|
+
options.delete(:vars)
|
27
|
+
options
|
28
|
+
end
|
29
|
+
|
30
|
+
def vars
|
31
|
+
options[:vars] || {}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
class Lono::Configset
|
2
|
+
class Resolver
|
3
|
+
extend Memoist
|
4
|
+
|
5
|
+
@@dependencies = [] # save to later regsiter configsets
|
6
|
+
|
7
|
+
@@resolving_message_shown = false
|
8
|
+
def resolve(*unresolved)
|
9
|
+
unresolved.flatten! # initially only top-level
|
10
|
+
puts "Resolving dependencies..." if !@@resolving_message_shown && !unresolved.empty?
|
11
|
+
puts "Resolving #{unresolved.map(&:name)}" if ENV['LONO_DEBUG_CONFIGSET']
|
12
|
+
|
13
|
+
@@resolving_message_shown = true
|
14
|
+
|
15
|
+
unresolved.each do |jade|
|
16
|
+
jade.check_for_circular_dependency!
|
17
|
+
jade.materialize
|
18
|
+
jade.dependencies.each do |j|
|
19
|
+
@@dependencies << j # store for later registration
|
20
|
+
unless j.resolved? or unresolved.include?(j)
|
21
|
+
resolve(j)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
jade.resolved! # resolve after depth-first tranversal. So all dependencies have also been resolved at this point.
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def register
|
29
|
+
@@dependencies.each do |jade|
|
30
|
+
# dependency jades have minimal registry info. For additional info is pulled from stored reference data in
|
31
|
+
# jade like jade.resource_from_parent.
|
32
|
+
registry = jade.registry
|
33
|
+
registry.resource = jade.resource_from_parent
|
34
|
+
if jade.type == "blueprint/configset"
|
35
|
+
Register::Blueprint.prepend(registry)
|
36
|
+
elsif jade.type == "configset"
|
37
|
+
Register::Project.prepend(registry)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/lono/conventions.rb
CHANGED
@@ -1,11 +1,22 @@
|
|
1
1
|
module Lono
|
2
|
-
|
3
|
-
|
4
|
-
def
|
5
|
-
options = options
|
6
|
-
template = options
|
7
|
-
|
8
|
-
|
2
|
+
class Conventions
|
3
|
+
attr_reader :stack, :blueprint, :template, :param
|
4
|
+
def initialize(options)
|
5
|
+
@options = options
|
6
|
+
@stack, @blueprint, @template, @param = naming_conventions(options)
|
7
|
+
end
|
8
|
+
|
9
|
+
def naming_conventions(options)
|
10
|
+
o = options.deep_symbolize_keys
|
11
|
+
stack = o[:stack]
|
12
|
+
blueprint = o[:blueprint] || o[:stack]
|
13
|
+
template = o[:template] || blueprint
|
14
|
+
param = o[:param] || template || blueprint
|
15
|
+
[stack, blueprint, template, param]
|
16
|
+
end
|
17
|
+
|
18
|
+
def values
|
19
|
+
[@stack, @blueprint, @template, @param]
|
9
20
|
end
|
10
21
|
end
|
11
22
|
end
|
data/lib/lono/core.rb
CHANGED
@@ -39,23 +39,6 @@ module Lono
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
# Precedence (highest to lowest)
|
43
|
-
# 1. LONO_SUFFIX
|
44
|
-
# 2. .current/lono
|
45
|
-
# 3. config/settings.yml
|
46
|
-
def suffix
|
47
|
-
suffix = ENV['LONO_SUFFIX'] # highest precedence
|
48
|
-
suffix ||= Cfn::Current.suffix
|
49
|
-
unless suffix
|
50
|
-
settings = Setting.new.data
|
51
|
-
suffix ||= settings["stack_name_suffix"] # lowest precedence
|
52
|
-
end
|
53
|
-
|
54
|
-
return if suffix&.empty?
|
55
|
-
suffix
|
56
|
-
end
|
57
|
-
memoize :suffix
|
58
|
-
|
59
42
|
# Do not use the Setting#data to load the profile because it can cause an
|
60
43
|
# infinite loop then if we decide to use Lono.env from within settings class.
|
61
44
|
def settings
|
@@ -67,9 +50,22 @@ module Lono
|
|
67
50
|
end
|
68
51
|
memoize :settings
|
69
52
|
|
70
|
-
def
|
71
|
-
|
72
|
-
|
53
|
+
def lono_pro_removal_check!
|
54
|
+
if lono_pro_installed?
|
55
|
+
puts "ERROR: A lono-pro gem installation has been detected.".color(:red)
|
56
|
+
puts <<~EOL
|
57
|
+
The lono-pro gem is now a part of lono itself. The lono-pro gem has been deprecated.
|
58
|
+
Please uninstall the lono-pro gem and remove it from your Gemfile to continue.
|
59
|
+
EOL
|
60
|
+
exit 1
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def lono_pro_installed?
|
65
|
+
Lono::Pro::VERSION
|
66
|
+
true
|
67
|
+
rescue NameError
|
68
|
+
false
|
73
69
|
end
|
74
70
|
|
75
71
|
private
|
@@ -1,13 +1,12 @@
|
|
1
|
-
# More info:
|
1
|
+
# More info: https://lono.cloud/docs/settings/
|
2
2
|
# The base config is specially treated. It gets included the other environments automatically.
|
3
3
|
# Yaml also directly supports merging with & and <<* syntax but doing it automatically
|
4
4
|
# for a cleaner syntax.
|
5
5
|
base:
|
6
|
-
#
|
6
|
+
# https://lono.cloud/docs/app-scripts/
|
7
7
|
# extract_scripts:
|
8
8
|
# to: "/opt"
|
9
9
|
# as: "ec2-user"
|
10
|
-
# stack_name_suffix: random # tack on a 3 char random string at the end of the stack name for lono cfn create
|
11
10
|
|
12
11
|
development:
|
13
12
|
# When you have AWS_PROFILE set to one of these values, lono will switch to the desired
|
data/lib/lono/file_uploader.rb
CHANGED
@@ -1,19 +1,22 @@
|
|
1
1
|
module Lono
|
2
|
-
class FileUploader
|
2
|
+
class FileUploader < AbstractBase
|
3
3
|
include Lono::Template::AwsService
|
4
4
|
extend Memoist
|
5
5
|
|
6
|
-
def initialize(
|
7
|
-
|
6
|
+
def initialize(options={})
|
7
|
+
super
|
8
8
|
@checksums = {}
|
9
9
|
@prefix = "#{folder_key}/#{Lono.env}/#{blueprint}/files" # s3://s3-bucket/folder/development/files
|
10
10
|
end
|
11
11
|
|
12
12
|
def upload_all
|
13
|
-
|
13
|
+
# pattern = "#{Lono.blueprint_root}/app/files/**/*"
|
14
|
+
# size = Dir.glob(pattern).size
|
15
|
+
# puts "size #{size}"
|
16
|
+
# return unless Dir.glob(pattern).size > 0
|
17
|
+
# puts "Uploading app/files2..."
|
14
18
|
load_checksums!
|
15
19
|
|
16
|
-
pattern = "#{Lono.blueprint_root}/app/files/**/*"
|
17
20
|
Dir.glob(pattern).each do |path|
|
18
21
|
next if ::File.directory?(path)
|
19
22
|
s3_upload(path)
|
@@ -0,0 +1,140 @@
|
|
1
|
+
require "bundler"
|
2
|
+
require "text-table"
|
3
|
+
|
4
|
+
module Lono::Finder
|
5
|
+
class Base
|
6
|
+
extend Memoist
|
7
|
+
|
8
|
+
def initialize(lono_root: nil, blueprint_root: nil)
|
9
|
+
@lono_root = lono_root || Lono.root
|
10
|
+
@blueprint_root = blueprint_root || Lono.blueprint_root
|
11
|
+
end
|
12
|
+
|
13
|
+
# Returns root path of component: blueprint or configset
|
14
|
+
def find(name, local_only: false)
|
15
|
+
all = find_all(local_only: local_only)
|
16
|
+
all.find { |jadespec| jadespec.name == name }
|
17
|
+
end
|
18
|
+
|
19
|
+
def find_all(local_only: false)
|
20
|
+
if local_only
|
21
|
+
local
|
22
|
+
else
|
23
|
+
local + materialized
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# overridden in finder/blueprint/configset.rb
|
28
|
+
def local
|
29
|
+
project + vendor + gems
|
30
|
+
end
|
31
|
+
|
32
|
+
def project
|
33
|
+
roots = path_roots("#{@lono_root}/app/#{type.pluralize}")
|
34
|
+
components(roots, "project")
|
35
|
+
end
|
36
|
+
|
37
|
+
def vendor
|
38
|
+
roots = path_roots("#{@lono_root}/vendor/#{type.pluralize}")
|
39
|
+
components(roots, "vendor")
|
40
|
+
end
|
41
|
+
|
42
|
+
def gems
|
43
|
+
components(gem_roots, "gem")
|
44
|
+
end
|
45
|
+
|
46
|
+
# Folders that each materialized gems to tmp/configsets
|
47
|
+
def materialized
|
48
|
+
components(materialized_gem_roots, "materialized")
|
49
|
+
end
|
50
|
+
|
51
|
+
# Components: blueprints or configsets
|
52
|
+
# Returns array of config Hashes. Example structure:
|
53
|
+
#
|
54
|
+
# [{
|
55
|
+
# name: "cfn-hup",
|
56
|
+
# root: "/path/to/gem/root",
|
57
|
+
# source_type: "project",
|
58
|
+
# },...]
|
59
|
+
#
|
60
|
+
def components(roots, source_type)
|
61
|
+
components = []
|
62
|
+
roots.each do |root|
|
63
|
+
next unless detect?(root)
|
64
|
+
jadespec = Lono::Jadespec.new(root, source_type)
|
65
|
+
components << jadespec
|
66
|
+
end
|
67
|
+
components
|
68
|
+
end
|
69
|
+
memoize :components
|
70
|
+
|
71
|
+
def detect?(root)
|
72
|
+
expr = "#{root}/#{detection_path}"
|
73
|
+
Dir.glob(expr).size > 0
|
74
|
+
end
|
75
|
+
|
76
|
+
# Used for blueprints, configsets, and blueprint/configsets
|
77
|
+
def list(options={})
|
78
|
+
table = Text::Table.new
|
79
|
+
table.head = ["Name", "Path", "Type"]
|
80
|
+
|
81
|
+
components = find_all
|
82
|
+
components.each do |jadespec|
|
83
|
+
pretty_path = jadespec.root.sub("#{Lono.root}/", "")
|
84
|
+
unless options[:filter_materialized] && jadespec.source_type == "materialized"
|
85
|
+
table.rows << [jadespec.name, pretty_path, jadespec.source_type]
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
if table.rows.empty?
|
90
|
+
puts "No #{type.pluralize} found."
|
91
|
+
else
|
92
|
+
puts(options[:message] || "Available #{type.pluralize}:")
|
93
|
+
puts table
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
private
|
98
|
+
def path_roots(path)
|
99
|
+
Dir.glob("#{path}/*").to_a
|
100
|
+
end
|
101
|
+
|
102
|
+
# Example return:
|
103
|
+
#
|
104
|
+
# [
|
105
|
+
# "/home/ec2-user/.rbenv/versions/2.5.6/lib/ruby/gems/2.5.0/gems/rake-13.0.1",
|
106
|
+
# "/home/ec2-user/.rbenv/versions/2.5.6/lib/ruby/gems/2.5.0/gems/thor-0.20.3"
|
107
|
+
# ]
|
108
|
+
#
|
109
|
+
def gem_roots
|
110
|
+
Bundler.load.specs.map do |spec|
|
111
|
+
spec.full_gem_path
|
112
|
+
end
|
113
|
+
end
|
114
|
+
memoize :gem_roots
|
115
|
+
|
116
|
+
def materialized_gem_roots
|
117
|
+
gemfile_lock = "#{Lono.root}/tmp/configsets/Gemfile.lock"
|
118
|
+
return [] unless File.exist?(gemfile_lock)
|
119
|
+
parser = Bundler::LockfileParser.new(Bundler.read_file(gemfile_lock))
|
120
|
+
specs = parser.specs
|
121
|
+
# __materialize__ only exists in Gem::LazySpecification and not in Gem::Specification
|
122
|
+
specs.each { |spec| spec.__materialize__ }
|
123
|
+
specs.map do |spec|
|
124
|
+
spec.full_gem_path
|
125
|
+
end
|
126
|
+
end
|
127
|
+
memoize :materialized_gem_roots
|
128
|
+
|
129
|
+
public
|
130
|
+
class << self
|
131
|
+
def find(name)
|
132
|
+
new.find(name)
|
133
|
+
end
|
134
|
+
|
135
|
+
def list(options={})
|
136
|
+
new.list(options)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|