berkshelf_ext 1.0.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,2 +1,7 @@
1
- ## v0.1.0
1
+ ## v1.0.2
2
+ * Add `non_recommends_depends` to fix dependency resolution
3
+ * Add `knife_uploader` addon to disable ridley based uploads
4
+ * Remove preemptive cookbook fetching. Fixes proper dependency resolution to use dependencies defined within Berksfile when explicitly defining cookbooks to upload.
5
+
6
+ ## v1.0.0
2
7
  * Initial release
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # Berkshelf Ext
2
2
 
3
- Berkshelf extensions to add features to berkshelf not
4
- accepted upstream.
3
+ Berkshelf extensions to add features to berkshelf.
5
4
 
6
5
  ## Usage
7
6
 
@@ -26,9 +25,12 @@ it as usual.
26
25
 
27
26
  ## Current extensions
28
27
 
29
- * Resolution via nested berksfiles (nested_berksfiles)
30
- * Proper berksfile path when loading berksfiles (berksfile_loader_context)
31
- * Proper dependency resolution (dependency_chains)
28
+ These extensions are auto loaded by default.
29
+
30
+ * Resolution via nested berksfiles (nested_berksfiles)[1]
31
+ * Proper berksfile path when loading berksfiles (berksfile_loader_context)[2]
32
+ * Proper dependency resolution (dependency_chains)[3]
33
+ * Do not include recommends entries in cookbook dependencies (non_recommends_depends)
32
34
 
33
35
  ## Prevent extension loading
34
36
 
@@ -38,5 +40,22 @@ environment variables
38
40
  * `BERKSHELF_EXT_EXCEPT="nested_berksfiles"`
39
41
  * `BERKSHELF_EXT_ONLY="nested_berksfiles,berksfile_loader_context"`
40
42
 
43
+ ## Current addons
44
+
45
+ Addons are extensions that must be explicitly enabled via environment variable:
46
+
47
+ * `BERKSHELF_EXT_ADDONS="knife_uploader"`
48
+
49
+ ### Available addons
50
+
51
+ * Knife based cookbook uploading (disables Ridley)[4]
52
+
53
+ # References
54
+
55
+ 1. https://github.com/RiotGames/berkshelf/pull/304
56
+ 2. https://github.com/RiotGames/berkshelf/pull/304
57
+ 3. https://github.com/RiotGames/berkshelf/pull/302
58
+ 4. https://github.com/RiotGames/berkshelf/pull/291
59
+
41
60
  # Info
42
61
  * Repository: https://github.com/chrisroberts/berkshelf_ext
Binary file
@@ -11,5 +11,6 @@ Gem::Specification.new do |s|
11
11
  s.require_path = 'lib'
12
12
  s.executables = %w(berks_ext)
13
13
  s.add_dependency 'berkshelf', BerkshelfExt::BERKSHELF_CONSTRAINT
14
+ s.add_dependency 'chef'
14
15
  s.files = Dir['**/*']
15
16
  end
data/bin/berks_ext CHANGED
File without changes
@@ -0,0 +1,62 @@
1
+ require 'chef'
2
+ require 'chef/cookbook_uploader'
3
+
4
+ module Ridley
5
+ class << self
6
+ def new(options)
7
+ RidleyMocker.new(options)
8
+ end
9
+ end
10
+ end
11
+
12
+ class RidleyMocker
13
+ def initialize(options)
14
+ end
15
+
16
+ def method_missing(sym, *args)
17
+ if(@ckbk)
18
+ @ckbk.send(sym, *args)
19
+ else
20
+ super
21
+ end
22
+ end
23
+
24
+ def cookbook
25
+ self
26
+ end
27
+
28
+ def alive?
29
+ false
30
+ end
31
+
32
+ def path
33
+ @path
34
+ end
35
+
36
+ def upload(path, upload_options)
37
+ chef_config!
38
+ @path = path
39
+ loader = Chef::Cookbook::CookbookVersionLoader.new(path)
40
+ loader.load_cookbooks
41
+ cv = loader.cookbook_version
42
+ cv.send(:generate_manifest)
43
+ cv.manifest['name'] = "#{cv.name}-#{cv.version}" #.sub!(%r{-[^-]+$}, '')
44
+ cv.manifest['cookbook_name'] = cv.name
45
+ cv.freeze_version if upload_options.delete(:freeze)
46
+ Chef::CookbookUploader.new([cv], cookbook.path, upload_options).upload_cookbooks
47
+ @ckbk = cv
48
+ end
49
+
50
+ def chef_config!
51
+ cwd = Dir.pwd.split('/')
52
+ until(cwd.empty?)
53
+ knife_conf = File.join(cwd.join('/'), '.chef/knife.rb')
54
+ if(File.exists?(knife_conf))
55
+ Chef::Config.from_file(knife_conf)
56
+ return
57
+ end
58
+ end
59
+ raise 'Failed to locate knife.rb file to configure chef!'
60
+ end
61
+
62
+ end
@@ -9,3 +9,9 @@ Dir.glob(File.join(File.dirname(__FILE__), '*.rb')).each do |ext_file|
9
9
  end
