mlafeldt / chef-runner

The fastest way to run Chef cookbooks
Apache License 2.0
179 stars 17 forks source link

`berks install --path [PATH}` has been replaced by `berks vendor` #12

Closed arosenhagen closed 10 years ago

arosenhagen commented 10 years ago

Berkshelf switched commands from berks install --path [PATH} to berks vendor.

INFO: Installing cookbook dependencies with Berkshelf resolver
DEPRECATED: `berks install --path [PATH}` has been replaced by `berks vendor`.
DEPRECATED: Re-run your command as `berks vendor [PATH]` or see `berks help vendor`.
mlafeldt commented 10 years ago

Thanks for your patch.

Unfortunately, this breaks compatibility with Berkshelf v2.

INFO: Installing cookbook dependencies with Berkshelf resolver
Could not find command "vendor".

berks install --path still works with Berkshelf v3, right? If it's not going to be removed anytime soon, I can live with the deprecation warning.

Or, even better, we can figure out a smart way to use the right command depending on the version. (Something like bundle exec berks version is super slow.)

mlafeldt commented 10 years ago

PS: Just found out that berks install --path is going to be removed in Berkshelf v4.

arosenhagen commented 10 years ago

unfortunately chef-runner fails with ERROR: exit status 1 while sticking to berks install --path and Berkshelf 3 :-/

mlafeldt commented 10 years ago

Oh, so they already removed it and only kept the deprecation warning. I'll take a look asap.

Thanks so far.

mlafeldt commented 10 years ago

I think I'm going to make your changes the new default behavior, but still support Berkshelf v2 somehow (e.g. via an environment variable). What do you think?

arosenhagen commented 10 years ago

:+1:

mlafeldt commented 10 years ago

I think I found a good solution to support both versions.

I let chef-runner create and execute this little Ruby helper script:

require "berkshelf"

cookbook_path = ARGV.shift

berksfile = ::Berkshelf::Berksfile.from_file("Berksfile")

::Berkshelf.ui.mute do
  if ::Berkshelf::Berksfile.method_defined?(:vendor)
    # Berkshelf 3.0 requires the directory to not exist
    FileUtils.rm_rf(cookbook_path)
    berksfile.vendor(cookbook_path)
  else
    berksfile.install(:path => cookbook_path)
  end
end

This is exactly the code that ChefSpec and Test Kitchen are using. :)

arosenhagen commented 10 years ago

this looks like a very nice solution ;-)

mlafeldt commented 10 years ago

@arosenhagen Please check my changes. :)

(Since you gave me write access, I thought it'd be OK to push directly.)

I think I'll make Berkshelf's output less verbose too, but in a different commit/PR.

arosenhagen commented 10 years ago

Sorry, I'm afraid I can't help out on that end (since go is totally new to me). That's why I gave you write access to the PR branch. So you're good to take it over ;-)

mlafeldt commented 10 years ago

I see. Hope my changes work for you too. Merging now! :)