summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2020-04-08 20:29:39 -0700
committerGitHub <noreply@github.com>2020-04-08 20:29:39 -0700
commite5caab7de9726d280e12bb593b6d8c3ce6afa177 (patch)
tree7a9852a87dc43617d0068fa150c496846b583698
parent590831eae3826420a80f9df8843d40663fd879de (diff)
parentf069a87d9e29bc1e0b115f3d1359e0372ad74d1d (diff)
downloadchef-e5caab7de9726d280e12bb593b6d8c3ce6afa177.tar.gz
Merge pull request #9634 from chef/lcg/fix-bootstrap-cli-options
Fix knife bootstrap_version CLI option overriding config option
-rw-r--r--lib/chef/knife/bootstrap.rb5
-rw-r--r--lib/chef/knife/core/bootstrap_context.rb6
-rw-r--r--spec/unit/knife/core/bootstrap_context_spec.rb4
3 files changed, 8 insertions, 7 deletions
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb
index 82fa5971b8..3785fa9c17 100644
--- a/lib/chef/knife/bootstrap.rb
+++ b/lib/chef/knife/bootstrap.rb
@@ -1,6 +1,6 @@
#
# Author:: Adam Jacob (<adam@chef.io>)
-# Copyright:: Copyright 2010-2019, Chef Software Inc.
+# Copyright:: Copyright 2010-2020, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -149,8 +149,7 @@ class Chef
# client.rb content via chef-full/bootstrap_context
option :bootstrap_version,
long: "--bootstrap-version VERSION",
- description: "The version of #{Chef::Dist::PRODUCT} to install.",
- proc: lambda { |v| Chef::Config[:knife][:bootstrap_version] = v }
+ description: "The version of #{Chef::Dist::PRODUCT} to install."
option :channel,
long: "--channel CHANNEL",
diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb
index 8f07149ebe..f889e7b7ed 100644
--- a/lib/chef/knife/core/bootstrap_context.rb
+++ b/lib/chef/knife/core/bootstrap_context.rb
@@ -1,6 +1,6 @@
#
# Author:: Daniel DeLeo (<dan@chef.io>)
-# Copyright:: Copyright 2011-2016, Chef Software, Inc.
+# Copyright:: Copyright 2011-2020, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -194,6 +194,8 @@ class Chef
s
end
+ # XXX: this reads values only out of the config file and is NOT merged with the CLI options, and it is most likely
+ # a bug to be using this accessor and we should be using config and not knife_config.
def knife_config
@chef_config.key?(:knife) ? @chef_config[:knife] : {}
end
@@ -203,7 +205,7 @@ class Chef
#
# @return [String] download version string
def version_to_install
- return knife_config[:bootstrap_version] if knife_config[:bootstrap_version]
+ return @config[:bootstrap_version] if @config[:bootstrap_version]
if @config[:channel] == "stable"
Chef::VERSION.split(".").first
diff --git a/spec/unit/knife/core/bootstrap_context_spec.rb b/spec/unit/knife/core/bootstrap_context_spec.rb
index 99035eff4e..7ddb981aba 100644
--- a/spec/unit/knife/core/bootstrap_context_spec.rb
+++ b/spec/unit/knife/core/bootstrap_context_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Daniel DeLeo (<dan@chef.io>)
-# Copyright:: Copyright 2011-2016, Chef Software Inc.
+# Copyright:: Copyright 2011-2020, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -297,7 +297,7 @@ describe Chef::Knife::Core::BootstrapContext do
describe "#version_to_install" do
context "when bootstrap_version is provided" do
- let(:chef_config) { { knife: { bootstrap_version: "awesome" } } }
+ let(:config) { { bootstrap_version: "awesome" } }
it "returns bootstrap_version" do
expect(bootstrap_context.version_to_install).to eq "awesome"