berktacular 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eeb6b4f68edec2f117fac5fe278528a608a147e7
4
- data.tar.gz: bfac47d7cf35f86f56eb4d424b55f7b5684d85c7
3
+ metadata.gz: f7726b1582a4399d6a82bc73d9d9753b0e8d3943
4
+ data.tar.gz: cd4f5d8b9fa377f6deecffeb9d39b01435f76dbe
5
5
  SHA512:
6
- metadata.gz: 067c4df6bf09bfc3891017c04c77b737a290cb28e1c435e0f4e79706b8d61c113bcb45536f387747a9aea951f82cabd0f77a727898fe09ca0a549d703e2c2336
7
- data.tar.gz: 54674b306779da178c450f63783a60012d66e23fd57bc16b8c91868e79c29e3889fa38246bd47282de66c8b1fbb58871e1f3846ee5cda5454bccf245561a3b3a
6
+ metadata.gz: 9410e6368a66220dd90f2464d5b1387085034e419fbb102a05d8fb7f4340fe877ef8b0fa7dabbc0aeb6019208ca4863cde123a06b4df6b7163320b5b90b59bd4
7
+ data.tar.gz: 34893ffc90c76f9cd47980da97659bdb7c7a4a3f83d8c3e5304b6cc4ae47e58eae0c37e93eaf23f90d0e82d658e66bed8860e224a28c6c252dd70f8fab913ae6
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.1.0
data/bin/berktacular CHANGED
@@ -21,6 +21,7 @@ workdir = nil
21
21
  verbose = false
22
22
  source_list = []
23
23
  versions_only = false
24
+ multi_cookbook_dir = nil
24
25
 
25
26
  options = OptionParser.new do |opts|
26
27
  opts.banner = "Read environment json file and spit out a berksfile"
@@ -68,6 +69,13 @@ options = OptionParser.new do |opts|
68
69
  workdir = w
69
70
  preserve = true
70
71
  end
72
+ opts.on("-m PATH", "--multi-cookbook-dir PATH", String,
73
+ "Treat the given directory as a multi-cookbook directory, and allow referring to cookbooks " \
74
+ "under this directory when the 'rel' configuration parameter is specified and the version " \
75
+ "matches. This helps test pull requests that introduce a new cookbook version and " \
76
+ "update an environment file to point to that version at the same time.") do |m|
77
+ multi_cookbook_dir = m
78
+ end
71
79
  opts.on("-s", "--source SOURCE", String,
72
80
  "Add this source to the generated Berksfile in addition to the default source",
73
81
  "(https://api.berkshelf.com). This may be e.g. an internal Berkshelf API server URL.",
@@ -141,6 +149,12 @@ if upload
141
149
  end
142
150
  end
143
151
 
152
+ if multi_cookbook_dir && !Dir.exists?(multi_cookbook_dir)
153
+ warn "The multi-cookbook directory not found at '#{multi_cookbook_dir}'"
154
+ warn options
155
+ exit 6
156
+ end
157
+
144
158
  # We have to set our work dir now or berktacular will give us a new one each time we pass in nil.
145
159
  workdir = Berktacular.best_temp_dir unless workdir
146
160
  puts "Using workdir: '#{workdir}'" if verbose
@@ -152,7 +166,8 @@ b = Berktacular::Berksfile.new(
152
166
  upgrade: upgrade,
153
167
  github_token: github_token,
154
168
  verbose: verbose,
155
- source_list: source_list
169
+ source_list: source_list,
170
+ multi_cookbook_dir: multi_cookbook_dir
156
171
  )
157
172
  b.check_updates if check
158
173
  puts "#{b}" if printit
@@ -35,7 +35,8 @@ module Berktacular
35
35
  :upgrade => opts.has_key?(:upgrade) ? opts[:upgrade] : false,
36
36
  :github_token => opts.has_key?(:github_token) ? opts[:github_token] : nil,
37
37
  :verbose => opts.has_key?(:verbose) ? opts[:verbose] : false,
38
- :source_list => opts.has_key?(:source_list) ? opts[:source_list] : []
38
+ :source_list => opts.has_key?(:source_list) ? opts[:source_list] : [],
39
+ :multi_cookbook_dir => opts.has_key?(:multi_cookbook_dir) ? opts[:multi_cookbook_dir] : nil
39
40
  }
40
41
  @installed = {}
41
42
  # only connect once, pass the client to each cookbook. and only if needed
@@ -194,7 +195,7 @@ module Berktacular
194
195
  # @return [Array] a list of Cookbook objects for this environment.
