aws-cfn-compiler 0.8.10 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZmJlYzZjZDIwYzc4YzhiZWYxYjA4ZjgwZGI2NjIzNTBhNWEyNjdhNg==
4
+ MjUzMDEzY2Q4MDYwNjZkYzZmZWYyOTZmNTYxNTQxOTAyNzdiOTU3Yw==
5
5
  data.tar.gz: !binary |-
6
- MzEyNzI0NDI2YWQwYzViYzhiM2M2MzFiZjAyMjE5MGZhMzFhMDA4Yg==
6
+ MmE3YmQ0MmFkZTI2ZmZjOTJhNjM0ZGZlMjI0YzUyZTAyMmRhMTdiMw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDY0NzZjMWE0YzNmMjZkZDk4ZjFhMmY3YzFkYmJjYTA5ZTQwNzkwZmM4YTRk
10
- YTc1Zjk0ODdiZmM2YjBhNDEyN2M1NGZiOWFlZDgyNGE3NWYzNWYzYjgwODU2
11
- ZTkzMzkyOWFjMzI4OTAzZTMzNDFhNjQ1ZjQwY2IwMDY5MTU5YjA=
9
+ MmNiMDAyMDBmNzIzNWRiNGExODZhMzY5NjQ4NzRhMjBiYmFkNTlkOWJhNTc0
10
+ ODc2YTk3NzA5ZWI2MmUzNDg0M2I3ODVlNmE3ZTljZWZlMDgxMGY5YzU0ZTE3
11
+ MTdhZjFlMjJjMGNlNTljZjFiYTRhOGE1MTY4ODhhMDRlYzg4MTI=
12
12
  data.tar.gz: !binary |-
13
- ZTc1Y2VmMzAxOWMwZTZiNzUzMTk2OWY3ZTRiNjQxZGVkYjUxZTBiYjA0NTFi
14
- MTgzNDRmOTNjM2I5YmE0ODYxMmEyYmU5OTEyNjE2ZWRlMmQ3ZDI2ZjRlZGJm
15
- ODZmNjVhZWEwMThiN2EwY2I3YjBiMjlhNmFiYjFlYmE2YmQ3OTQ=
13
+ MmRkNDU0Zjk5ODYwMjE1YTcwZjllYThmMWYwNDRlYmUyODNjZGE4NzEzYTgy
14
+ ZTA2OWEyMzI3YjAwNzQxZWRjYjRjMzVhMzk3NjM3MzgxNjVhMGVjZjc2NjNk
15
+ MThjYTliMDk3NmNjMjc3ZjdkOTQzMDFlMDk5MDM5MTIxZGUwZmM=
@@ -23,8 +23,8 @@ Gem::Specification.new do |spec|
23
23
  spec.add_dependency 'json'
24
24
  spec.add_dependency 'slop'
25
25
  spec.add_dependency 'inifile'
26
- spec.add_dependency 'aws-cfn-dsl', '>= 0.8.0'
27
- spec.add_dependency 'dldinternet-mixlib-cli', '>= 0.1.0'
28
- spec.add_dependency 'dldinternet-mixlib-logging', '>= 0.3.0'
26
+ spec.add_dependency 'aws-cfn-dsl', '>= 0.9.0'
27
+ spec.add_dependency 'dldinternet-mixlib-cli', '>= 0.2.0'
28
+ spec.add_dependency 'dldinternet-mixlib-logging', '>= 0.4.0'
29
29
 
30
30
  end
data/bin/cfn-compiler CHANGED
@@ -4,7 +4,7 @@ require 'rubygems'
4
4
 
5
5
  path = File.dirname(__FILE__)
6
6
  if File.exists?("#{path}/../.gitignore")
7
- %w(aws-cfn-decompiler aws-cfn-compiler aws-cfn-dsl cloudformation-ruby-dsl dldinternet-mixlib-logging).each do |mod|
7
+ %w(aws-cfn-decompiler aws-cfn-compiler aws-cfn-dsl cloudformation-ruby-dsl dldinternet-mixlib-logging dldinternet-mixlib-cli).each do |mod|
8
8
  add_path = File.expand_path(File.join(path, "../../#{mod}", "lib"))
9
9
  $:.unshift(add_path)
10
10
  end
@@ -116,7 +116,7 @@ module Aws
116
116
  def load_spec(spec=nil)
117
117
  if spec
118
118
  abs = nil
119
- [spec, File.join(@config[:directory],spec)].each do |p|
119
+ [spec, File.join(@config[:brick_path_list],spec)].flatten.each do |p|
120
120
  begin
121
121
  abs = File.realpath(File.absolute_path(File.expand_path(p)))
122
122
  break if File.exists?(abs)
@@ -143,7 +143,7 @@ module Aws
143
143
  abort! "Unsupported file type for specification: #{spec}"
144
144
  end
145
145
  else
146
- abort! 'Unable to open specification'+ (abs.nil? ? " or {,#{@config[:directory]}/}#{spec} not found" : ": #{abs}")
146
+ abort! 'Unable to open specification'+ (abs.nil? ? " or {.,#{@config[:brick_path_list].join(',')}/}#{spec} not found" : ": #{abs}")
147
147
  end
