cfhighlander 0.2.1 → 0.3.0.alpha.1528936037
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +199 -82
- data/bin/cfhighlander +1 -1
- data/bin/{highlander.rb → cfhighlander.rb} +39 -23
- data/cfndsl_ext/sg.rb +29 -2
- data/hl_ext/mapping_helper.rb +6 -4
- data/lib/{highlander.compiler.rb → cfhighlander.compiler.rb} +26 -18
- data/lib/{highlander.dsl.base.rb → cfhighlander.dsl.base.rb} +3 -2
- data/lib/cfhighlander.dsl.params.rb +108 -0
- data/lib/cfhighlander.dsl.subcomponent.rb +274 -0
- data/lib/{highlander.dsl.rb → cfhighlander.dsl.template.rb} +111 -63
- data/lib/cfhighlander.factory.rb +45 -0
- data/lib/cfhighlander.factory.templatefinder.rb +248 -0
- data/lib/{highlander.helper.rb → cfhighlander.helper.rb} +2 -2
- data/lib/{highlander.mapproviders.rb → cfhighlander.mapproviders.rb} +1 -1
- data/lib/cfhighlander.model.component.rb +177 -0
- data/lib/cfhighlander.model.templatemeta.rb +25 -0
- data/lib/{highlander.publisher.rb → cfhighlander.publisher.rb} +3 -3
- data/lib/{highlander.validator.rb → cfhighlander.validator.rb} +1 -1
- data/lib/util/zip.util.rb +1 -1
- data/templates/cfndsl.component.template.erb +15 -14
- metadata +38 -15
- data/lib/highlander.dsl.component.rb +0 -243
- data/lib/highlander.dsl.params.rb +0 -113
- data/lib/highlander.factory.rb +0 -359
@@ -0,0 +1,248 @@
|
|
1
|
+
LOCAL_CFHIGHLANDER_CACHE_LOCATION = "#{ENV['HOME']}/.cfhighlander/components"
|
2
|
+
|
3
|
+
require_relative './cfhighlander.model.templatemeta'
|
4
|
+
|
5
|
+
module Cfhighlander
|
6
|
+
|
7
|
+
module Factory
|
8
|
+
|
9
|
+
class TemplateFinder
|
10
|
+
|
11
|
+
def initialize(component_sources = [])
|
12
|
+
## First look in local $PWD/components folder
|
13
|
+
## Then search for cached $HOME/.highlander/components
|
14
|
+
## Then search in sources given by dsl
|
15
|
+
default_locations = [
|
16
|
+
LOCAL_CFHIGHLANDER_CACHE_LOCATION,
|
17
|
+
File.expand_path('components'),
|
18
|
+
File.expand_path('.')
|
19
|
+
]
|
20
|
+
default_locations.each do |predefined_path|
|
21
|
+
component_sources.unshift(predefined_path)
|
22
|
+
end
|
23
|
+
|
24
|
+
@component_sources = component_sources
|
25
|
+
end
|
26
|
+
|
27
|
+
def findTemplateDefault(template_name, component_version)
|
28
|
+
default_lookup_url = 'https://github.com/theonestack'
|
29
|
+
default_lookup_url = ENV['HIGHLANDER_DEFAULT_COMPONENT_GIT_LOOKUP'] if ENV.key? 'HIGHLANDER_DEFAULT_COMPONENT_GIT_LOOKUP'
|
30
|
+
default_lookup_url = ENV['CFHIGHLANDER_DEFAULT_COMPONENT_GIT_LOOKUP'] if ENV.key? 'CFHIGHLANDER_DEFAULT_COMPONENT_GIT_LOOKUP'
|
31
|
+
|
32
|
+
git_url = "#{default_lookup_url}/hl-component-#{template_name}"
|
33
|
+
|
34
|
+
if component_version.nil? or component_version.empty? or component_version == 'latest'
|
35
|
+
branch = 'master'
|
36
|
+
else
|
37
|
+
branch = component_version
|
38
|
+
end
|
39
|
+
local_path = "#{LOCAL_CFHIGHLANDER_CACHE_LOCATION}/#{template_name}/#{component_version}"
|
40
|
+
return findTemplateGit(local_path, template_name, component_version, git_url, branch)
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
def findTemplateGit(cache_path, component_name, component_version, git_url, branch)
|
45
|
+
begin
|
46
|
+
cache_path = "#{cache_path}/" unless cache_path.end_with? '/'
|
47
|
+
# if this is snapshot, clean local cache
|
48
|
+
if branch.end_with? '.snapshot'
|
49
|
+
branch = branch.gsub('.snapshot', '')
|
50
|
+
FileUtils.rmtree cache_path if File.exist? cache_path and File.directory? cache_path
|
51
|
+
end
|
52
|
+
|
53
|
+
# if local cache exists, return from cache
|
54
|
+
if not Dir.glob("#{cache_path}*.highlander.rb").empty?
|
55
|
+
# if cache exists, just return from cache
|
56
|
+
component_name = Dir.glob("#{cache_path}*.highlander.rb")[0].gsub(cache_path, '').gsub('.highlander.rb', '')
|
57
|
+
STDERR.puts("DEPRECATED: #{component_name}: Use *.cfhighlander.rb template file name pattern")
|
58
|
+
return component_name, cache_path
|
59
|
+
end
|
60
|
+
|
61
|
+
if not Dir.glob("#{cache_path}*.cfhighlander.rb").empty?
|
62
|
+
# if cache exists, just return from cache
|
63
|
+
component_name = Dir.glob("#{cache_path}*.cfhighlander.rb")[0].gsub(cache_path, '').gsub('.cfhighlander.rb', '')
|
64
|
+
return component_name, cache_path
|
65
|
+
end
|
66
|
+
|
67
|
+
# shallow clone
|
68
|
+
puts "Trying to load #{component_name}/#{component_version} from #{git_url}##{branch} ... "
|
69
|
+
clone_opts = { depth: 1 }
|
70
|
+
clone_opts[:branch] = branch if not (branch.nil? or branch.empty?)
|
71
|
+
Git.clone git_url, cache_path, clone_opts
|
72
|
+
puts "\t .. cached in #{cache_path}\n"
|
73
|
+
# return from cache once it's cloned
|
74
|
+
return findTemplateGit(cache_path, component_name, component_version, git_url, branch)
|
75
|
+
rescue Exception => e
|
76
|
+
STDERR.puts "Failed to resolve component #{component_name}@#{component_version} from #{git_url}"
|
77
|
+
STDERR.puts e
|
78
|
+
return nil
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def findTemplateS3(s3_location, component_name, component_version, use_legacy_extension = true)
|
83
|
+
parts = s3_location.split('/')
|
84
|
+
bucket = parts[2]
|
85
|
+
prefix = parts[3]
|
86
|
+
s3_key = "#{prefix}/#{component_name}/#{component_version}/#{component_name}.highlander.rb"
|
87
|
+
s3_prefix = "#{prefix}/#{component_name}/#{component_version}/"
|
88
|
+
local_destination = "#{LOCAL_CFHIGHLANDER_CACHE_LOCATION}/#{component_name}/#{component_version}"
|
89
|
+
begin
|
90
|
+
s3 = Aws::S3::Client.new({ region: s3_bucket_region(bucket) })
|
91
|
+
FileUtils.mkdir_p local_destination unless Dir.exist? local_destination
|
92
|
+
|
93
|
+
hl_content = s3.get_object({ bucket: bucket,
|
94
|
+
key: s3_key,
|
95
|
+
response_target: "#{local_destination}/#{component_name}.#{use_legacy_extension ? 'highlander' : 'cfhighlander'}.rb"
|
96
|
+
})
|
97
|
+
# if code execution got so far we consider file exists and download it locally
|
98
|
+
component_files = s3.list_objects_v2({ bucket: bucket, prefix: s3_prefix })
|
99
|
+
component_files.contents.each {|s3_object|
|
100
|
+
file_name = s3_object.key.gsub(s3_prefix, '')
|
101
|
+
destination_file = "#{local_destination}/#{file_name}"
|
102
|
+
destination_dir = File.dirname(destination_file)
|
103
|
+
print "Caching #{file_name} of #{component_name}@#{component_version} in #{destination_dir} ... "
|
104
|
+
|
105
|
+
FileUtils.mkpath(destination_dir) unless File.exists?(destination_dir)
|
106
|
+
s3.get_object({ bucket: bucket, key: s3_object.key, response_target: destination_file })
|
107
|
+
print " [OK] \n"
|
108
|
+
}
|
109
|
+
if use_legacy_extension
|
110
|
+
STDERR.puts "DEPRECATED: s3 load #{component_name} with *.highlander.rb template file name pattern"
|
111
|
+
end
|
112
|
+
return local_destination
|
113
|
+
rescue => e
|
114
|
+
# this handles both nonexisting key and bucket
|
115
|
+
if use_legacy_extension
|
116
|
+
return findTemplateS3(s3_location, component_name, component_version, false)
|
117
|
+
end
|
118
|
+
puts("#{component_name} not found in s3://#{bucket}/#{prefix}")
|
119
|
+
STDERR.puts(e.to_s) unless e.message.include? 'does not exist'
|
120
|
+
return nil
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
# will try and locate template based on git template location
|
125
|
+
# if template location is not git repo, returns nil
|
126
|
+
def tryFindTemplateGit(template_location, template_version)
|
127
|
+
|
128
|
+
# avoid any nres
|
129
|
+
template_version = '' if template_version.nil?
|
130
|
+
|
131
|
+
# if empty or latest branch is empty
|
132
|
+
if template_version.empty? or template_version == 'latest' or template_version == 'latest.snapshot'
|
133
|
+
branch = ''
|
134
|
+
else
|
135
|
+
# otherwise component version is actual branch
|
136
|
+
branch = template_version
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
git_url = nil
|
141
|
+
if template_location.start_with? 'git:'
|
142
|
+
git_url = template_location.gsub('git:', '')
|
143
|
+
elsif template_location.start_with? 'github:'
|
144
|
+
git_url = "https://github.com/#{template_location.gsub('github:', '')}"
|
145
|
+
elsif template_location.start_with? 'github.com:'
|
146
|
+
git_url = "https://github.com/#{template_location.gsub('github.com:', '')}"
|
147
|
+
end
|
148
|
+
|
149
|
+
|
150
|
+
if not git_url.nil?
|
151
|
+
local_path = "#{LOCAL_CFHIGHLANDER_CACHE_LOCATION}/#{template_location.gsub(':', '_').gsub(/\/+/, '/')}/#{template_version}"
|
152
|
+
template_name, location = findTemplateGit(local_path, template_location, template_version, git_url, branch)
|
153
|
+
if location.nil?
|
154
|
+
raise "Could not resolve component #{template_location}@#{template_version}"
|
155
|
+
else
|
156
|
+
return template_name, template_version, location
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
return nil
|
161
|
+
end
|
162
|
+
|
163
|
+
def findTemplate(template_name, template_version)
|
164
|
+
template_version_s = template_version.nil? ? 'latest' : template_version
|
165
|
+
template_version = nil if template_version == 'latest'
|
166
|
+
is_git_template = template_name.start_with? 'git'
|
167
|
+
|
168
|
+
if template_name.include? '@' and (not template_name.start_with? 'git')
|
169
|
+
parts = template_name.split('@')
|
170
|
+
template_name = parts[0]
|
171
|
+
template_version = parts[1]
|
172
|
+
template_version_s = template_version
|
173
|
+
end
|
174
|
+
|
175
|
+
if template_name.include? '#' and (is_git_template)
|
176
|
+
parts = template_name.split('#')
|
177
|
+
template_name = parts[0]
|
178
|
+
template_version = parts[1]
|
179
|
+
template_version_s = template_version
|
180
|
+
end
|
181
|
+
|
182
|
+
# if component specified as git location
|
183
|
+
if is_git_template
|
184
|
+
new_template_name, new_version, candidate_git = tryFindTemplateGit(template_name, template_version_s)
|
185
|
+
return build_meta(new_template_name, new_version, candidate_git) unless candidate_git.nil?
|
186
|
+
end
|
187
|
+
|
188
|
+
# if not git but has .snapshot lookup in default, it is allowed to reference default
|
189
|
+
# snapshots
|
190
|
+
if (not template_version.nil?) and template_version.end_with? '.snapshot'
|
191
|
+
new_template_name, snapshot_candidate_location = findTemplateDefault(template_name, template_version_s)
|
192
|
+
return build_meta(new_template_name, template_version, snapshot_candidate_location) unless snapshot_candidate_location.nil?
|
193
|
+
end
|
194
|
+
|
195
|
+
# try in all of the component sources
|
196
|
+
@component_sources.each do |source|
|
197
|
+
template_full_name = "#{template_name}@#{template_version.nil? ? 'latest' : template_version}"
|
198
|
+
# TODO handle http(s) sources and their download to local
|
199
|
+
if source.start_with?('http')
|
200
|
+
raise StandardError, 'http(s) sources not supported yet'
|
201
|
+
elsif source.start_with?('s3://')
|
202
|
+
# s3 candidate
|
203
|
+
|
204
|
+
s3_candidate = findTemplateS3(source, template_name, template_version_s)
|
205
|
+
# at this point all component files are download to local file system and consumed from there
|
206
|
+
return build_meta(template_name, template_version_s, s3_candidate) unless s3_candidate.nil?
|
207
|
+
|
208
|
+
else
|
209
|
+
# file system candidate
|
210
|
+
candidate = "#{source}/#{template_name}"
|
211
|
+
candidate = "#{candidate}/#{template_version}" unless template_version.nil?
|
212
|
+
candidate_hl_path = "#{candidate}/#{template_name}.highlander.rb"
|
213
|
+
candidate_cfhl_path = "#{candidate}/#{template_name}.cfhighlander.rb"
|
214
|
+
candidate2_hl_path = "#{source}/#{template_name}.highlander.rb"
|
215
|
+
candidate2_cfhl_path = "#{source}/#{template_name}.cfhighlander.rb"
|
216
|
+
puts "TRACE: Trying to load #{template_full_name} from #{candidate} ... "
|
217
|
+
if (File.exist?(candidate_hl_path) or File.exist?(candidate_cfhl_path))
|
218
|
+
return build_meta(template_name, template_version_s, candidate)
|
219
|
+
end
|
220
|
+
|
221
|
+
puts "TRACE: Trying to load #{template_full_name} from #{source} ... "
|
222
|
+
# if component version is latest it is allowed to search in path
|
223
|
+
# with no version component in it
|
224
|
+
if (File.exist?(candidate2_hl_path) or File.exist?(candidate2_cfhl_path))
|
225
|
+
return build_meta(template_name, 'latest', source)
|
226
|
+
end unless template_version_s != 'latest'
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
# try default component source on github
|
231
|
+
template_name, default_candidate = findTemplateDefault(template_name, template_version_s)
|
232
|
+
return build_meta(template_name, template_version_s, default_candidate) unless default_candidate.nil?
|
233
|
+
|
234
|
+
return nil
|
235
|
+
end
|
236
|
+
|
237
|
+
def build_meta(template_name, template_version, template_location)
|
238
|
+
return Cfhighlander::Model::TemplateMetadata.new(
|
239
|
+
template_name: template_name,
|
240
|
+
template_version: template_version,
|
241
|
+
template_location: template_location)
|
242
|
+
end
|
243
|
+
|
244
|
+
end
|
245
|
+
|
246
|
+
end
|
247
|
+
|
248
|
+
end
|
@@ -0,0 +1,177 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Cfhighlander
|
4
|
+
|
5
|
+
module Model
|
6
|
+
|
7
|
+
class Component
|
8
|
+
|
9
|
+
attr_accessor :component_dir,
|
10
|
+
:config,
|
11
|
+
:highlander_dsl_path,
|
12
|
+
:cfndsl_path,
|
13
|
+
:highlander_dsl,
|
14
|
+
:cfndsl_content,
|
15
|
+
:mappings,
|
16
|
+
:name,
|
17
|
+
:template,
|
18
|
+
:version,
|
19
|
+
:distribution_bucket,
|
20
|
+
:distribution_prefix,
|
21
|
+
:component_files,
|
22
|
+
:cfndsl_ext_files,
|
23
|
+
:lambda_src_files
|
24
|
+
|
25
|
+
attr_reader :cfn_model, :outputs
|
26
|
+
|
27
|
+
def initialize(template_meta, component_name)
|
28
|
+
@template = template_meta
|
29
|
+
@name = component_name
|
30
|
+
@component_dir = template_meta.template_location
|
31
|
+
@mappings = {}
|
32
|
+
@version = template_meta.template_version
|
33
|
+
@distribution_bucket = nil
|
34
|
+
@distribution_prefix = nil
|
35
|
+
@component_files = []
|
36
|
+
@cfndsl_ext_files = []
|
37
|
+
@lambda_src_files = []
|
38
|
+
end
|
39
|
+
|
40
|
+
# load component configuration files
|
41
|
+
def load_config()
|
42
|
+
@config = {} if @config.nil?
|
43
|
+
Dir["#{@component_dir}/*.config.yaml"].each do |config_file|
|
44
|
+
puts "INFO Loading config for #{@name}: read file:#{config_file} "
|
45
|
+
partial_config = YAML.load(File.read(config_file))
|
46
|
+
unless partial_config.nil?
|
47
|
+
@config.extend(partial_config)
|
48
|
+
@component_files << config_file
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# load extensions
|
54
|
+
def loadDepandantExt()
|
55
|
+
@highlander_dsl.dependson_components.each do |requirement|
|
56
|
+
requirement.component_loaded.cfndsl_ext_files.each do |file|
|
57
|
+
cfndsl_ext_files << file
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# evaluate components template
|
63
|
+
# @param [Hash] config_override
|
64
|
+
def load(config_override = nil)
|
65
|
+
if @component_dir.start_with? 'http'
|
66
|
+
raise StandardError, 'http(s) sources not supported yet'
|
67
|
+
end
|
68
|
+
|
69
|
+
legacy_cfhighlander_path = "#{@component_dir}/#{@template.template_name}.highlander.rb"
|
70
|
+
if File.exist? legacy_cfhighlander_path
|
71
|
+
STDERR.puts "DEPRECATED: #{legacy_cfhighlander_path} - Use *.cfhiglander.rb"
|
72
|
+
@highlander_dsl_path = legacy_cfhighlander_path
|
73
|
+
else
|
74
|
+
@highlander_dsl_path = "#{@component_dir}/#{@template.template_name}.cfhighlander.rb"
|
75
|
+
end
|
76
|
+
|
77
|
+
@cfndsl_path = "#{@component_dir}/#{@template.template_name}.cfndsl.rb"
|
78
|
+
candidate_mappings_path = "#{@component_dir}/*.mappings.yaml"
|
79
|
+
candidate_dynamic_mappings_path = "#{@component_dir}/#{@template.template_name}.mappings.rb"
|
80
|
+
|
81
|
+
@cfndsl_ext_files += Dir["#{@component_dir}/ext/cfndsl/*.rb"]
|
82
|
+
@lambda_src_files += Dir["#{@component_dir}/lambdas/**/*"].find_all {|p| not File.directory? p}
|
83
|
+
@component_files += @cfndsl_ext_files
|
84
|
+
@component_files += @lambda_src_files
|
85
|
+
|
86
|
+
@config = {} if @config.nil?
|
87
|
+
|
88
|
+
@config.extend config_override unless config_override.nil?
|
89
|
+
@config['component_version'] = @version unless @version.nil?
|
90
|
+
@config['component_name'] = @name
|
91
|
+
@config['template_name'] = @template.template_name
|
92
|
+
@config['template_version'] = @template.template_version
|
93
|
+
|
94
|
+
|
95
|
+
Dir[candidate_mappings_path].each do |mapping_file|
|
96
|
+
mappings = YAML.load(File.read(mapping_file))
|
97
|
+
@component_files << mapping_file
|
98
|
+
mappings.each do |name, map|
|
99
|
+
@mappings[name] = map
|
100
|
+
end unless mappings.nil?
|
101
|
+
end
|
102
|
+
|
103
|
+
if File.exist? candidate_dynamic_mappings_path
|
104
|
+
require candidate_dynamic_mappings_path
|
105
|
+
@component_files << candidate_dynamic_mappings_path
|
106
|
+
end
|
107
|
+
|
108
|
+
# 1st pass - parse the file
|
109
|
+
@component_files << @highlander_dsl_path
|
110
|
+
@highlander_dsl = eval(File.read(@highlander_dsl_path), binding)
|
111
|
+
# set version if not defined
|
112
|
+
@highlander_dsl.ComponentVersion(@version) unless @version.nil?
|
113
|
+
|
114
|
+
|
115
|
+
if @highlander_dsl.description.nil?
|
116
|
+
if template.template_name == @name
|
117
|
+
description = "#{@name}@#{template.template_version} - v#{@highlander_dsl.version}"
|
118
|
+
else
|
119
|
+
description = "#{@name} - v#{@highlander_dsl.version}"
|
120
|
+
description += " (#{template.template_name}@#{template.template_version})"
|
121
|
+
end
|
122
|
+
|
123
|
+
@highlander_dsl.Description(description)
|
124
|
+
end
|
125
|
+
|
126
|
+
# set (override) distribution options
|
127
|
+
@highlander_dsl.DistributionBucket(@distribution_bucket) unless @distribution_bucket.nil?
|
128
|
+
@highlander_dsl.DistributionPrefix(@distribution_prefix) unless @distribution_prefix.nil?
|
129
|
+
|
130
|
+
if File.exist? @cfndsl_path
|
131
|
+
@component_files << @cfndsl_path
|
132
|
+
@cfndsl_content = File.read(@cfndsl_path)
|
133
|
+
@cfndsl_content.strip!
|
134
|
+
# if there is CloudFormation do [content] end extract only contents
|
135
|
+
### Regex \s is whitespace
|
136
|
+
match_data = /^CloudFormation do\s(.*)end\s?$/m.match(@cfndsl_content)
|
137
|
+
if not match_data.nil?
|
138
|
+
@cfndsl_content = match_data[1]
|
139
|
+
end
|
140
|
+
|
141
|
+
else
|
142
|
+
@cfndsl_content = ''
|
143
|
+
end
|
144
|
+
|
145
|
+
loadDepandantExt()
|
146
|
+
end
|
147
|
+
|
148
|
+
# evaluates cfndsl with current config
|
149
|
+
def eval_cfndsl
|
150
|
+
compiler = Cfhighlander::Compiler::ComponentCompiler.new self
|
151
|
+
@cfn_model = compiler.evaluateCloudFormation().as_json
|
152
|
+
@outputs = (
|
153
|
+
if @cfn_model.key? 'Outputs'
|
154
|
+
then
|
155
|
+
@cfn_model['Outputs'].map {|k, v| ComponentOutput.new self, k, v}
|
156
|
+
else
|
157
|
+
[]
|
158
|
+
end
|
159
|
+
)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
class ComponentOutput
|
164
|
+
|
165
|
+
attr_reader :component, :name, :value
|
166
|
+
|
167
|
+
def initialize(component, name, value)
|
168
|
+
@component = component
|
169
|
+
@name = name
|
170
|
+
@value = value
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
end
|
175
|
+
|
176
|
+
end
|
177
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Cfhighlander
|
2
|
+
|
3
|
+
module Model
|
4
|
+
|
5
|
+
class TemplateMetadata
|
6
|
+
|
7
|
+
@template_name
|
8
|
+
@template_version
|
9
|
+
@template_location
|
10
|
+
|
11
|
+
attr_reader :template_location,
|
12
|
+
:template_version,
|
13
|
+
:template_name
|
14
|
+
|
15
|
+
def initialize(template_name:, template_version:, template_location:)
|
16
|
+
@template_name = template_name
|
17
|
+
@template_version = template_version
|
18
|
+
@template_location = template_location
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
require_relative './
|
1
|
+
require_relative './cfhighlander.compiler'
|
2
2
|
require 'aws-sdk-s3'
|
3
3
|
|
4
|
-
module
|
4
|
+
module Cfhighlander
|
5
5
|
|
6
6
|
module Publisher
|
7
7
|
|
8
|
-
class
|
8
|
+
class ComponentPublisher
|
9
9
|
|
10
10
|
def initialize(component, cleanup)
|
11
11
|
@component = component
|
data/lib/util/zip.util.rb
CHANGED
@@ -8,21 +8,21 @@ CloudFormation do
|
|
8
8
|
<% end %>
|
9
9
|
|
10
10
|
# render subcomponents
|
11
|
-
<% for @
|
12
|
-
CloudFormation_Stack('<%= @
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
})
|
11
|
+
<% for @subcomponent in dsl.subcomponents %>
|
12
|
+
CloudFormation_Stack('<%= @subcomponent.cfn_name %>') do
|
13
|
+
TemplateURL '<%= @subcomponent.distribution_url %>'
|
14
|
+
Parameters ({
|
15
|
+
<% for @param in @subcomponent.parameters %><%="\t"%>'<%=@param.name %>' => <%= @param.cfndsl_value %>,
|
16
|
+
<% end %>})
|
17
|
+
<% if @subcomponent.conditional %>Condition 'Enable<%= @subcomponent.cfn_name %>' <% end %>
|
19
18
|
end
|
20
19
|
<% end %>
|
21
20
|
|
22
21
|
<%= component_cfndsl %>
|
23
22
|
|
24
|
-
|
23
|
+
|
25
24
|
<% unless dsl.lambda_functions_keys.nil? %>
|
25
|
+
# cfhighlander generated lambda functions
|
26
26
|
<% for @key in dsl.lambda_functions_keys %>
|
27
27
|
render_lambda_functions(self,
|
28
28
|
<%= @key %>,
|
@@ -30,16 +30,17 @@ CloudFormation do
|
|
30
30
|
{'bucket'=>'<%= dsl.distribution_bucket %>','prefix' => '<%= dsl.distribution_prefix %>', 'version'=>'<%= dsl.version %>'})
|
31
31
|
<% end %>
|
32
32
|
<% end %>
|
33
|
-
#
|
33
|
+
# cfhighlander generated parameters
|
34
34
|
<% for @param in dsl.parameters.param_list %>
|
35
35
|
Parameter('<%= @param.name %>') do
|
36
36
|
Type '<%= @param.type %>'
|
37
37
|
Default '<%= @param.default_value %>'
|
38
|
-
<% unless @param.no_echo.nil? %>
|
39
|
-
|
40
|
-
<% end %>
|
38
|
+
<% unless @param.no_echo.nil? %>NoEcho <%= @param.no_echo.to_s %> <% end %>
|
39
|
+
<% unless @param.allowed_values.nil? %>AllowedValues <%= @param.allowed_values.to_s %> <% end %>
|
41
40
|
end
|
42
41
|
<% end %>
|
43
42
|
|
44
|
-
|
43
|
+
<% for @condition in dsl.conditions %> Condition('<%= @condition.name %>', <%= @condition.expression %>)
|
44
|
+
<% end %>
|
45
|
+
Description '<%= dsl.description %>'
|
45
46
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cfhighlander
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0.alpha.1528936037
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nikola Tosic
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-06-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: highline
|
@@ -191,6 +191,26 @@ dependencies:
|
|
191
191
|
- - "<"
|
192
192
|
- !ruby/object:Gem::Version
|
193
193
|
version: '2'
|
194
|
+
- !ruby/object:Gem::Dependency
|
195
|
+
name: netaddr
|
196
|
+
requirement: !ruby/object:Gem::Requirement
|
197
|
+
requirements:
|
198
|
+
- - "~>"
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: '1.5'
|
201
|
+
- - ">="
|
202
|
+
- !ruby/object:Gem::Version
|
203
|
+
version: 1.5.1
|
204
|
+
type: :runtime
|
205
|
+
prerelease: false
|
206
|
+
version_requirements: !ruby/object:Gem::Requirement
|
207
|
+
requirements:
|
208
|
+
- - "~>"
|
209
|
+
- !ruby/object:Gem::Version
|
210
|
+
version: '1.5'
|
211
|
+
- - ">="
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: 1.5.1
|
194
214
|
- !ruby/object:Gem::Dependency
|
195
215
|
name: rspec
|
196
216
|
requirement: !ruby/object:Gem::Requirement
|
@@ -214,7 +234,7 @@ extra_rdoc_files: []
|
|
214
234
|
files:
|
215
235
|
- README.md
|
216
236
|
- bin/cfhighlander
|
217
|
-
- bin/
|
237
|
+
- bin/cfhighlander.rb
|
218
238
|
- cfndsl_ext/config/managed_policies.yaml
|
219
239
|
- cfndsl_ext/iam_helper.rb
|
220
240
|
- cfndsl_ext/lambda_helper.rb
|
@@ -223,16 +243,19 @@ files:
|
|
223
243
|
- hl_ext/common_helper.rb
|
224
244
|
- hl_ext/mapping_helper.rb
|
225
245
|
- hl_ext/vpc.rb
|
226
|
-
- lib/
|
227
|
-
- lib/
|
228
|
-
- lib/
|
229
|
-
- lib/
|
230
|
-
- lib/
|
231
|
-
- lib/
|
232
|
-
- lib/
|
233
|
-
- lib/
|
234
|
-
- lib/
|
235
|
-
- lib/
|
246
|
+
- lib/cfhighlander.compiler.rb
|
247
|
+
- lib/cfhighlander.dsl.base.rb
|
248
|
+
- lib/cfhighlander.dsl.params.rb
|
249
|
+
- lib/cfhighlander.dsl.subcomponent.rb
|
250
|
+
- lib/cfhighlander.dsl.template.rb
|
251
|
+
- lib/cfhighlander.factory.rb
|
252
|
+
- lib/cfhighlander.factory.templatefinder.rb
|
253
|
+
- lib/cfhighlander.helper.rb
|
254
|
+
- lib/cfhighlander.mapproviders.rb
|
255
|
+
- lib/cfhighlander.model.component.rb
|
256
|
+
- lib/cfhighlander.model.templatemeta.rb
|
257
|
+
- lib/cfhighlander.publisher.rb
|
258
|
+
- lib/cfhighlander.validator.rb
|
236
259
|
- lib/util/zip.util.rb
|
237
260
|
- templates/cfndsl.component.template.erb
|
238
261
|
homepage: https://github.com/theonestack/cfhighlander/blob/master/README.md
|
@@ -250,9 +273,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
250
273
|
version: '0'
|
251
274
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
252
275
|
requirements:
|
253
|
-
- - "
|
276
|
+
- - ">"
|
254
277
|
- !ruby/object:Gem::Version
|
255
|
-
version:
|
278
|
+
version: 1.3.1
|
256
279
|
requirements: []
|
257
280
|
rubyforge_project:
|
258
281
|
rubygems_version: 2.7.7
|