clc-promote 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/promote/uploader.rb +12 -17
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d1648dc80e86e5091475fbfd5a3f37af2d205650
4
- data.tar.gz: 517af2fb1dfc639eb0c7ee913b06203b8e54f10d
3
+ metadata.gz: 602f553a778d7101ac52edf230810a29cf238235
4
+ data.tar.gz: 99b38236925df3acc02278aeb5ca17f4b958e55e
5
5
  SHA512:
6
- metadata.gz: f3707c1103ab6bab1a1e1e5279af57858274073a16b4240212b9ebc2ba611369505785fd2b3d547afa683d5091888dd811b8d6fbba4088946ef2353f8291436b
7
- data.tar.gz: 044f7283e1ba7275c6f29ee1a0d5a77897741d0b9fff09486398af22e33ca35484b65d6afd8d2200c29c6886abaf7e84e18a9cc116a746030e6fb7fdd73e4c10
6
+ metadata.gz: 2502cd2f02475e4db17af01f4ce40a52b00235424e543ffeaaaac815fd5fe3072b5ffaea9bed3dd8ca034073e41e10a8acfcf4ecd28f27398513b76dc9c5320a
7
+ data.tar.gz: f52ef0d6e040118f95e4a8025d61af02c0df6320058173516ce7d56d2807ebf93d1fd5d57cb5bdac61df001d05139235b93f1a70f4da8b87a9a295e3a533d483
@@ -24,23 +24,16 @@ module Promote
24
24
 
25
25
  def upload_cookbooks(environment)
26
26
  anything_to_upload = false
27
+
27
28
  server_cookbooks = Utils.chef_server_cookbooks(config)
29
+ env_versions = EnvironmentFile.new(environment, config).cookbook_versions
30
+
28
31
  FileUtils.rm_rf(config.temp_directory) if Dir.exist?(config.temp_directory)
29
32
  Dir.mkdir(config.temp_directory)
30
33
 
31
- env_versions = EnvironmentFile.new(environment, config).cookbook_versions
32
- Dir.glob(File.expand_path("~/.berkshelf/cookbooks/*")).each do | dir |
33
- cp_name = File.basename(dir)
34
- idx = cp_name.rindex('-')
35
- cb_name = cp_name[0,idx]
36
- cb_version = cp_name[idx+1,cp_name.length-idx]
37
- anything_to_upload = cookbooks_copied?(cb_name, cb_version, dir, server_cookbooks, env_versions)
38
- end
39
-
40
- Dir.glob(File.join(config.cookbook_directory, "*")).each do | dir |
41
- metadata = Chef::Cookbook::Metadata.new
42
- metadata.from_file(File.join(dir, "metadata.rb"))
43
- anything_to_upload = cookbooks_copied?(metadata.name, metadata.version, dir, server_cookbooks, env_versions) || anything_to_upload
34
+ (Dir.glob(File.expand_path("~/.berkshelf/cookbooks/*")) <<
35
+ Dir.glob(File.join(config.cookbook_directory, "*"))).flatten!.each do | dir |
36
+ anything_to_upload = cookbooks_copied?(dir, server_cookbooks, env_versions) || anything_to_upload
44
37
  end
45
38
 
46
39
  if anything_to_upload
@@ -71,10 +64,12 @@ module Promote
71
64
  private
72
65
 
73
66
  #only include versions in environment but exclude whats on the server
74
- def cookbooks_copied?(name, version, dir, server_cookbooks, environment_cookbooks)
75
- if !server_cookbooks.has_key?(name) || (server_cookbooks[name]["versions"].select {|v| v['version'] == version}).empty?
76
- if environment_cookbooks.has_key?(name) && environment_cookbooks[name] == version
77
- FileUtils.copy_entry(dir, File.join(config.temp_directory, name))
67
+ def cookbooks_copied?(dir, server_cookbooks, environment_cookbooks)
68
+ metadata = Chef::Cookbook::Metadata.new
69
+ metadata.from_file(File.join(dir, "metadata.rb"))
70
+ if !server_cookbooks.has_key?(metadata.name) || (server_cookbooks[metadata.name]["versions"].select {|v| v['version'] == metadata.version}).empty?
71
+ if environment_cookbooks.has_key?(metadata.name) && environment_cookbooks[metadata.name] == metadata.version
72
+ FileUtils.copy_entry(dir, File.join(config.temp_directory, metadata.name))
78
73
  true
79
74
  end
80
75
  end
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.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - CenturyLink Cloud