148
148
  else
149
149
  abort! 'No specification provided'
@@ -134,11 +134,22 @@ module Aws
134
134
  ref = match[2]
135
135
  # noinspection RubyParenthesesAroundConditionInspection
136
136
  if (subm = match[1].match(%r'^(.+?)/(.+)$'))
137
- path = File.join(File.dirname(@config[:directory]),subm[1])
137
+ @config[:brick_path_list].each do |p|
138
+ path = File.join(p,subm[1]) # File.dirname(@config[:directory])
139
+ unless File.directory?(path)
140
+ path = nil
141
+ end
142
+ end
138
143
  sub = subm[2]
139
144
  else
140
145
  # sub = nil
141
- path = File.join(File.dirname(@config[:directory]),match[1])
146
+ # path = File.join(File.dirname(@config[:directory]),match[1])
147
+ @config[:brick_path_list].each do |p|
148
+ path = File.join(p,match[1]) # File.dirname(@config[:directory])
149
+ unless File.directory?(path)
150
+ path = nil
151
+ end
152
+ end
142
153
  end
143
154
  else
144
155
  # Otherwise it is what it seems ;)
@@ -55,26 +55,40 @@ module Aws
55
55
  end
56
56
 
57
57
  def vet_path(dir,base=nil,rel=false)
58
- if rel
59
- base = File.realpath(File.expand_path(File.join(@config[:directory], base)))
60
- else
61
- base = @config[:directory] unless base
62
- end
63
58
  path = nil
64
- [dir, dir.downcase].each do |d|
65
- path = File.join(base, dir)
59
+ @config[:brick_path_list].each do |p|
60
+ if rel
61
+ # base = File.realpath(File.expand_path(File.join(@config[:directory], base)))
62
+ base = File.realpath(File.expand_path(File.join(p, base)))
63
+ else
64
+ base = p unless base
65
+ end
66
+ [dir, dir.downcase].each do |d|
67
+ path = File.join(base, dir)
68
+ if File.directory?(path)
69
+ break
70
+ end
71
+ end
66
72
  if File.directory?(path)
67
73
  break
68
74
  end
69
75
  end
76
+ patn = path
77
+ unless @config[:expandedpaths]
78
+ patn = short_path(path)
79
+ end
80
+
70
81
  unless File.directory?(path)
71
- @logger.error " !! error: Cannot load bricks from #{path} (started with #{File.join(base, dir)}')"
82
+ @logger.error " !! error: Cannot load bricks from #{patn} with brick path: \n\t#{@config[:brick_path_list].join("\n\t")} \n(started with #{File.join(base, dir)}')"
72
83
  abort!
73
84
  end
74
85
  path
75
86
  end
76
87
 
77
-
88
+ def short_path(path,n=2)
89
+ patn = path.split(File::SEPARATOR)[0-n..-1]
90
+ patn = patn.join(File::SEPARATOR)
91
+ end
78
92
  end
79
93
  end
80
94
  end
@@ -8,6 +8,7 @@ module Aws
8
8
 
9
9
  setup_options
10
10
 
11
+ @opts.on :b, :brick_path=, 'A list of paths to template components (bricks). May also set as the BRICK_PATH environment variable.', as: String
11
12
  @opts.on :F, :format=, 'The output format of the components. [JSON|YAML|Ruby]', { as: String, match: @format_regex, default: 'yaml' }
12
13
  @opts.on :s, :specification=, 'The specification to use when selecting components. A JSON or YAML file', { as: String
13
14
  }
@@ -39,8 +40,75 @@ module Aws
39
40
 
40
41
  @config[:precedence] = @opts[:precedence].split(%r',+\s*').reverse
41
42
 
43
+ @optional ||= {}
44
+ @optional[:directory] = true
42
45
  setup_config
43
46
 
