This repository has been archived by the owner on Dec 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Add brew-boxen-cask-install #57
Open
n0ts
wants to merge
14
commits into
boxen:master
Choose a base branch
from
n0ts:topic-brewcask
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
ac7fec7
Add brew-boxen-cask-install
n0ts a7e1432
Add class comment
n0ts 83593ec
Merge branch 'master' into topic-brewcask
n0ts db7ae4c
Merge branch 'master' into topic-brewcask
n0ts fb0828c
Fix feedback
n0ts bd4c3d2
Update README
n0ts b199806
Add provider test
n0ts 039c8bc
Changed test cask name
n0ts 2d011bc
CI os change to osx
n0ts 3ab67cd
Remove OS
jacobbednarz c549f1c
Fix tests
n0ts 58a491c
Update Gemfile.lock
n0ts f3a0cd8
Update cardboard
n0ts 903a127
Add tap caskroom/cask
n0ts File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
$LOAD_PATH.unshift("#{HOMEBREW_LIBRARY_PATH}/cask/lib") | ||
require "hbc" | ||
|
||
Hbc::CLI::Install.new(ARGV).run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
require "puppet/provider/package" | ||
require "puppet/util/execution" | ||
require 'puppet/provider/package' | ||
require 'puppet/util/execution' | ||
|
||
Puppet::Type.type(:package).provide :brewcask, :parent => Puppet::Provider::Package do | ||
include Puppet::Util::Execution | ||
|
@@ -45,15 +45,20 @@ def query | |
end | ||
|
||
def install | ||
install_cmd = ['brew'] | ||
if install_options.any? | ||
execute ["brew", "install", "Caskroom/cask/#{resource[:name]}", *install_options].flatten, command_opts | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
install_cmd << 'cask install' | ||
install_cmd << install_options | ||
else | ||
execute ["brew", "boxen-install", "Caskroom/cask/#{resource[:name]}"], command_opts | ||
install_cmd << 'boxen-cask-install' | ||
end | ||
install_cmd << resource[:name] | ||
|
||
execute install_cmd.flatten, command_opts | ||
end | ||
|
||
def uninstall | ||
execute ["brew", "cask", "uninstall", "--force", resource[:name]] | ||
execute ['brew', 'cask', 'uninstall', '--force', resource[:name]] | ||
end | ||
|
||
def install_options | ||
|
@@ -86,18 +91,18 @@ def self.execute(*args) | |
end | ||
|
||
def default_user | ||
Facter.value(:boxen_user) || Facter.value(:id) || "root" | ||
Facter.value(:boxen_user) || Facter.value(:id) || 'root' | ||
end | ||
|
||
def command_opts | ||
opts = { | ||
:combine => true, | ||
:custom_environment => { | ||
"HOME" => "/Users/#{default_user}", | ||
"PATH" => "#{self.class.home}/bin:/usr/bin:/usr/sbin:/bin:/sbin", | ||
"HOMEBREW_NO_EMOJI" => "Yes", | ||
:combine => true, | ||
:custom_environment => { | ||
'HOME' => "/Users/#{default_user}", | ||
'PATH' => "#{self.class.home}/bin:/usr/bin:/usr/sbin:/bin:/sbin", | ||
'HOMEBREW_NO_EMOJI' => 'Yes', | ||
}, | ||
:failonfail => true, | ||
:failonfail => true, | ||
} | ||
# Only try to run as another user if Puppet is run as root. | ||
opts[:uid] = default_user if Process.uid == 0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
require "rspec-puppet" | ||
require 'rspec-puppet' | ||
|
||
fixture_path = File.expand_path File.join(__FILE__, "..", "fixtures") | ||
fixture_path = File.expand_path File.join(__FILE__, '..', 'fixtures') | ||
|
||
RSpec.configure do |c| | ||
c.manifest_dir = File.join(fixture_path, "manifests") | ||
c.module_path = File.join(fixture_path, "modules") | ||
c.manifest_dir = File.join(fixture_path, 'manifests') | ||
c.module_path = File.join(fixture_path, 'modules') | ||
end | ||
|
||
def default_test_facts | ||
{ | ||
:boxen_home => "/test/boxen", | ||
:boxen_srcdir => "/test/boxen/src", | ||
:boxen_user => "testuser", | ||
:boxen_home => '/test/boxen', | ||
:boxen_srcdir => '/test/boxen/src', | ||
:boxen_user => 'testuser', | ||
} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
require 'spec_helper' | ||
|
||
provider = Puppet::Type.type(:package).provider(:brewcask) | ||
|
||
describe provider do | ||
it 'should have an install method' do | ||
is_expected.to respond_to(:install) | ||
end | ||
|
||
it 'should have a uninstall method' do | ||
is_expected.to respond_to(:uninstall) | ||
end | ||
|
||
it 'should not have a latst method' do | ||
is_expected.not_to respond_to(:latest) | ||
end | ||
|
||
it 'should not have a update method' do | ||
is_expected.not_to respond_to(:update) | ||
end | ||
|
||
describe 'when installing' do | ||
context 'installing cask without install options' do | ||
before do | ||
@resource = Puppet::Type.type(:package).new( | ||
:name => 'cask', | ||
:ensure => :present, | ||
:provider => :brewcask, | ||
) | ||
@provider = provider.new(@resource) | ||
end | ||
|
||
it 'should return install command' do | ||
expect{ @provider.install }.to raise_error(Puppet::ExecutionFailure, | ||
/brew boxen-cask-install cask/) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. brew command is failed, so I check exception message command name. |
||
end | ||
|
||
it 'should return nil query' do | ||
expect(@provider.query).to eq(nil) | ||
end | ||
end | ||
|
||
context 'installing cask with install options' do | ||
before do | ||
@resource = Puppet::Type.type(:package).new( | ||
:name => 'cask', | ||
:ensure => :present, | ||
:provider => :brewcask, | ||
:install_options => '--foo', | ||
) | ||
@provider = provider.new(@resource) | ||
end | ||
|
||
it 'should return install command with install options' do | ||
expect { @provider.install }.to raise_error(Puppet::ExecutionFailure, | ||
/brew cask install --foo cask/) | ||
end | ||
end | ||
end | ||
|
||
describe 'when uninstalling' do | ||
before do | ||
@resource = Puppet::Type.type(:package).new( | ||
:name => 'cask', | ||
:ensure => :present, | ||
:provider => :brewcask, | ||
) | ||
@provider = provider.new(@resource) | ||
end | ||
|
||
it 'should return uninstall command' do | ||
expect { @provider.uninstall }.to raise_error(Puppet::ExecutionFailure, | ||
/brew cask uninstall --force cask/) | ||
end | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this wasn't you but can you delete this section? I don't think it really adds any value or information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I same as puppuet-homebrew/README