Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change over from ChefDK to ChefCLI #94

Merged
merged 2 commits into from
Jul 9, 2019
Merged
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
26 changes: 13 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PATH
specs:
chef-apply (0.3.2)
chef (>= 15.0)
chef-dk (>= 4.0)
chef-cli (>= 1.0.3)
chef-telemetry
license-acceptance (~> 1.0, >= 1.0.11)
mixlib-cli
Expand Down Expand Up @@ -33,11 +33,11 @@ GEM
debug_inspector (>= 0.0.1)
builder (3.2.3)
byebug (11.0.1)
chef (15.0.300)
chef (15.1.36)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is going out in a minor version bump of Chef Workstation, correct? Make sure we're not going to have multiple chef gem versions bundled

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This matches the version that we currently pull into ChefDK, which is where WS sources it from.

addressable
bcrypt_pbkdf (~> 1.0)
bundler (>= 1.10)
chef-config (= 15.0.300)
chef-config (= 15.1.36)
chef-zero (>= 14.0.11)
diff-lcs (~> 1.2, >= 1.2.4)
ed25519 (~> 1.2)
Expand All @@ -50,7 +50,7 @@ GEM
license-acceptance (~> 1.0, >= 1.0.5)
mixlib-archive (>= 0.4, < 2.0)
mixlib-authentication (~> 2.1)
mixlib-cli (>= 1.7, < 3.0)
mixlib-cli (>= 2.1.1, < 3.0)
mixlib-log (>= 2.0.3, < 4.0)
mixlib-shellout (>= 2.4, < 4.0)
net-sftp (~> 2.1, >= 2.1.2)
Expand All @@ -63,13 +63,7 @@ GEM
train-core (~> 2.0, >= 2.0.12)
tty-screen (~> 0.6)
uuidtools (~> 2.1.5)
chef-config (15.0.300)
addressable
fuzzyurl
mixlib-config (>= 2.2.12, < 4.0)
mixlib-shellout (>= 2.0, < 4.0)
tomlrb (~> 1.2)
chef-dk (4.0.60)
chef-cli (1.0.3)
addressable (>= 2.3.5, < 2.6)
chef (~> 15.0)
cookbook-omnifetch (~> 0.5)
Expand All @@ -81,6 +75,12 @@ GEM
mixlib-shellout (>= 2.0, < 4.0)
paint (~> 1.0)
solve (> 2.0, < 5.0)
chef-config (15.1.36)
addressable
fuzzyurl
mixlib-config (>= 2.2.12, < 4.0)
mixlib-shellout (>= 2.0, < 4.0)
tomlrb (~> 1.2)
chef-telemetry (0.1.8)
chef-config
concurrent-ruby (~> 1.0)
Expand All @@ -97,7 +97,7 @@ GEM
citrus (3.0.2)
coderay (1.1.2)
concurrent-ruby (1.1.5)
cookbook-omnifetch (0.8.1)
cookbook-omnifetch (0.9.0)
mixlib-archive (>= 0.4, < 2.0)
debug_inspector (0.0.3)
declarative (0.0.10)
Expand All @@ -107,7 +107,7 @@ GEM
docker-api (1.34.2)
excon (>= 0.47.0)
multi_json
domain_name (0.5.20180417)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
ed25519 (1.2.4)
equatable (0.6.1)
Expand Down
2 changes: 1 addition & 1 deletion chef-apply.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Gem::Specification.new do |spec|
spec.add_dependency "pastel" # A color library
spec.add_dependency "tty-spinner" # Pretty output for status updates in the CLI
spec.add_dependency "chef", ">= 15.0" # Needed to load cookbooks
spec.add_dependency "chef-dk", ">= 4.0"
spec.add_dependency "chef-cli", ">= 1.0.3 " # Policyfile
spec.add_dependency "chef-telemetry"
spec.add_dependency "license-acceptance", "~> 1.0", ">= 1.0.11"

Expand Down
12 changes: 6 additions & 6 deletions lib/chef_apply/action/generate_local_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,24 @@ def perform_action
exporter.run
@archive_file_location = exporter.archive_file_location
notify(:success)
rescue ChefDK::PolicyfileInstallError => e
rescue ChefCLI::PolicyfileInstallError => e
raise PolicyfileInstallError.new(e)
end

