cocina 0.2.0 → 0.2.2

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: 8877bc986582498901f7827f0c64844ddaa727ad
4
- data.tar.gz: 5f4bce67c538c8bddf0c5e8b826c4c29e092ac80
3
+ metadata.gz: f40fd78e9dae58f0388b9b0993946090d78fb8af
4
+ data.tar.gz: bc60df50ce81f0e0fba66ab3e933c5db3b5e4417
5
5
  SHA512:
6
- metadata.gz: e6c74d4072c1f47591719a6e16cb348d10c60159d44d7b7abfb1ef2937e781483b32056861b79317ba49a5f5926e817e2ea8c6b3cf98cd959e85bbdc04d9a7d5
7
- data.tar.gz: 8f9718ae491e62c0153df3831e1dd1e87599dd3b9ec6b4ebafacc690dff3a809c8fffa213f0fab7d8898995d0448d2ff168c91df21f11467ff04a7f1f4abdef6
6
+ metadata.gz: 83bbfd7ca76d2f7102831c8f1f2f0f9a08489bef17173f824f324b4d25f8a29d6420f64103f517f59b26c8fd7de28fa0edc53a5eae125cae59955c8695139d2a
7
+ data.tar.gz: 100706d0df4bf3389a355cdb1157af164d3317781c70568bb9d62d1262a43864544653b8b8223fb43da768f5ae30c4cffc83038cf0104bd2cd18722793d3699d
@@ -1,9 +1,14 @@
1
+ with_kitchen_yaml '.kitchen.yml'
2
+ log_level :info
3
+
1
4
  instance 'web-ubuntu-1404' do
2
5
  depends 'app-ubuntu-1404'
3
6
  actions :converge, :converge, :verify
7
+ cleanup true
4
8
  end
5
9
 
6
10
  instance 'app-ubuntu-1404' do
7
11
  depends 'db-ubuntu-1404'
8
12
  actions :converge, :converge, :verify
13
+ cleanup true
9
14
  end
@@ -23,12 +23,10 @@ module Cocina
23
23
 
24
24
  def run
25
25
  log_banner "Running for: #{primary_instance.name}"
26
-
27
26
  prepare_dependencies
28
27
  converge_dependencies
29
-
30
28
  primary_instance.run_actions
31
- cleanup
29
+ cleanup if primary_instance.cleanup?
32
30
  end
33
31
 
34
32
  def instance(id)
@@ -8,29 +8,44 @@ module Cocina
8
8
  def initialize(file)
9
9
  @cocinafile = file
10
10
  @instances = []
11
+ @log_level = :info
11
12
 
12
13
  $stdout.sync = true
13
14
 
15
+ load_cocinafile
16
+ load_kitchen_config
17
+ build_dependencies
18
+ end
19
+
20
+ def load_cocinafile
21
+ self.instance_eval(IO.read(cocinafile), cocinafile, 1)
22
+ end
23
+
24
+ def load_kitchen_config
14
25
  @loader = Kitchen::Loader::YAML.new(
15
- project_config: ENV["KITCHEN_YAML"],
26
+ project_config: project_kitchen_yaml,
16
27
  local_config: ENV["KITCHEN_LOCAL_YAML"],
17
28
  global_config: ENV["KITCHEN_GLOBAL_YAML"]
18
29
  )
19
30
  @config = Kitchen::Config.new(
20
31
  loader: @loader
21
32
  )
22
- @config.log_level =
23
- Kitchen.env_log unless Kitchen.env_log.nil?
33
+ @config.log_level = log_level
24
34
  @config.log_overwrite =
25
35
  Kitchen.env_log_overwrite unless Kitchen.env_log_overwrite.nil?
36
+ end
26
37
 
27
- load_cocinafile
38
+ def log_level(level=nil)
39
+ return @log_level if level.nil?
40
+ @log_level = level
41
+ end
28
42
 
29
- build_dependencies
43
+ def with_kitchen_yaml(file)
44
+ @project_kitchen_yaml = file
30
45
  end
31
46
 
32
- def load_cocinafile
33
- self.instance_eval(IO.read(cocinafile), cocinafile, 1)
47
+ def project_kitchen_yaml
48
+ @project_kitchen_yaml ||= ENV["KITCHEN_YAML"]
34
49
  end
35
50
 
36
51
  def kitchen_instance(target)
@@ -41,13 +56,13 @@ module Cocina
41
56
  return true if instance?(id)
42
57
  cocina_instance = Cocina::Instance.new(id)
43
58
  cocina_instance.instance_eval(&block)
44
- cocina_instance.runner = kitchen_instance(id)
45
59
  @instances << cocina_instance
46
60
  nil
47
61
  end
48
62
 
49
63
  def build_dependencies
50
64
  instances.each do |machine|
65
+ machine.runner = kitchen_instance(machine.name)
51
66
  machine.dependencies.each do |id|
52
67
  next if instance?(id)
53
68
  dep = Cocina::Instance.new(id)
@@ -14,6 +14,7 @@ module Cocina
14
14
  @name = name
15
15
  @dependencies = []
16
16
  @actions = default_actions
17
+ @cleanup = false
17
18
  end
18
19
 
19
20
  # Define a dependency for the Instance
@@ -22,6 +23,18 @@ module Cocina
22
23
  @dependencies << dep
23
24
  end
24
25
 
26
+ # Perform a cleanup of all instances after all actions have been performed
27
+ #
28
+ def cleanup(switch=nil)
29
+ @cleanup = switch
30
+ end
31
+
32
+ # Check if we want to perform cleanup for this instance
33
+ #
34
+ def cleanup?
35
+ @cleanup
36
+ end
37
+
25
38
  # Check if the Instance has any defined dependencies
26
39
  #
27
40
  def dependencies?
@@ -1,3 +1,3 @@
1
1
  module Cocina
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocina
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Raabe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-30 00:00:00.000000000 Z
11
+ date: 2016-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler