chef-taste 1.0.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.
Files changed (61) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +108 -0
  5. data/Rakefile +1 -0
  6. data/bin/taste +5 -0
  7. data/chef-taste.gemspec +31 -0
  8. data/lib/chef/taste.rb +41 -0
  9. data/lib/chef/taste/changelog.rb +107 -0
  10. data/lib/chef/taste/cli.rb +46 -0
  11. data/lib/chef/taste/dependency.rb +72 -0
  12. data/lib/chef/taste/dependency_checker.rb +95 -0
  13. data/lib/chef/taste/display.rb +84 -0
  14. data/lib/chef/taste/errors.rb +32 -0
  15. data/lib/chef/taste/symbols.rb +30 -0
  16. data/lib/chef/taste/version.rb +35 -0
  17. data/test/cookbooks/curry/.gitignore +17 -0
  18. data/test/cookbooks/curry/.kitchen.yml +27 -0
  19. data/test/cookbooks/curry/Berksfile +3 -0
  20. data/test/cookbooks/curry/Gemfile +7 -0
  21. data/test/cookbooks/curry/LICENSE +3 -0
  22. data/test/cookbooks/curry/README.md +13 -0
  23. data/test/cookbooks/curry/Thorfile +12 -0
  24. data/test/cookbooks/curry/Vagrantfile +86 -0
  25. data/test/cookbooks/curry/chefignore +96 -0
  26. data/test/cookbooks/curry/metadata.rb +12 -0
  27. data/test/cookbooks/curry/recipes/default.rb +8 -0
  28. data/test/cookbooks/fried_rice/.gitignore +17 -0
  29. data/test/cookbooks/fried_rice/.kitchen.yml +27 -0
  30. data/test/cookbooks/fried_rice/Berksfile +3 -0
  31. data/test/cookbooks/fried_rice/Gemfile +7 -0
  32. data/test/cookbooks/fried_rice/LICENSE +3 -0
  33. data/test/cookbooks/fried_rice/README.md +13 -0
  34. data/test/cookbooks/fried_rice/Thorfile +12 -0
  35. data/test/cookbooks/fried_rice/Vagrantfile +86 -0
  36. data/test/cookbooks/fried_rice/chefignore +96 -0
  37. data/test/cookbooks/fried_rice/metadata.rb +12 -0
  38. data/test/cookbooks/fried_rice/recipes/default.rb +8 -0
  39. data/test/cookbooks/noodles/.gitignore +17 -0
  40. data/test/cookbooks/noodles/.kitchen.yml +27 -0
  41. data/test/cookbooks/noodles/Berksfile +3 -0
  42. data/test/cookbooks/noodles/Gemfile +7 -0
  43. data/test/cookbooks/noodles/LICENSE +3 -0
  44. data/test/cookbooks/noodles/README.md +13 -0
  45. data/test/cookbooks/noodles/Thorfile +12 -0
  46. data/test/cookbooks/noodles/Vagrantfile +86 -0
  47. data/test/cookbooks/noodles/chefignore +96 -0
  48. data/test/cookbooks/noodles/metadata.rb +11 -0
  49. data/test/cookbooks/noodles/recipes/default.rb +8 -0
  50. data/test/cookbooks/water/.gitignore +17 -0
  51. data/test/cookbooks/water/.kitchen.yml +27 -0
  52. data/test/cookbooks/water/Berksfile +3 -0
  53. data/test/cookbooks/water/Gemfile +7 -0
  54. data/test/cookbooks/water/LICENSE +3 -0
  55. data/test/cookbooks/water/README.md +13 -0
  56. data/test/cookbooks/water/Thorfile +12 -0
  57. data/test/cookbooks/water/Vagrantfile +86 -0
  58. data/test/cookbooks/water/chefignore +96 -0
  59. data/test/cookbooks/water/metadata.rb +8 -0
  60. data/test/cookbooks/water/recipes/default.rb +8 -0
  61. metadata +297 -0