10
10
  require ext_file
11
11
  end
12
+
13
+ if(ENV['BERKSHELF_EXT_ADDONS'])
14
+ ENV['BERKSHELF_EXT_ADDONS'].split(',').each do |addon|
15
+ require "berkshelf_ext/addons/#{addon.strip}"
16
+ end
17
+ end
@@ -1,4 +1,4 @@
1
- module Berkshelf
1
+ module BerkshelfExt
2
2
  module BerksfileLoaderContext
3
3
  module Berksfile
4
4
  def self.included(klass)
@@ -50,4 +50,4 @@ module Berkshelf
50
50
  end
51
51
  end
52
52
 
53
- Berkshelf::Berksfile.send(:include, Berkshelf::BerksfileLoaderContext::Berksfile)
53
+ Berkshelf::Berksfile.send(:include, BerkshelfExt::BerksfileLoaderContext::Berksfile)
@@ -1,5 +1,33 @@
1
1
  module BerkshelfExt
2
2
  module DependencyChains
3
+ module Berksfile
4
+ class << self
5
+ def included(klass)
6
+ klass.class_eval do
7
+ alias_method :non_dependency_chains_sources, :sources
8
+ alias_method :sources, :dependency_chains_sources
9
+ end
10
+ end
11
+ end
12
+ def dependency_chains_sources(options = {})
13
+ l_sources = @sources.collect { |name, source| source }.flatten
14
+
15
+ except = Array(options.fetch(:except, nil)).collect(&:to_sym)
16
+ only = Array(options.fetch(:only, nil)).collect(&:to_sym)
17
+
18
+ case
19
+ when !except.empty? && !only.empty?
20
+ raise Berkshelf::ArgumentError, "Cannot specify both :except and :only"
21
+ when !except.empty?
22
+ l_sources.select { |source| (except & source.groups).empty? }
23
+ when !only.empty?
24
+ l_sources.select { |source| !(only & source.groups).empty? }
25
+ else
26
+ l_sources
27
+ end
28
+ end
29
+ end
30
+
3
31
  module Resolver
4
32
 
5
33
  class << self
@@ -48,7 +76,10 @@ module BerkshelfExt
48
76
  begin
49
77
  solution = Solve.it!(graph, [demand])
50
78
  rescue Solve::Errors::NoSolutionError
51
- raise Berkshelf::NoSolution.new("Failed to resolve dependencies for: #{demand.join(': ')}")
79
+ raise Berkshelf::NoSolution.new(
80
+ "Failed to resolve dependencies for:\n#{demand.join(': ')}\nDependencies: " <<
81
+ @sources[demand.first].cached_cookbook.dependencies.map{|n,v| " #{n}: #{v}"}.join("\n")
82
+ )
52
83
  end
53
84
  end
54
85
  solution = Solve.it!(graph, demands)
@@ -0,0 +1,20 @@
1
+ module BerkshelfExt
2
+ module NonRecommendsDepends
3
+ module CachedCookbook
4
+ class << self
5
+ def included(klass)
6
+ klass.class_eval do
7
+ alias_method :non_non_recommends_depends_dependencies, :dependencies
8
+ alias_method :dependencies, :non_recommends_depends_dependencies
9
+ end
10
+ end
11
+ end
12
+
13
+ def non_recommends_depends_dependencies
14
+ metadata.dependencies
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ Berkshelf::CachedCookbook.send(:include, BerkshelfExt::NonRecommendsDepends::CachedCookbook)
@@ -2,6 +2,6 @@ module BerkshelfExt
2
2
  class Version < Gem::Version
3
3
  end
4
4
 
5
- VERSION = Version.new('1.0.0')
5
+ VERSION = Version.new('1.0.2')
6
6
  BERKSHELF_CONSTRAINT = '~> 1.3.1'
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: berkshelf_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-09 00:00:00.000000000 Z
12
+ date: 2013-04-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: berkshelf
@@ -27,6 +27,22 @@ dependencies:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  version: 1.3.1
30
+ - !ruby/object:Gem::Dependency
31
+ name: chef
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'
30
46
  description: Extenstions for berkshelf
31
47
  email: chrisroberts.code@gmail.com
32
48
  executables:
@@ -39,6 +55,8 @@ files:
39
55
  - lib/berkshelf_ext/nested_berksfiles.rb
40
56
  - lib/berkshelf_ext/version.rb
41
57
  - lib/berkshelf_ext/dependency_chains.rb
58
+ - lib/berkshelf_ext/addons/knife_uploader.rb
59
+ - lib/berkshelf_ext/non_recommends_depends.rb
42
60
  - lib/berkshelf_ext/berksfile_loader_context.rb
43
61
  - lib/berkshelf_ext.rb
44
62
  - README.md