yutani 0.1.12 → 0.1.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a8429b5ebef83eb6a439a01fb542973221d0386
4
- data.tar.gz: 49d5ea9b1161aacc544489bca25d8e6b07c93c60
3
+ metadata.gz: 483c5e58654c42e69d8e7e788857ce69fd1b7e86
4
+ data.tar.gz: b54ada05a35257c53244c48c8de8875e177ecc57
5
5
  SHA512:
6
- metadata.gz: 4a3c7679596ea8d4602586701ac439e84c4cbf0bb92dc475fbc6817bf194c70ef1b632705e6153c434dd53810bc813c88fbd1b5a1c71aa272f74c98a9d7c7cd9
7
- data.tar.gz: 305d1813cc2929ecda7dcd3ddb71dbff4433337dddd9ac36241cf41cecd37b7994efe9eb689462723f66993f4995be2ad9ab3f8b47cc6d2711ac85897853bc99
6
+ metadata.gz: 68fe75b176ce425ec09c835c5156e040b46f5b3ef36f1f34d6c810af6f3ba5055da50902acdc6aafefe8246b9183352164f8f86594a3b6a8f2e4e350c2b0b931
7
+ data.tar.gz: dc0b8699b5b7269b02e6c5bee8673d667315394171f38b267ae0acc821d82ff51266aee34481bad849390b889a0bfad0ad75f5b7e55925c69d8c486a7a7034cb
data/lib/yutani/cli.rb CHANGED
@@ -44,7 +44,11 @@ module Yutani
44
44
  # * the glob - this is hardcoded to *.rb
45
45
  desc 'watch', 'Run build upon changes to scripts'
46
46
  def watch
47
- Listen.to(Yutani::Config::DEFAULTS['scripts_dir']) do |m, a, d|
47
+ Listen.to(
48
+ Yutani::Config::DEFAULTS['scripts_dir'],
49
+ Yutani::Config::DEFAULTS['includes_dir']
50
+ ) do |m, a, d|
51
+
48
52
  Yutani.logger.info "Re-build triggered: #{m} modified" unless m.empty?
49
53
  Yutani.logger.info "Re-build triggered: #{a} added" unless a.empty?
50
54
  Yutani.logger.info "Re-build triggered: #{d} deleted" unless d.empty?
data/lib/yutani/config.rb CHANGED
@@ -6,6 +6,7 @@ module Yutani
6
6
  DEFAULTS = Config[{
7
7
  "scripts_dir" => "scripts",
8
8
  "includes_dir" => "includes",
9
+ "templates_dir" => "templates",
9
10
  "terraform_dir" => "terraform",
10
11
  "hiera_config" => {
11
12
  :backends => ["yaml"],
data/lib/yutani/hiera.rb CHANGED
@@ -9,6 +9,10 @@ module Yutani
9
9
 
10
10
  @scopes = []
11
11
 
12
+ def hiera(k)
13
+ Hiera.lookup(k)
14
+ end
15
+
12
16
  class << self
13
17
  attr_accessor :hiera, :scopes
14
18
 
@@ -1,5 +1,7 @@
1
1
  module Yutani
2
- class Provider < DSLEntity
2
+ class Provider
3
+ include Hiera
4
+
3
5
  attr_accessor :provider_name, :fields
4
6
 
5
7
  def initialize(provider_name, **scope, &block)
@@ -26,7 +28,7 @@ module Yutani
26
28
 
27
29
  def method_missing(name, *args, &block)
28
30
  if block_given?
29
- raise StandardError,
31
+ raise StandardError,
30
32
  "provider properties do not accept blocks as parameters"
31
33
  else
32
34
  @fields[name] = args.first
@@ -1,5 +1,7 @@
1
1
  module Yutani
2
- class Resource < DSLEntity
2
+ class Resource
3
+ include Hiera
4
+
3
5
  attr_accessor :resource_type, :namespace, :fields
4
6
 
5
7
  def initialize(resource_type, *namespace, &block)
@@ -26,6 +28,10 @@ module Yutani
26
28
  "${%s}" % [resource_type, namespace.join('_'), attr].join('.')
27
29
  end
28
30
 
31
+ def template(path, **kv)
32
+ Template.new(kv).render(path)
33
+ end
34
+
29
35
  def respond_to_missing?(method_name, include_private = false)
30
36
  true
31
37
  end
@@ -45,7 +51,7 @@ module Yutani
45
51
  end
46
52
  end
47
53
 
48
- class SubResource < Resource
54
+ class SubResource < Resource
49
55
  def initialize
50
56
  @fields = {}
51
57
  end
data/lib/yutani/stack.rb CHANGED
@@ -1,7 +1,9 @@
1
1
  require 'json'
2
2
 
3
3
  module Yutani
4
- class Stack < DSLEntity
4
+ class Stack
5
+ include Hiera
6
+
5
7
  attr_accessor :resources, :providers, :outputs, :variables
6
8
 
7
9
  def initialize(*namespace, &block)
@@ -0,0 +1,27 @@
1
+ require 'erb'
2
+
3
+ module Yutani
4
+ class TemplateNotFoundError < StandardError; end
5
+
6
+ # an openstruct is useful because it lets us take a hash
7
+ # and turn its k/v's into local variables inside the tmpl
8
+ class Template < OpenStruct
9
+ include Hiera
10
+
11
+ class << self
12
+ def templates_path
13
+ Yutani.config['templates_dir']
14
+ end
15
+ end
16
+
17
+ def render(path)
18
+ full_path = File.join(Template.templates_path, path)
19
+
20
+ unless File.exists?(full_path)
21
+ raise TemplateNotFoundError, full_path
22
+ end
23
+
24
+ ERB.new(File.read(full_path)).result binding
25
+ end
26
+ end
27
+ end
@@ -1,3 +1,3 @@
1
1
  module Yutani
2
- VERSION = '0.1.12'
2
+ VERSION = '0.1.15'
3
3
  end
data/lib/yutani.rb CHANGED
@@ -7,11 +7,11 @@ require 'yutani/version'
7
7
  require 'yutani/config'
8
8
  require 'yutani/hiera'
9
9
  require 'yutani/cli'
10
- require 'yutani/dsl_entity'
11
10
  require 'yutani/directory_tree'
12
11
  require 'yutani/stack'
13
12
  require 'yutani/resource'
14
13
  require 'yutani/provider'
14
+ require 'yutani/template'
15
15
  require 'yutani/utils'
16
16
 
17
17
  module Yutani
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yutani
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Louis Garman
@@ -173,11 +173,11 @@ files:
173
173
  - lib/yutani/cli.rb
174
174
  - lib/yutani/config.rb
175
175
  - lib/yutani/directory_tree.rb
176
- - lib/yutani/dsl_entity.rb
177
176
  - lib/yutani/hiera.rb
178
177
  - lib/yutani/provider.rb
179
178
  - lib/yutani/resource.rb
180
179
  - lib/yutani/stack.rb
180
+ - lib/yutani/template.rb
181
181
  - lib/yutani/utils.rb
182
182
  - lib/yutani/version.rb
183
183
  homepage: https://github.com/leg100/yutani
@@ -1,7 +0,0 @@
1
- module Yutani
2
- class DSLEntity
3
- def hiera(k)
4
- Yutani::Hiera.lookup(k)
5
- end
6
- end
7
- end