@@ -0,0 +1,95 @@
1
+ #
2
+ # Copyright (c) 2013 Kannan Manickam <me@arangamani.net>
3
+ #
4
+ # MIT License
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining
7
+ # a copy of this software and associated documentation files (the
8
+ # "Software"), to deal in the Software without restriction, including
9
+ # without limitation the rights to use, copy, modify, merge, publish,
10
+ # distribute, sublicense, and/or sell copies of the Software, and to
11
+ # permit persons to whom the Software is furnished to do so, subject to
12
+ # the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be
15
+ # included in all copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ #
25
+
26
+ require 'chef/taste'
27
+
28
+ module Chef
29
+ module Taste
30
+ # The class checks for cookbook dependencies and populates all fields for the dependent cookbook
31
+ #
32
+ class DependencyChecker
33
+ class << self
34
+ # Check for cookbook dependencies and their versions
35
+ #
36
+ # @param path [String] the path for the cookbook
37
+ #
38
+ # @return [Array<Dependency>] list of dependency objects
39
+ #
40
+ # @raise NotACookbook the current/given path is not a cookbook
41
+ #
42
+ def check(path = Dir.pwd)
43
+ raise NotACookbookError, "Path is not a cookbook" unless File.exists?(File.join(path, 'metadata.rb'))
44
+ ridley = Ridley::Chef::Cookbook::Metadata.from_file(File.join(path, 'metadata.rb'))
45
+ dependencies =
46
+ ridley.dependencies.map do |name, version|
47
+ Dependency.new(name, version)
48
+ end
49
+ populate_fields(dependencies)
50
+ end
51
+
52
+ # Populate various fields for all dependencies
53
+ #
54
+ # @param dependencies [Array<Dependency>] list of dependency objects
55
+ #
56
+ # @return [Array<Dependency>] list of dependency objects with updated fields
57
+ #
58
+ def populate_fields(dependencies)
59
+ rest = Berkshelf::CommunityREST.new
60
+ dependencies.each do |dep|
61
+ # Skip cookbooks that are not available in the community site. It might be an external cookbook.
62
+ #
63
+ next unless cookbook_exists?(dep.name)
64
+
65
+ dep.latest = rest.latest_version(dep.name)
66
+ # Obtain the version used based on the version constraint
67
+ #
68
+ dep.version_used = rest.satisfy(dep.name, dep.requirement)
69
+ dep.source_url = rest.get(dep.name).body['external_url']
70
+
71
+ # Calculate the status based on the version being used and the latest version
72
+ #
73
+ if Solve::Version.new(dep.version_used).eql?(Solve::Version.new(dep.latest))
74
+ dep.status = TICK_MARK
75
+ else
76
+ dep.status = X_MARK
77
+ dep.changelog = Changelog.compute(dep)
78
+ end
79
+ end
80
+ end
81
+
82
+ # Checks if a particular cookbook exists in the community site
83
+ #
84
+ # @param name [String] the name of the cookbook
85
+ #
86
+ # @return [Boolean] whether the cookbook exists in the community site or not
87
+ #
88
+ def cookbook_exists?(name)
89
+ rest = Berkshelf::CommunityREST.new
90
+ rest.get(name).status == 200
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,84 @@
1
+ #
2
+ # Copyright (c) 2013 Kannan Manickam <me@arangamani.net>
3
+ #
4
+ # MIT License
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining
7
+ # a copy of this software and associated documentation files (the
8
+ # "Software"), to deal in the Software without restriction, including
9
+ # without limitation the rights to use, copy, modify, merge, publish,
10
+ # distribute, sublicense, and/or sell copies of the Software, and to
11
+ # permit persons to whom the Software is furnished to do so, subject to
12
+ # the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be
15
+ # included in all copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ #
25
+
26
+ require 'chef/taste'
27
+
28
+ module Chef
29
+ module Taste
30
+ # Displays the status of the dependency cookbooks
31
+ #
32
+ class Display
33
+ class << self
34
+ # Prints the status of dependent cookbooks as a table
35
+ #
36
+ # @param dependencies [Array<Dependency>] list of cookbook dependency objects
37
+ #
38
+ def print(dependencies)
39
+ if dependencies.empty?
40
+ puts "No dependent cookbooks"
41
+ else
42
+ rows = []
43
+ headings = [
44
+ 'Name',
45
+ 'Requirement',
46
+ 'Used',
47
+ 'Latest',
48
+ 'Status',
49
+ 'Changelog'
50
+ ]
51
+ dependencies.each do |dependency|
52
+ color =
53
+ if dependency.status == TICK_MARK
54
+ 'green'
55
+ elsif dependency.status == X_MARK
56
+ 'red'
57
+ else
58
+ 'white'
59
+ end
60
+ rows << [
61
+ dependency.name,
62
+ dependency.requirement,
63
+ dependency.version_used,
64
+ dependency.latest,
65
+ {:value => dependency.status.send(color), :alignment => :center},
66
+ dependency.changelog
67
+ ]
68
+ end
69
+
70
+ # If any of the cookbook is out-of-date
71
+ out_of_date = dependencies.any? { |dep| dep.status == X_MARK }
72
+ table = Terminal::Table.new headings: headings, rows: rows
73
+ puts table
74
+ if out_of_date
75
+ puts "Status: out-of-date ( #{X_MARK} )".red
76
+ else
77
+ puts "Status: up-to-date ( #{TICK_MARK} )".green
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,32 @@
1
+ #
2
+ # Copyright (c) 2013 Kannan Manickam <me@arangamani.net>
3
+ #
4
+ # MIT License
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining
7
+ # a copy of this software and associated documentation files (the
8
+ # "Software"), to deal in the Software without restriction, including
9
+ # without limitation the rights to use, copy, modify, merge, publish,
10
+ # distribute, sublicense, and/or sell copies of the Software, and to
11
+ # permit persons to whom the Software is furnished to do so, subject to
12
+ # the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be
15
+ # included in all copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ #
25
+
26
+ module Chef
27
+ module Taste
28
+ # The current/given path is not a cookbook
29
+ #
30
+ class NotACookbookError < StandardError; end
31
+ end
32
+ end
@@ -0,0 +1,30 @@
1
+ #
2
+ # Copyright (c) 2013 Kannan Manickam <me@arangamani.net>
3
+ #
4
+ # MIT License
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining
7
+ # a copy of this software and associated documentation files (the
8
+ # "Software"), to deal in the Software without restriction, including
9
+ # without limitation the rights to use, copy, modify, merge, publish,
10
+ # distribute, sublicense, and/or sell copies of the Software, and to
11
+ # permit persons to whom the Software is furnished to do so, subject to
12
+ # the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be
15
+ # included in all copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ #
25
+
26
+ # The ASCII code for tick mark symbol
27
+ TICK_MARK = "\u2714"
28
+
29
+ # The ASCII code for X mark symbol
30
+ X_MARK = "\u2716"
@@ -0,0 +1,35 @@
1
+ #
2
+ # Copyright (c) 2013 Kannan Manickam <me@arangamani.net>
3
+ #
4
+ # MIT License
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining
7
+ # a copy of this software and associated documentation files (the
8
+ # "Software"), to deal in the Software without restriction, including
9
+ # without limitation the rights to use, copy, modify, merge, publish,
10
+ # distribute, sublicense, and/or sell copies of the Software, and to
11
+ # permit persons to whom the Software is furnished to do so, subject to
12
+ # the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be
15
+ # included in all copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ #
25
+
26
+ # The top level module
27
+ #
28
+ module Chef
29
+ # The taste module that contains all classes
30
+ #
31
+ module Taste
32
+ # The version string
33
+ VERSION = "1.0.0"
34
+ end
35
+ end
@@ -0,0 +1,17 @@
1
+ .vagrant
2
+ Berksfile.lock
3
+ *~
4
+ *#
5
+ .#*
6
+ \#*#
7
+ .*.sw[a-z]
8
+ *.un~
9
+ /cookbooks
10
+
11
+ # Bundler
12
+ Gemfile.lock
13
+ bin/*
14
+ .bundle/*
15
+
16
+ .kitchen/
17
+ .kitchen.local.yml
@@ -0,0 +1,27 @@
1
+ ---
2
+ driver_plugin: vagrant
3
+ driver_config:
4
+ require_chef_omnibus: true
5
+
6
+ platforms:
7
+ - name: ubuntu-12.04
8
+ driver_config:
9
+ box: opscode-ubuntu-12.04
10
+ box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box
11
+ - name: ubuntu-10.04
12
+ driver_config:
13
+ box: opscode-ubuntu-10.04
14
+ box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-10.04_provisionerless.box
15
+ - name: centos-6.4
16
+ driver_config:
17
+ box: opscode-centos-6.4
18
+ box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_centos-6.4_provisionerless.box
19
+ - name: centos-5.9
20
+ driver_config:
21
+ box: opscode-centos-5.9
22
+ box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_centos-5.9_provisionerless.box
23
+
24
+ suites:
25
+ - name: default
26
+ run_list: ["recipe[curry]"]
27
+ attributes: {}
@@ -0,0 +1,3 @@
1
+ site :opscode
2
+
3
+ metadata
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'berkshelf'
4
+ gem 'test-kitchen', '~> 1.0.0.alpha.3', :group => :integration
5
+ gem 'kitchen-vagrant', :group => :integration
6
+
7
+ gem 'chef-taste', :path => '../../../'
@@ -0,0 +1,3 @@
1
+ Copyright (C) 2013 YOUR_NAME
2
+
3
+ All rights reserved - Do Not Redistribute
@@ -0,0 +1,13 @@
1
+ # curry cookbook
2
+
3
+ # Requirements
4
+
5
+ # Usage
6
+
7
+ # Attributes
8
+
9
+ # Recipes
10
+
11
+ # Author
12
+
13
+ Author:: YOUR_NAME (<YOUR_EMAIL>)
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+
3
+ require 'bundler'
4
+ require 'bundler/setup'
5
+ require 'berkshelf/thor'
6
+
7
+ begin
8
+ require 'kitchen/thor_tasks'
9
+ Kitchen::ThorTasks.new
10
+ rescue LoadError
11
+ puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV['CI']
12
+ end
@@ -0,0 +1,86 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ Vagrant.configure("2") do |config|
5
+ # All Vagrant configuration is done here. The most common configuration
6
+ # options are documented and commented below. For a complete reference,
7
+ # please see the online documentation at vagrantup.com.
8
+
9
+ config.vm.hostname = "curry-berkshelf"
10
+
11
+ # Every Vagrant virtual environment requires a box to build off of.
12
+ config.vm.box = "Berkshelf-CentOS-6.3-x86_64-minimal"
13
+
14
+ # The url from where the 'config.vm.box' box will be fetched if it
15
+ # doesn't already exist on the user's system.
16
+ config.vm.box_url = "https://dl.dropbox.com/u/31081437/Berkshelf-CentOS-6.3-x86_64-minimal.box"
17
+
18
+ # Assign this VM to a host-only network IP, allowing you to access it
19
+ # via the IP. Host-only networks can talk to the host machine as well as
20
+ # any other machines on the same network, but cannot be accessed (through this
21
+ # network interface) by any external networks.
22
+ config.vm.network :private_network, ip: "33.33.33.10"
23
+
24
+ # Create a public network, which generally matched to bridged network.
25
+ # Bridged networks make the machine appear as another physical device on
26
+ # your network.
27
+
28
+ # config.vm.network :public_network
29
+
30
+ # Create a forwarded port mapping which allows access to a specific port
31
+ # within the machine from a port on the host machine. In the example below,
32
+ # accessing "localhost:8080" will access port 80 on the guest machine.
33
+
34
+ # Share an additional folder to the guest VM. The first argument is
35
+ # the path on the host to the actual folder. The second argument is
36
+ # the path on the guest to mount the folder. And the optional third
37
+ # argument is a set of non-required options.
38
+ # config.vm.synced_folder "../data", "/vagrant_data"
39
+
40
+ # Provider-specific configuration so you can fine-tune various
41
+ # backing providers for Vagrant. These expose provider-specific options.
42
+ # Example for VirtualBox:
43
+ #
44
+ # config.vm.provider :virtualbox do |vb|
45
+ # # Don't boot with headless mode
46
+ # vb.gui = true
47
+ #
48
+ # # Use VBoxManage to customize the VM. For example to change memory:
49
+ # vb.customize ["modifyvm", :id, "--memory", "1024"]
50
+ # end
51
+ #
52
+ # View the documentation for the provider you're using for more
53
+ # information on available options.
54
+
55
+ config.ssh.max_tries = 40
56
+ config.ssh.timeout = 120
57
+
58
+ # The path to the Berksfile to use with Vagrant Berkshelf
59
+ # config.berkshelf.berksfile_path = "./Berksfile"
60
+
61
+ # Enabling the Berkshelf plugin. To enable this globally, add this configuration
62
+ # option to your ~/.vagrant.d/Vagrantfile file
63
+ config.berkshelf.enabled = true
64
+
65
+ # An array of symbols representing groups of cookbook described in the Vagrantfile
66
+ # to exclusively install and copy to Vagrant's shelf.
67
+ # config.berkshelf.only = []
68
+
69
+ # An array of symbols representing groups of cookbook described in the Vagrantfile
70
+ # to skip installing and copying to Vagrant's shelf.
71
+ # config.berkshelf.except = []
72
+
73
+ config.vm.provision :chef_solo do |chef|
74
+ chef.json = {
75
+ :mysql => {
76
+ :server_root_password => 'rootpass',
77
+ :server_debian_password => 'debpass',
78
+ :server_repl_password => 'replpass'
79
+ }
80
+ }
81
+
82
+ chef.run_list = [
83
+ "recipe[curry::default]"
84
+ ]
85
+ end
86
+ end