labs-deployer 0.0.4 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/.deployer-example ADDED
@@ -0,0 +1,4 @@
1
+ project_name: tropo/12.0/cookbooks/functional_deployment
2
+ aws_key: 123
3
+ aws_secret: 123
4
+ bucket_name: cookbooks.voxeo.net
data/Gemfile CHANGED
@@ -6,3 +6,4 @@ gemspec
6
6
  gem 'rake'
7
7
  gem 'berkshelf', '= 1.0.0'
8
8
  gem 'thor'
9
+ gem 'mash'
data/README.md CHANGED
@@ -18,13 +18,13 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- Thos task that helps bundle and deploy cookbooks to S3. Expects the following in your knife.rb
21
+ Thos task that helps bundle and deploy cookbooks to S3. Ascends path looking for .deployer file. A local .deployer files attributes will take precedence over one in a higher scope. The contents of this file should contain one or more of the following:
22
22
 
23
23
  ```ruby
24
-
25
- knife[:aws_access_key_id] = "abc123"
26
- knife[:aws_secret_access_key] = "abc123"
27
- knife[:bucket] = 'cookbooks.myserver.com'
24
+ bucket_name: cookbooks.something.com
25
+ aws_key: abc
26
+ aws_secret: 123
27
+ project_name: tropo/12.0/cookbooks/functional_deployment
28
28
  ```
29
29
 
30
30
  ## Contributing
@@ -17,9 +17,10 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
19
 
20
-
21
-
22
- gem.add_dependency('s3')
23
- gem.add_dependency('thor')
20
+ gem.add_dependency('mash')
21
+ gem.add_dependency('json_pure')
22
+ gem.add_dependency('s3')
23
+ gem.add_dependency('thor')
24
+ gem.add_dependency('berkshelf')
24
25
 
25
26
  end
data/lib/labs-deployer.rb CHANGED
@@ -10,15 +10,17 @@ require 'digest/md5'
10
10
  require 'mime/types'
11
11
  require 'berkshelf/cli'
12
12
  require 's3'
13
-
13
+ require 'labs-deployer/config'
14
14
  class Solo < Thor
15
15
 
16
16
  Berkshelf::Config.new
17
17
 
18
+
18
19
  desc "package", "package and deploy a cookbook"
19
20
 
20
21
  def package
21
- get_dependencies
22
+ @config = VoxeoLabs::Config.new(Dir.pwd)
23
+ #get_dependencies
22
24
  pkg = package_files
23
25
  upload_cookbooks(pkg)
24
26
  end
@@ -39,15 +41,15 @@ class Solo < Thor
39
41
 
40
42
  def upload_cookbooks(file)
41
43
  service = S3::Service.new({
42
- :access_key_id => Chef::Config[:knife][:aws_access_key_id],
43
- :secret_access_key => Chef::Config[:knife][:aws_secret_access_key]
44
- })
45
- bucket = service.buckets.find(Chef::Config[:knife][:bucket])
44
+ :access_key_id => @config.aws_key, #Chef::Config[:knife][:aws_access_key_id],
45
+ :secret_access_key => @config.aws_secret #@Chef::Config[:knife][:aws_secret_access_key]
46
+ })
47
+ bucket = service.buckets.find(@config.bucket_name)
46
48
  say "== Uploading cookbook [#{file}]", :green
47
49
 
48
50
  ## Only upload files, we're not interested in directories
49
51
  if File.file?(file)
50
- remote_file = "#{get_cookbook_name}/#{file.split("/")[-1]}"
52
+ remote_file = "#{get_folder_name}/#{file.split("/")[-1]}"
51
53
 
52
54
  begin
53
55
  obj = bucket.objects.find_first(remote_file)
@@ -61,7 +63,7 @@ class Solo < Thor
61
63
  obj = nil
62
64
  end
63
65
 
64
- say "== Uploading #{file}", :green
66
+ say "== Uploading #{file} to #{get_folder_name}", :green
65
67
  obj = bucket.objects.build(remote_file)