195
196
  def cookbooks
196
197
  @cookbooks ||= @cookbook_versions.sort.map do |book, version|
197
- Cookbook.new(book, version, @cookbook_locations[book], @opts )
198
+ Cookbook.new(book, version, @cookbook_locations[book], @opts)
198
199
  end
199
200
  end
200
201
 
@@ -204,9 +205,9 @@ module Berktacular
204
205
  cookbooks.each do |b|
205
206
  candidates = b.check_updates
206
207
  next unless candidates.any?
207
- puts "Cookbook: #{b.name} (auto upgrade: #{b.auto_upgrade ? 'enabled' : 'disabled'})",
208
- "\tCurrent: #{b.version_number}",
209
- "\tUpdates: #{candidates.join(", ")}"
208
+ puts "Cookbook: #{b.name} (auto upgrade: #{b.auto_upgrade ? 'enabled' : 'disabled'})",
209
+ "\tCurrent: #{b.version_number}",
210
+ "\tUpdates: #{candidates.join(", ")}"
210
211
  end
211
212
  end
212
213
 
@@ -1,8 +1,9 @@
1
1
  require 'semverse'
2
+ require 'ridley'
2
3
 
3
4
  module Berktacular
4
5
 
5
- # This class represents a cookbook entry form a Berksfile
6
+ # This class represents a cookbook entry from a Berksfile
6
7
 
7
8
  class Cookbook
8
9
 
@@ -35,6 +36,7 @@ module Berktacular
35
36
  @upgrade = opts.has_key?(:upgrade) ? opts[:upgrade] : false
36
37
  @git_client = opts.has_key?(:git_client) ? opts[:git_client].dup : nil
37
38
  @verbose = opts.has_key?(:verbose) ? opts[:verbose] : false
39
+ @multi_cookbook_dir = opts[:multi_cookbook_dir]
38
40
  check_updates if @auto_upgrade && @upgrade
39
41
  end
40
42
 
@@ -91,6 +93,22 @@ module Berktacular
91
93
  ver = (upgrade && @candidates && @candidates.first) || @version_number
92
94
  line = []
93
95
  if config
96
+ # Allow using coobkooks residing in subdirectories of a "multi-cookbook directory"
97
+ # (this can be e.g. the Chef repository) if the version matches.
98
+ if config.has_key?('rel') && @multi_cookbook_dir
99
+ local_cookbook_dir = File.join(@multi_cookbook_dir, config['rel'])
100
+ if Dir.exists?(local_cookbook_dir)
101
+ metadata_path = Dir["#{File.join(local_cookbook_dir, 'metadata')}.{rb,json}"].first
102
+ if metadata_path
103
+ metadata = Ridley::Chef::Cookbook::Metadata.from_file(metadata_path)
104
+ if metadata.version == ver
105
+ line << "path: \"#{local_cookbook_dir}\""
106
+ return line.join(', ')
107
+ end
108
+ end
109
+ end
110
+ end
111
+
94
112
  if config.has_key?('github')
95
113
  line << "git: \"git@github.com:#{config['github']}.git\""
96
114
  line << "rel: \"#{config['rel']}\"" if config.has_key?('rel')
@@ -106,7 +124,7 @@ module Berktacular
106
124
  end
107
125
  end
108
126
  else
109
- line << " \"#{ver}\""
127
+ line << "\"#{ver}\""
110
128
  end
111
129
  line.join(", ").gsub('%{version}', ver)
112
130
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: berktacular
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Harvey-Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-13 00:00:00.000000000 Z
11
+ date: 2014-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solve
@@ -139,12 +139,12 @@ executables:
139
139
  extensions: []
140
140
  extra_rdoc_files: []
141
141
  files:
142
+ - VERSION
142
143
  - bin/berktacular
143
144
  - lib/berktacular.rb
144
145
  - lib/berktacular/berksfile.rb
145
- - lib/berktacular/version.rb
146
146
  - lib/berktacular/cookbook.rb
147
- - VERSION
147
+ - lib/berktacular/version.rb
148
148
  homepage: https://rubygems.org/gems/berktacular
149
149
  licenses:
150
150
  - Apache License, Version 2.0
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  version: '0'
166
166
  requirements: []
167
167
  rubyforge_project:
168
- rubygems_version: 2.0.14
168
+ rubygems_version: 2.2.2
169
169
  signing_key:
170
170
  specification_version: 4
171
171
  summary: Parse chef env files, generates a Berksfile and verifies it.