clc-promote 0.2.0 → 0.2.1

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: e687f6bcfc1d904507cbee41f0191181eed28273
4
- data.tar.gz: 6476cbbfc08c6554abd65bf594c18f50e8ff2a68
3
+ metadata.gz: b0cd6b4f5ccdee96517ba9b01436fabe5c5fe77a
4
+ data.tar.gz: c5a8e1d7fe576d91d907d06564e9624df5e8d0d3
5
5
  SHA512:
6
- metadata.gz: b205d382415d921d2e297084516662ca2a6ab790dfdc815fbc801ad181ee0c406d61052d0e7210c8b36586305e131ee38456c84500b4983ea324f3259ab62686
7
- data.tar.gz: 95b580aa5bc01e973620428dcda740369b91eee832a1d016d1ceb52e8c27dd91d111a4a31058b37a630f10f65e8f697e60252426ab364ede0a4eafc031c5229a
6
+ metadata.gz: f6489be22cbf85bb0d4716c18663e5df0f43d77dbe21022499e760e10da5ac2f7563bc812161f326954e7d6585e7189245fc754ba3f2dc67d56bd337ce214fba
7
+ data.tar.gz: 510034cdb259d038aae9afa214665318bbf9264aeb1191d242722bacd0ab35177556699ded8e7c86ec8d0635fd87d6bdf0bc0c717a784ebfccbb59dcbd9d666e
@@ -126,8 +126,8 @@ module Promote
126
126
  namespace "Promote" do
127
127
  desc "Upload an environment to the chef server"
128
128
  task "upload_environment", :environment do |task, args|
129
- puts "Uploading environment..."
130
- @uploader.upload_environment(args.environment)
129
+ file_uploaded = @uploader.upload_environment(args.environment)
130
+ puts "Uploading #{file_uploaded} to #{@uploader.config.chef_server_url} as #{@uploader.config.node_name} using #{@uploader.config.client_key}"
131
131
  end
132
132
  end
133
133
  end
@@ -135,9 +135,9 @@ module Promote
135
135
  def define_upload_data_bags
136
136
  namespace "Promote" do
137
137
  desc "Upload data_bags to the chef server"
138
- task "upload_data_bags" do |task, args|
139
- puts "Uploading data_bags..."
140
- @uploader.upload_data_bags
138
+ task "upload_data_bags" do
139
+ file_uploaded = @uploader.upload_data_bags
140
+ puts "Uploading #{file_uploaded} to #{@uploader.config.chef_server_url} as #{@uploader.config.node_name} using #{@uploader.config.client_key}"
141
141
  end
142
142
  end
143
143
  end
@@ -1,5 +1,4 @@
1
1
  require 'chef'
2
- require 'chef/chef_fs/knife'
3
2
  require 'chef/chef_fs/parallelizer'
4
3
  require 'chef/chef_fs/config'
5
4
  require 'chef/chef_fs/file_pattern'
@@ -7,7 +6,6 @@ require 'chef/chef_fs/file_system'
7
6
  require 'chef/config'
8
7
  require 'chef/knife/cookbook_upload'
9
8
  require 'chef/chef_fs/path_utils'
10
- require 'chef/knife/upload'
11
9
 
12
10
  module Promote
13
11
  class Uploader
@@ -18,6 +16,7 @@ module Promote
18
16
  Chef::Config[:client_key] = config.client_key
19
17
  Chef::Config[:chef_server_url] = config.chef_server_url
20
18
  Chef::Config[:node_name] = config.node_name
19
+ Chef::Config[:chef_repo_path] = config.repo_root
21
20
  end
22
21
 
23
22
  def upload_cookbooks
@@ -54,27 +53,24 @@ module Promote
54
53
  end
55
54
 
56
55
  def upload_environment(environment_name)
57
- knife = Chef::Knife::Upload.new(["/environments/#{environment_name}.json"])
58
- knife.config[:chef_repo_path] = config.repo_root
59
- Chef::ChefFS::Knife.deps do
60
- knife.configure_chef
61
- knife.run
62
- end
56
+ upload_file("/environments/#{environment_name}.json")
63
57
  end
64
58
 
65
59
  def upload_data_bags
66
- knife = Chef::Knife::Upload.new(["/data_bags"])
67
- knife.config[:chef_repo_path] = config.repo_root
68
- Chef::ChefFS::Knife.deps do
69
- knife.configure_chef
70
- knife.run
71
- end
60
+ upload_file("/data_bags")
72
61
  end
73
62
 
74
63
  attr_accessor :config
75
64
 
76
65
  private
77
66
 
67
+ def upload_file(file_path)
68
+ fs_config = Chef::ChefFS::Config.new
69
+ pattern = Chef::ChefFS::FilePattern.new(Chef::ChefFS::PathUtils::join(fs_config.base_path, file_path))
70
+ Chef::ChefFS::FileSystem.copy_to(pattern, fs_config.local_fs, fs_config.chef_fs, 1, Chef::Config)
71
+ file_path
72
+ end
73
+
78
74
  def validate_config
79
75
  required_keys = [:client_key, :chef_server_url, :node_name]
80
76
  missing_keys = []
@@ -99,7 +99,6 @@ 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}"
103
102
  File.open(env_file, 'w') do |out|
104
103
  out << JSON.pretty_generate(content)
105
104
  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.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - CenturyLink Cloud