66
68
  obj.content = open(file)
67
69
  obj.content_type = MIME::Types.type_for(file).to_s
@@ -75,6 +77,14 @@ class Solo < Thor
75
77
  IO.read(Berkshelf.find_metadata).match(/^version.*/).to_s.split('"')[1]
76
78
  end
77
79
 
80
+ def get_folder_name
81
+ if @config.project_name
82
+ return @config.project_name
83
+ else
84
+ get_cookbook_name
85
+ end
86
+ end
87
+
78
88
  def get_cookbook_name
79
89
  name = IO.read(Berkshelf.find_metadata).match(/^name.*/).to_s.split('"')[1]
80
90
  if name.nil?
@@ -0,0 +1,45 @@
1
+ module VoxeoLabs
2
+ class Config
3
+ require 'pathname'
4
+ require 'yaml'
5
+
6
+ attr_reader :bucket_name, :aws_secret, :aws_key, :project_name
7
+
8
+ def initialize(path)
9
+ file_name=".deployer"
10
+
11
+ Pathname.new(path).ascend do |dir|
12
+ config_file = dir + file_name
13
+ if dir.children.include?(config_file)
14
+ merge_config(YAML::load_file(config_file))
15
+ end
16
+ end
17
+
18
+ end
19
+
20
+ private
21
+
22
+ def merge_config(config)
23
+
24
+ if config['bucket_name']
25
+ @bucket_name = config['bucket_name'] unless @bucket_name
26
+ end
27
+
28
+ if config['aws_secret']
29
+ @aws_secret = config['aws_secret'] unless @aws_secret
30
+ end
31
+
32
+ if config['aws_key']
33
+ @aws_key = config['aws_key'] unless @aws_key
34
+ end
35
+
36
+ if config['project_name']
37
+ @project_name = config['project_name'] unless @project_name
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+ end
44
+
45
+
@@ -1,5 +1,5 @@
1
1
  module Labs
2
2
  module Deployer
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.7"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: labs-deployer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,40 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-28 00:00:00.000000000 Z
12
+ date: 2012-12-12 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: mash
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: json_pure
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
14
46
  - !ruby/object:Gem::Dependency
15
47
  name: s3
16
48
  requirement: !ruby/object:Gem::Requirement
@@ -43,6 +75,22 @@ dependencies:
43
75
  - - ! '>='
44
76
  - !ruby/object:Gem::Version
45
77
  version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: berkshelf
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
46
94
  description: Thor tasks to package chef solo cookbooks
47
95
  email:
48
96
  - johntdyer@gmail.com
@@ -50,6 +98,7 @@ executables: []
50
98
  extensions: []
51
99
  extra_rdoc_files: []
52
100
  files:
101
+ - .deployer-example
53
102
  - .gitignore
54
103
  - Gemfile
55
104
  - LICENSE.txt
@@ -57,6 +106,7 @@ files:
57
106
  - Rakefile
58
107
  - labs-deployer.gemspec
59
108
  - lib/labs-deployer.rb
109
+ - lib/labs-deployer/config.rb
60
110
  - lib/labs-deployer/version.rb
61
111
  homepage: ''
62
112
  licenses: []
@@ -72,7 +122,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
72
122
  version: '0'
73
123
  segments:
74
124
  - 0
75
- hash: -2226089765112800771
125
+ hash: -3720495764964049352
76
126
  required_rubygems_version: !ruby/object:Gem::Requirement
77
127
  none: false
78
128
  requirements:
@@ -81,10 +131,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
131
  version: '0'
82
132
  segments:
83
133
  - 0
84
- hash: -2226089765112800771
134
+ hash: -3720495764964049352
85
135
  requirements: []
86
136
  rubyforge_project:
87
- rubygems_version: 1.8.24
137
+ rubygems_version: 1.8.23
88
138
  signing_key:
89
139
  specification_version: 3
90
140
  summary: Deployed cookbooks to s3