47
+ if @config[:brick_path]
48
+ brick_path = @config[:brick_path]
49
+ elsif ENV['BRICK_PATH']
50
+ brick_path = ENV['BRICK_PATH']
51
+ else
52
+ brick_path = @config[:directory]
53
+ end
54
+ if brick_path
55
+ @config[:brick_path_list] = parseList(brick_path,':','parsePath')
56
+
57
+ mia = []
58
+ @config[:brick_path_list].each do |path|
59
+ unless File.directory? path
60
+ mia << path
61
+ end
62
+ end
63
+
64
+ if mia.size > 0
65
+ hints = []
66
+ mia.each do |p|
67
+ hints << hint_paths(p,Dir.pwd)
68
+ end
69
+ hints.flatten!
70
+ abort! "Invalid brick path: #{brick_path}! #{mia.size > 1 ? 'These' : 'This'} path#{mia.size > 1 ? 's' : ''} does not exist or cannot be read!\n #{mia.join("\n\t")}
71
+ Did you mean one of these? #{@config[:expandedpaths] ? "(Above #{Dir.pwd})" : ""}
72
+ \t#{hints.join("\n\t")}\n"
73
+ end
74
+ end
75
+
76
+ end
77
+
78
+ def hint_paths(p,pwd,n=0,rel='',f=nil)
79
+ hints = []
80
+ d = p
81
+ until File.directory?(d)
82
+ if d == '.'
83
+ return hints
84
+ end
85
+ d = File.dirname(d)
86
+ end
87
+ unless f
88
+ q = d
89
+ Range.new(1,n).each do
90
+ d = File.dirname(d)
91
+ end
92
+ f = File.basename(p)
93
+ r = pwd.gsub(%r'^#{q}','').split(File::SEPARATOR)
94
+ if r.size > 0
95
+ r = r[1..-1]
96
+ end
97
+ if r.size > 0
98
+ rel = r.map{|_| '..'}.join(File::SEPARATOR)
99
+ end
100
+ pwd = d
101
+ end
102
+ Dir.glob("#{d}/*").each do |path|
103
+ if File.directory?(path)
104
+ if path.match %r'/#{f}'
105
+ hints << File.join(rel,path.gsub(%r'^#{File.dirname(d)}',''))
106
+ else
107
+ hints << hint_paths(path,pwd,n,rel,f)
108
+ end
109
+ end
110
+ end
111
+ hints.flatten
44
112
  end
45
113
 
46
114
  end
@@ -15,7 +15,6 @@ module Aws
15
15
  logStep "Parsing #{section}..."
16
16
 
17
17
  if spec and spec[section]
18
- abort! "No such directory: #{@config[:directory]} (I am here: #{Dir.pwd})" unless File.directory?(@config[:directory])
19
18
  @items ||= {}
20
19
  @items[section] ||= {}
21
20
  get = {}
@@ -28,6 +27,7 @@ module Aws
28
27
  else
29
28
  path = vet_path(sub ? sub : section, refp, rel)
30
29
  end
30
+ abort! "No such directory: #{path} (I am here: #{Dir.pwd})" unless File.directory?(path)
31
31
  unless get[path]
32
32
  get[path] = get_file_set([".*"], path, @config[:precedence])
33
33
  end
@@ -84,10 +84,11 @@ module Aws
84
84
  Aws::Cfn::Compiler.binding ||= {}
85
85
  Aws::Cfn::Compiler.binding[section] ||= {}
86
86
  Aws::Cfn::Compiler.binding[section][base] ||= {
87
- brick_path: @config[:directory],
88
- template: @dsl,
89
- logger: @logger,
90
- compiler: self
87
+ brick_path: @config[:brick_path],
88
+ brick_path_list: @config[:brick_path_list],
89
+ template: @dsl,
90
+ logger: @logger,
91
+ compiler: self
91
92
  }
92
93
  source_file = File.expand_path(filename)
93
94
  begin
@@ -72,7 +72,7 @@ module Aws
72
72
  end
73
73
  @logger.info " saved #{filn}."
74
74
  rescue
75
- abort! "!!! Could not write file #{path}: #{$!}"
75
+ abort! "!!! Could not write file #{path}: \nException: #{$!}\nParent directory exists? #{File.directory?(File.dirname(path))}\n"
76
76
  end
77
77
  else
78
78
  @logger.warn " Did not overwrite #{filn}."
@@ -1,7 +1,7 @@
1
1
  module Aws
2
2
  module Cfn
3
3
  module Compiler
4
- VERSION = '0.8.10'
4
+ VERSION = '0.9.1'
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-cfn-compiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.10
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - PKinney
@@ -92,42 +92,42 @@ dependencies:
92
92
  requirements:
93
93
  - - ! '>='
94
94
  - !ruby/object:Gem::Version
95
- version: 0.8.0
95
+ version: 0.9.0
96
96
  type: :runtime
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - ! '>='
101
101
  - !ruby/object:Gem::Version
102
- version: 0.8.0
102
+ version: 0.9.0
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: dldinternet-mixlib-cli
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - ! '>='
108
108
  - !ruby/object:Gem::Version
109
- version: 0.1.0
109
+ version: 0.2.0
110
110
  type: :runtime
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - ! '>='
115
115
  - !ruby/object:Gem::Version
116
- version: 0.1.0
116
+ version: 0.2.0
117
117
  - !ruby/object:Gem::Dependency
118
118
  name: dldinternet-mixlib-logging
119
119
  requirement: !ruby/object:Gem::Requirement
120
120
  requirements:
121
121
  - - ! '>='
122
122
  - !ruby/object:Gem::Version
123
- version: 0.3.0
123
+ version: 0.4.0
124
124
  type: :runtime
125
125
  prerelease: false
126
126
  version_requirements: !ruby/object:Gem::Requirement
127
127
  requirements:
128
128
  - - ! '>='
129
129
  - !ruby/object:Gem::Version
130
- version: 0.3.0
130
+ version: 0.4.0
131
131
  description: The idea is to create a folder structure to better manage pieces of a
132
132
  CloudFormation deployment. Additionally, writing in JSON is hard, so the compiler
133
133
  takes YAML files as well.