Skip to content
This repository has been archived by the owner on Dec 26, 2017. It is now read-only.

Remove ChefDK dependency in favor of berkshelf gem #324

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# vagrant-berkshelf Changelog

## 6.0.0

- Remove ChefDK dependency

## 5.1.2

- Loosen the vagrant dependency to allow for Vagrant 2.X
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ See Seth Vargo's blog post for additional information on Test Kitchen vs. Vagran
## Installation

1. Install the latest version of [Vagrant](https://www.vagrantup.com/downloads.html)
2. Install the latest version of [ChefDK](https://downloads.chef.io/chef-dk/)
3. Install the Vagrant Berkshelf plugin:

```sh
Expand Down
32 changes: 1 addition & 31 deletions lib/vagrant-berkshelf/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,9 @@

module VagrantPlugins
module Berkshelf
INSTALL_CHEFDK_INSTRUCTIONS = <<-EOH.freeze
Please download and install the latest version of the ChefDK from:

https://downloads.chef.io/chef-dk

and follow the installation instructions. Do not forget to add the ChefDK to
your PATH.
EOH

class BerkshelfNotFound < Vagrant::Errors::VagrantError
def error_message
<<-EOH
Vagrant Berkshelf could not find the 'berks' executable in your PATH.

#{INSTALL_CHEFDK_INSTRUCTIONS}
EOH
"Vagrant Berkshelf could not find the 'berks' executable in your PATH."
end
end

Expand All @@ -27,20 +14,6 @@ def initialize(command, stdout, stderr)
super
end

def chefdk?
@command.include?("chefdk")
end

def not_chefdk_message
<<-EOH
It appears that you are not using the ChefDK. Please note that Vagrant Berkshelf
works best when used with the ChefDK, and other installation methods are not
officially supported.

#{INSTALL_CHEFDK_INSTRUCTIONS}
EOH
end

def error_message
base = <<-EOH
The following berks command failed to execute:
Expand All @@ -53,7 +26,6 @@ def error_message
stderr: #{@stderr}
EOH

base << "\n#{not_chefdk_message}" if !chefdk?
base
end
end
Expand All @@ -70,8 +42,6 @@ def error_message
<<-EOH
The Berkshelf version at #{@bin.inspect} is invalid.
Vagrant Berkshelf requires #{@constraint}, but the current version is #{@version}.

#{INSTALL_CHEFDK_INSTRUCTIONS}
EOH
end
end
Expand Down
13 changes: 6 additions & 7 deletions lib/vagrant-berkshelf/helpers.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'json'
require 'open3'
require 'vagrant/util'

require_relative 'errors'
Expand Down Expand Up @@ -59,13 +60,11 @@ def berks(command, *args)

final_command = [berks_bin, command, *args]

Vagrant::Util::Env.with_clean_env do
r = Subprocess.execute(*final_command)
if r.exit_code != 0
raise BerksCommandFailed.new(final_command.join(' '), r.stdout, r.stderr)
end
r
end
sanitized_env = ENV.to_h.merge('GEM_HOME' => nil, 'GEM_PATH' => nil)
command = final_command.join(' ')
out, err, status = Open3.capture3(sanitized_env, command)
raise BerksCommandFailed.new(command, out, err) unless status.success?
OpenStruct.new(stdout: out, stderr: err)
end

# The path to the Berkshelf binary on disk.
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant-berkshelf/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module VagrantPlugins
module Berkshelf
VERSION = "5.1.2"
VERSION = '6.0.0'
end
end
9 changes: 1 addition & 8 deletions vagrant-berkshelf.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,7 @@ Gem::Specification.new do |spec|
spec.require_paths = ['lib']
spec.required_ruby_version = '>= 2.2.0'

spec.post_install_message = <<-EOH
The Vagrant Berkshelf plugin requires Berkshelf from the Chef Development Kit.
You can download the latest version of the Chef Development Kit from:

https://downloads.chef.io/chefdk

Installing Berkshelf via other methods is not officially supported.
EOH
spec.add_runtime_dependency 'berkshelf'

spec.add_development_dependency 'spork', '~> 0.9'
spec.add_development_dependency 'rspec', '~> 3.0'
Expand Down