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 +4 -4
- data/lib/promote/rake_tasks.rb +12 -2
- data/lib/promote/versioner.rb +31 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e687f6bcfc1d904507cbee41f0191181eed28273
|
4
|
+
data.tar.gz: 6476cbbfc08c6554abd65bf594c18f50e8ff2a68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b205d382415d921d2e297084516662ca2a6ab790dfdc815fbc801ad181ee0c406d61052d0e7210c8b36586305e131ee38456c84500b4983ea324f3259ab62686
|
7
|
+
data.tar.gz: 95b580aa5bc01e973620428dcda740369b91eee832a1d016d1ceb52e8c27dd91d111a4a31058b37a630f10f65e8f697e60252426ab364ede0a4eafc031c5229a
|
data/lib/promote/rake_tasks.rb
CHANGED
@@ -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
|
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"
|
data/lib/promote/versioner.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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
|
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:
|
136
|
+
version: '0'
|
137
137
|
requirements: []
|
138
138
|
rubyforge_project:
|
139
139
|
rubygems_version: 2.2.1
|