clc-promote 0.2.0.pre → 0.2.0

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: 24e8944f0082aa895bf69fff09a1016943e6b212
4
- data.tar.gz: c5e93da8c48ae3507e421ddd4a1185d4bdba2b31
3
+ metadata.gz: e687f6bcfc1d904507cbee41f0191181eed28273
4
+ data.tar.gz: 6476cbbfc08c6554abd65bf594c18f50e8ff2a68
5
5
  SHA512:
6
- metadata.gz: cfe6919ce0b01abdb44b7cfb777b3e5ad5fa5108295e44c38a5d183220be94d7548348e5e728686fd015ae779a7abc341aa4edb768da06b50d16ea0e014f0fc5
7
- data.tar.gz: 833b9efee560ff24642a3d624638a799e31cb83a5f91ea1c3dffd43bf074f6a9d05545c5e718fd32e3adb7113abc51d2ace8f4aac03c74b8a941111c0d75d702
6
+ metadata.gz: b205d382415d921d2e297084516662ca2a6ab790dfdc815fbc801ad181ee0c406d61052d0e7210c8b36586305e131ee38456c84500b4983ea324f3259ab62686
7
+ data.tar.gz: 95b580aa5bc01e973620428dcda740369b91eee832a1d016d1ceb52e8c27dd91d111a4a31058b37a630f10f65e8f697e60252426ab364ede0a4eafc031c5229a
@@ -17,6 +17,7 @@ module Promote
17
17
  define_version_environments
18
18
  define_version_data_bag
19
19
  define_version_data_bags
20
+ define_sync_berksfiles
20
21
  define_upload_cookbooks
21
22
  define_upload_environment
22
23
  define_upload_data_bags
@@ -25,7 +26,6 @@ module Promote
25
26
 
26
27
  private
27
28
 
28
-
29
29
  def define_version_cookbook
30
30
  namespace "Promote" do
31
31
  desc "Version a cookbook"
@@ -39,7 +39,7 @@ module Promote
39
39
  namespace "Promote" do
40
40
  desc "Version all cookbooks"
41
41
  task "version_cookbooks" do
42
- puts "Version stamping cookbooks and syncing berksfile.locks..."
42
+ puts "Version stamping cookbooks..."
43
43
  @versioner.version_cookbooks.each do |result|
44
44
  puts "Versioned cookbook: #{result[:cookbook]} v#{result[:version]}"
45
45
  end
@@ -47,6 +47,16 @@ module Promote
47
47
  end
48
48
  end
49
49
 
50
+ def define_sync_berksfiles
51
+ namespace "Promote" do
52
+ desc "Syncs all Berksfile.lock files"
53
+ task "sync_berksfiles" do
54
+ puts "Syncing berksfile.locks..."
55
+ @versioner.sync_berksfiles
56
+ end
57
+ end
58
+ end
59
+
50
60
  def define_version_environment
51
61
  namespace "Promote" do
52
62
  desc "Version an environment"
@@ -35,16 +35,19 @@ module Promote
35
35
  end
36
36
 
37
37
  def version_cookbooks
38
- cookbooks = Dir.glob(File.join(config.cookbook_directory, "*"))
39
38
  results = []
40
- cookbooks.each do |file|
39
+ repo_cookbooks.each do |file|
41
40
  cookbook = File.basename(file)
42
41
  result = version_cookbook(cookbook)
43
42
  if !result.nil?
44
43
  results << result
45
44
  end
46
45
  end
47
- cookbooks.each do |cookbook|
46
+ results
47
+ end
48
+
49
+ def sync_berksfiles
50
+ repo_cookbooks.each do |cookbook|
48
51
  berks_name = File.join(config.cookbook_directory, File.basename(cookbook), "Berksfile")
49
52
  if File.exist?(berks_name)
50
53
  Berkshelf.set_format :null
@@ -52,7 +55,6 @@ module Promote
52
55
  berksfile.install
53
56
  end
54
57
  end
55
- results
56
58
  end
57
59
 
58
60
  def version_data_bag(data_bag_path)
@@ -89,9 +91,7 @@ module Promote
89
91
  end
90
92
 
91
93
  def constrain_environment(environment_name, cookbook_name)
92
- berks_name = File.join(config.cookbook_directory, cookbook_name, "Berksfile")
93
- berksfile = Berkshelf::Berksfile.from_file(berks_name)
94
- dependencies = berksfile.list
94
+ dependencies = environment_dependencies(cookbook_name)
95
95
  env_file = File.join(config.environment_directory, "#{environment_name}.json")
96
96
  content = JSON.parse(File.read(env_file))
97
97
  content['cookbook_versions'] = {}
@@ -99,16 +99,40 @@ module Promote
99
99
  content['cookbook_versions'][dep.name] = dep.locked_version.to_s
100
100
  end
101
101
 
102
+ puts "opening #{env_file} and writing #{content}"
102
103
  File.open(env_file, 'w') do |out|
103
104
  out << JSON.pretty_generate(content)
104
105
  end
105
106
  dependencies
106
107
  end
107
108
 
109
+ def is_dirty(environment_name, cookbook_name, environment_cookbook)
110
+ dependencies = environment_dependencies(environment_cookbook)
111
+ cb_dependency = (dependencies.select { |dep| dep.name == cookbook_name })[0]
112
+
113
+ env_file = File.join(config.environment_directory, "#{environment_name}.json")
114
+ content = JSON.parse(File.read(env_file))
115
+ if content.has_key?('cookbook_versions') && content['cookbook_versions'].has_key?(cookbook_name)
116
+ return cb_dependency.locked_version.to_s != content['cookbook_versions'][cookbook_name]
117
+ else
118
+ return true
119
+ end
120
+ end
121
+
108
122
  attr_accessor :config
109
123
 
110
124
  private
111
125
 
126
+ def environment_dependencies(cookbook_name)
127
+ berks_name = File.join(config.cookbook_directory, cookbook_name, "Berksfile")
128
+ berksfile = Berkshelf::Berksfile.from_file(berks_name)
129
+ berksfile.list
130
+ end
131
+
132
+ def repo_cookbooks
133
+ Dir.glob(File.join(config.cookbook_directory, "*"))
134
+ end
135
+
112
136
  def version_json(parent_directory, file_name, &block)
113
137
  version_string = "version"
114
138
  file = "#{parent_directory}/#{file_name}.json"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clc-promote
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.pre
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - CenturyLink Cloud
@@ -131,9 +131,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
131
131
  version: '0'
132
132
  required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  requirements:
134
- - - ">"
134
+ - - ">="
135
135
  - !ruby/object:Gem::Version
136
- version: 1.3.1
136
+ version: '0'
137
137
  requirements: []
138
138
  rubyforge_project:
139
139
  rubygems_version: 2.2.1