Skip to content

Commit

Permalink
Merge pull request #147 from Nordstrom/v2
Browse files Browse the repository at this point in the history
  • Loading branch information
oifland authored Aug 13, 2016
2 parents 6bef105 + 68488d0 commit be304a4
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 80 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
Bootstrap script should install latest ChefDK available by default
* Fix [#142](https://github.com/Nordstrom/chefdk_bootstrap/issues/142)
Add fix_profile and remove posh-git install for kitchen tests to avoid hanging
* Fix [#143](https://github.com/Nordstrom/chefdk_bootstrap/issues/143)
Remove support of custom cookbooks and private supermarkets
* Add Appveyor for windows integration testing
* Add version as a named parameter

Expand Down
13 changes: 1 addition & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,8 @@ ruby -e "$(curl https://raw.githubusercontent.com/Nordstrom/chefdk_bootstrap/mas
```

### Custom cookbook
#### Windows

```PowerShell
Invoke-WebRequest -UseBasicParsing https://raw.githubusercontent.com/Nordstrom/chefdk_bootstrap/master/bootstrap.ps1 | Invoke-Expression
install -cookbook <your cookbook name> -berks_source <your private supermarket url>
```

#### Mac

```bash
ruby -e "$(curl https://raw.githubusercontent.com/Nordstrom/chefdk_bootstrap/master/bootstrap.rb)" - --cookbook <your cookbook name> --berks-source <your supermarket url>
```
Deprecated. If you would like to use a custom cookbook, please use an earlier version of ChefDK_bootstrap.

### ChefDK Version
You can specify the version of chefdk to install as a named parameter in the bootstrap script. By default, the bootstrap script will install the latest version of chefdk. The script will not re-install chefdk if the target version is already installed.
Expand Down
19 changes: 2 additions & 17 deletions bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ function die {
function Install-Project {
Param(
[string] $version,
[string] $cookbook,
[string] $json_attributes,
[string] $berks_source,
[string] $branch
)

if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(`
Expand Down Expand Up @@ -64,17 +61,6 @@ function Install-Project {
}

$bootstrapCookbook = 'chefdk_bootstrap'
if ($cookbook) {
$bootstrapCookbook = $cookbook
}

if ($berks_source) {
$privateSource = "source '$berks_source'"
}

if ($branch) {
$devbranch = ", github: 'Nordstrom/chefdk_bootstrap', branch: '$branch'"
}

$userChefDir = Join-Path -path $env:USERPROFILE -childPath 'chef'
$dotChefDKDir = Join-Path -path $env:LOCALAPPDATA -childPath 'chefdk'
Expand All @@ -89,9 +75,8 @@ function Install-Project {

$berksfile = @"
source 'https://supermarket.chef.io'
$privateSource
cookbook '$bootstrapCookbook'$devbranch
cookbook '$bootstrapCookbook'
"@

$chefConfig = @"
Expand All @@ -103,7 +88,7 @@ function Install-Project {
### This bootstrap script will:
1. Install the ChefDK version $targetChefDk.
2. Download the $bootstrapCookbook cookbook via Berkshelf $privateSource
2. Download the $bootstrapCookbook cookbook via Berkshelf
3. Run chef-client to install the rest of the tools you'll need.
"@
Expand Down
11 changes: 0 additions & 11 deletions bootstrap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@ def parse
executable_name = File.basename($PROGRAM_NAME)
opts.banner = "Usage: #{executable_name} [options]"

opts.on('-c', '--cookbook COOKBOOK', 'Enter your custom ChefDK_bootstrap wrapper cookbook name.') do |v|
options[:cookbook] = v
end

opts.on('-b', '--berks-source BSOURCE_URL', 'Enter your private supermarket URL.') do |v|
options[:berks_source] = v
end

opts.on('-j', '--json-attributes JSON_ATTRIBUTES', 'Enter your URL/path to the JSON file containing your JSON attributes.') do |v|
options[:json_attributes] = v
end
Expand Down Expand Up @@ -81,7 +73,6 @@ class Berksfile
# * :berks_source [String] private supermarket URL
# * :json_attributes [String] URL/path to the JSON file
def initialize(options)
@berks_source = options[:berks_source]
@cookbook = options[:cookbook] || 'chefdk_bootstrap'
end

Expand All @@ -90,11 +81,9 @@ def initialize(options)
# @return [File] berksfile object
def create
@tempdir = Dir.mktmpdir('chefdk_bootstrap-')
private_source = "source '#{@berks_source}'" if @berks_source

berksfile_content = <<-EOH.gsub(/^\s+/, '')
source 'https://supermarket.chef.io'
#{private_source}
cookbook '#{@cookbook}'
EOH
Expand Down
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
maintainer_email '[email protected]'
license 'Apache 2.0'
description 'Bootstrap a developer workstation for local Chef development using the ChefDK'
version '1.9.0'
version '2.0.0'

supports 'windows'
supports 'mac_os_x'
Expand Down
1 change: 1 addition & 0 deletions recipes/conemu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
# installation script and we don't want to touch it
not_if '(& "C:\Program Files\ConEmu\ConEmu\ConEmuC.exe" /IsConEmu); $LASTEXITCODE -eq 1'
guard_interpreter :powershell_script
options '--allow-empty-checksums'
end
8 changes: 6 additions & 2 deletions recipes/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@
case node['platform_family']
when 'windows'
# chocolatey_package %w(git git-credential-manager-for-windows poshgit)
chocolatey_package 'git'
chocolatey_package 'git-credential-manager-for-windows'
chocolatey_package 'git' do
options '--allow-empty-checksums'
end
chocolatey_package 'git-credential-manager-for-windows' do
options '--allow-empty-checksums'
end
# chocolatey_package 'poshgit'
when 'mac_os_x'
package 'git'
Expand Down
4 changes: 3 additions & 1 deletion recipes/gitextensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@
# limitations under the License.
#

chocolatey_package 'gitextensions'
chocolatey_package 'gitextensions' do
options '--allow-empty-checksums'
end
4 changes: 3 additions & 1 deletion recipes/kdiff3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@
# limitations under the License.
#

chocolatey_package 'kdiff3'
chocolatey_package 'kdiff3' do
options '--allow-empty-checksums'
end
4 changes: 3 additions & 1 deletion recipes/poshgit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@
# limitations under the License.
#

chocolatey_package 'poshgit'
chocolatey_package 'poshgit' do
options '--allow-empty-checksums'
end
4 changes: 3 additions & 1 deletion recipes/virtualbox.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@

case node['platform_family']
when 'windows'
chocolatey_package 'virtualbox'
chocolatey_package 'virtualbox' do
options '--allow-empty-checksums'
end
when 'mac_os_x'
dmg_package 'Virtualbox' do
source node['chefdk_bootstrap']['virtualbox']['source']
Expand Down
37 changes: 4 additions & 33 deletions spec/unit/bootstrap_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@

context 'long options' do
let(:arguments) do
%w(--cookbook your_cookbook --berks-source https://supermarket.chef.io --json-attributes http://server/attributes.json --version 0.14.25)
%w(--json-attributes http://server/attributes.json --version 0.14.25)
end

it 'all long options specified' do
options = {
cookbook: 'your_cookbook',
berks_source: 'https://supermarket.chef.io',
cookbook: 'chefdk_bootstrap',
json_attributes: 'http://server/attributes.json',
version: '0.14.25'
}
Expand All @@ -45,13 +44,12 @@
end

context 'short options' do
let(:arguments) { %w(-c your_cookbook -b https://supermarket.chef.io -j http://server/attributes.json -v 0.14.25) }
let(:arguments) { %w(-j http://server/attributes.json -v 0.14.25) }

it 'all short options specified' do
options =
{
cookbook: 'your_cookbook',
berks_source: 'https://supermarket.chef.io',
cookbook: 'chefdk_bootstrap',
json_attributes: 'http://server/attributes.json',
version: '0.14.25'
}
Expand All @@ -73,33 +71,6 @@
.to include("cookbook 'chefdk_bootstrap'")
.and include("source 'https://supermarket.chef.io'")
end

it 'creates berksfile with custom berksfile source' do
options[:berks_source] = 'http://chef.example.com'
berksfile.create
expect(File.read(berksfile.path))
.to include("cookbook 'chefdk_bootstrap'")
.and include("source 'https://supermarket.chef.io'")
.and include("source 'http://chef.example.com'")
end

it 'creates berksfile with custom cookbook' do
options[:cookbook] = 'my_cookbook'
berksfile.create
expect(File.read(berksfile.path))
.to include("cookbook 'my_cookbook'")
.and include("source 'https://supermarket.chef.io'")
end

it 'creates berksfile with custom cookbook and custom berksfile source' do
options[:cookbook] = 'my_cookbook2'
options[:berks_source] = 'http://chef.example2.com'
berksfile.create
expect(File.read(berksfile.path))
.to include("cookbook 'my_cookbook2'")
.and include("source 'https://supermarket.chef.io'")
.and include("source 'http://chef.example2.com'")
end
end

describe '#delete' do
Expand Down

0 comments on commit be304a4

Please sign in to comment.