def exporter
require "chef-dk/policyfile_services/export_repo"
require "chef-cli/policyfile_services/export_repo"
@exporter ||=
ChefDK::PolicyfileServices::ExportRepo.new(policyfile: @cookbook.policyfile_lock_path,
ChefCLI::PolicyfileServices::ExportRepo.new(policyfile: @cookbook.policyfile_lock_path,
root_dir: @cookbook.path,
export_dir: @cookbook.export_path,
archive: true, force: true)
end

def installer
require "chef-dk/policyfile_services/install"
require "chef-dk/ui"
require "chef-cli/policyfile_services/install"
require "chef-cli/ui"
@installer ||=
ChefDK::PolicyfileServices::Install.new(ui: ChefDK::UI.null(), root_dir: @cookbook.path)
ChefCLI::PolicyfileServices::Install.new(ui: ChefCLI::UI.null(), root_dir: @cookbook.path)
end

end
Expand Down
22 changes: 11 additions & 11 deletions spec/unit/action/generate_local_policy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
#
require "spec_helper"
require "chef_apply/action/generate_local_policy"
require "chef-dk/policyfile_services/install"
require "chef-dk/ui"
require "chef-dk/policyfile_services/export_repo"
require "chef-cli/policyfile_services/install"
require "chef-cli/ui"
require "chef-cli/policyfile_services/export_repo"

RSpec.describe ChefApply::Action::GenerateLocalPolicy do
subject { ChefApply::Action::GenerateLocalPolicy.new(cookbook: cookbook) }
Expand All @@ -30,11 +30,11 @@
end

let(:installer_double) do
instance_double(ChefDK::PolicyfileServices::Install, run: :ok)
instance_double(ChefCLI::PolicyfileServices::Install, run: :ok)
end

let(:exporter_double) do
instance_double(ChefDK::PolicyfileServices::ExportRepo,
instance_double(ChefCLI::PolicyfileServices::ExportRepo,
archive_file_location: "/path/to/export",
run: :ok)
end
Expand Down Expand Up @@ -62,7 +62,7 @@
context "when PolicyfileServices raises an error" do
it "reraises as PolicyfileInstallError" do
expect(subject).to receive(:installer).and_return installer_double
expect(installer_double).to receive(:run).and_raise(ChefDK::PolicyfileInstallError.new("", nil))
expect(installer_double).to receive(:run).and_raise(ChefCLI::PolicyfileInstallError.new("", nil))
expect { subject.perform_action }.to raise_error(ChefApply::Action::PolicyfileInstallError)
end
end
Expand All @@ -72,15 +72,15 @@

# There is an issue with policyfile generation where, if we have a cookbook with too long
# of a name or directory name the policyfile will not generate. This is because the tar
# library that ChefDK uses comes from the Rubygems package and is meant for packaging
# library that ChefCLI uses comes from the Rubygems package and is meant for packaging
# gems up, so it can impose a 100 character limit. We attempt to solve this by ensuring
# that the paths/names we generate with `TempCookbook` are short.
#
# This is here for documentation
# 2018-05-18 mp addendum: this cna take upwards of 15s to run on ci nodes, pending
# for now since it's not testing any Chef Apply functionality.
xit "fails to create when there is a long path name" do
err = ChefDK::PolicyfileExportRepoError
err = ChefCLI::PolicyfileExportRepoError
expect { subject.perform_action }.to raise_error(err) do |e|
expect(e.cause.class).to eq(Gem::Package::TooLongFileName)
expect(e.cause.message).to match(/should be 100 or less/)
Expand All @@ -92,7 +92,7 @@
describe "#exporter" do

it "returns a correctly constructed ExportRepo" do
expect(ChefDK::PolicyfileServices::ExportRepo).to receive(:new)
expect(ChefCLI::PolicyfileServices::ExportRepo).to receive(:new)
.with(policyfile: cookbook.policyfile_lock_path,
root_dir: cookbook.path,
export_dir: cookbook.export_path,
Expand All @@ -104,8 +104,8 @@

describe "#installer" do
it "returns a correctly constructed Install service" do
expect(ChefDK::PolicyfileServices::Install).to receive(:new)
.with(ui: ChefDK::UI, root_dir: cookbook.path)
expect(ChefCLI::PolicyfileServices::Install).to receive(:new)
.with(ui: ChefCLI::UI, root_dir: cookbook.path)
.and_return(installer_double)
expect(subject.installer).to eq installer_double
end
Expand Down
4 changes: 1 addition & 3 deletions spec/unit/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
require "chef_apply/ui/terminal"
require "chef_apply/action/generate_temp_cookbook"

require "chef-dk/ui"
require "chef-dk/policyfile_services/export_repo"
require "chef-dk/policyfile_services/install"
require "chef-cli/ui"

RSpec.describe ChefApply::CLI do
subject { ChefApply::CLI.new(argv) }
Expand Down