summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md24
-rw-r--r--chef-config/lib/chef-config/config.rb13
-rw-r--r--chef-config/spec/unit/config_spec.rb6
-rw-r--r--lib/chef/chef_fs/file_system/cookbook_subdir.rb5
-rw-r--r--lib/chef/knife/ssh.rb2
-rw-r--r--spec/unit/chef_fs/file_system/cookbook_subdir_spec.rb34
6 files changed, 69 insertions, 15 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 63023acbe7..12ac806780 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,11 +4,11 @@
* [**Dave Eddy**](https://github.com/bahamas10)
[pr#3187](https://github.com/chef/chef/pull/3187) overhaul solaris SMF service provider
* [**Mikhail Zholobov**](https://github.com/legal90)
- [pr#3192](https://github.com/chef/chef/pull/3192) provider/user/dscl: Set default gid to 20
-* [**Mikhail Zholobov**](https://github.com/legal90)
- [pr#3193](https://github.com/chef/chef/pull/3193) provider/user/dscl: Set "comment" default value
+ - [pr#3192](https://github.com/chef/chef/pull/3192) provider/user/dscl: Set default gid to 20
+ - [pr#3193](https://github.com/chef/chef/pull/3193) provider/user/dscl: Set "comment" default value
* [**Jordan Evans**](https://github.com/jordane)
- [pr#3263](https://github.com/chef/chef/pull/3263) `value_for_platform` should use `Chef::VersionConstraint::Platform`
+ - [pr#3263](https://github.com/chef/chef/pull/3263) `value_for_platform` should use `Chef::VersionConstraint::Platform`
+ - [pr#3633](https://github.com/chef/chef/pull/3633) add the word group to `converge_by` call for group provider
* [**Scott McGillivray**](https://github.com/thechile)
[pr#3450](https://github.com/chef/chef/pull/3450) Fix 'knife cookbook show' to work on root files
* [**Aubrey Holland**](https://github.com/aub)
@@ -18,27 +18,27 @@
* [**Michael Pereira**](https://github.com/MichaelPereira)
[pr#3968](https://github.com/chef/chef/pull/3968) Fix cookbook installation from supermarket on windows
* [**Yukihiko SAWANOBORI**](https://github.com/sawanoboly)
- [pr#3941](https://github.com/chef/chef/pull/3941) allow reboot by reboot resource with chef-apply
+ - [pr#3941](https://github.com/chef/chef/pull/3941) allow reboot by reboot resource with chef-apply
+ - [pr#3900](https://github.com/chef/chef/pull/3900) Add new option json attributes file to bootstraping
* [**permyakovsv**](https://github.com/permyakovsv)
[pr#3901](https://github.com/chef/chef/pull/3901) Add tmux-split parameter to knife ssh
-* [**Yukihiko SAWANOBORI**](https://github.com/sawanoboly)
- [pr#3900](https://github.com/chef/chef/pull/3900) Add new option json attributes file to bootstraping
* [**Evan Gilman**](https://github.com/evan2645)
[pr#3864](https://github.com/chef/chef/pull/3864) Knife `bootstrap_environment` should use Explicit config before Implicit
* [**Ranjib Dey**](https://github.com/ranjib)
[pr#3834](https://github.com/chef/chef/pull/3834) Dont spit out stdout and stderr for execute resource failure, if its declared sensitive
* [**Jeff Blaine**](https://github.com/jblaine)
- [pr#3776](https://github.com/chef/chef/pull/3776) Changes --hide-healthy to --hide-by-mins MINS
+ - [pr#3776](https://github.com/chef/chef/pull/3776) Changes --hide-healthy to --hide-by-mins MINS
+ - [pr#3848](https://github.com/chef/chef/pull/3848) Migrate to --ssh-identity-file instead of --identity-file
* [**dbresson**](https://github.com/dbresson)
[pr#3650](https://github.com/chef/chef/pull/3650) Define == for node objects
-* [**Jordan Evans**](https://github.com/jordane)
- [pr#3633](https://github.com/chef/chef/pull/3633) add the word group to `converge_by` call for group provider
* [**Patrick Connolly**](https://github.com/patcon)
[pr#3529](https://github.com/chef/chef/pull/3529) Allow user@hostname format for knife-bootstrap
* [**Justin Seubert**](https://github.com/dude051)
[pr#4160](https://github.com/chef/chef/pull/4160) Correcting regex for upstart_state
-* [**Jeff Blaine**](https://github.com/jblaine)
- [pr#3848](https://github.com/chef/chef/pull/3848) Migrate to --ssh-identity-file instead of --identity-file
+* [**Sarah Michaelson**](https://github.com/skmichaelson)
+ [pr#3810](https://github.com/chef/chef/pull/3810) GH-1909 Add validation for chef_server_url
+* [**Maxime Brugidou**](https://github.com/brugidou)
+ [pr#4052](https://github.com/chef/chef/pull/4052) Add make_child_entry in ChefFS CookbookSubdir
* [pr#4185](https://github.com/chef/chef/pull/4185) dpkg provider cleanup
* [pr#4165](https://github.com/chef/chef/pull/4165) Multipackage internal API improvements
diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb
index 4e9355192a..49d775232d 100644
--- a/chef-config/lib/chef-config/config.rb
+++ b/chef-config/lib/chef-config/config.rb
@@ -76,12 +76,21 @@ module ChefConfig
default :formatters, []
+ def self.is_valid_url? uri
+ url = uri.to_s.strip
+ /^http:\/\// =~ url || /^https:\/\// =~ url || /^chefzero:/ =~ url
+ end
# Override the config dispatch to set the value of multiple server options simultaneously
#
# === Parameters
# url<String>:: String to be set for all of the chef-server-api URL's
#
- configurable(:chef_server_url).writes_value { |url| url.to_s.strip }
+ configurable(:chef_server_url).writes_value do |uri|
+ unless is_valid_url? uri
+ raise ConfigurationError, "#{uri} is an invalid chef_server_url."
+ end
+ uri.to_s.strip
+ end
# When you are using ActiveSupport, they monkey-patch 'daemonize' into Kernel.
# So while this is basically identical to what method_missing would do, we pull
@@ -303,7 +312,7 @@ module ChefConfig
default :host, 'localhost'
default :port, 8889.upto(9999) # Will try ports from 8889-9999 until one works
end
- default :chef_server_url, "https://localhost:443"
+ default :chef_server_url, "https://localhost:443"
default(:chef_server_root) do
# if the chef_server_url is a path to an organization, aka
diff --git a/chef-config/spec/unit/config_spec.rb b/chef-config/spec/unit/config_spec.rb
index 8e9a499a1a..4af5d4b7c7 100644
--- a/chef-config/spec/unit/config_spec.rb
+++ b/chef-config/spec/unit/config_spec.rb
@@ -60,6 +60,12 @@ RSpec.describe ChefConfig::Config do
expect(ChefConfig::Config.chef_server_url).to eq("https://junglist.gen.nz")
end
end
+
+ context "when the url is invalid" do
+ it "raises an exception" do
+ expect { ChefConfig::Config.chef_server_url = "127.0.0.1" }.to raise_error(ChefConfig::ConfigurationError)
+ end
+ end
end
describe "when configuring formatters" do
diff --git a/lib/chef/chef_fs/file_system/cookbook_subdir.rb b/lib/chef/chef_fs/file_system/cookbook_subdir.rb
index 73c709e01e..e7a6d3bccd 100644
--- a/lib/chef/chef_fs/file_system/cookbook_subdir.rb
+++ b/lib/chef/chef_fs/file_system/cookbook_subdir.rb
@@ -45,6 +45,11 @@ class Chef
true
end
+ def make_child_entry(name)
+ result = @children.select { |child| child.name == name }.first if @children
+ result || NonexistentFSObject.new(name, self)
+ end
+
def rest
parent.rest
end
diff --git a/lib/chef/knife/ssh.rb b/lib/chef/knife/ssh.rb
index fcffb718f5..99ae2f426a 100644
--- a/lib/chef/knife/ssh.rb
+++ b/lib/chef/knife/ssh.rb
@@ -16,6 +16,7 @@
# limitations under the License.
#
+require 'chef/mixin/shell_out'
require 'chef/knife'
class Chef
@@ -29,7 +30,6 @@ class Chef
require 'readline'
require 'chef/exceptions'
require 'chef/search/query'
- require 'chef/mixin/shell_out'
require 'chef/mixin/command'
require 'chef/util/path_helper'
require 'mixlib/shellout'
diff --git a/spec/unit/chef_fs/file_system/cookbook_subdir_spec.rb b/spec/unit/chef_fs/file_system/cookbook_subdir_spec.rb
new file mode 100644
index 0000000000..94a636fc0a
--- /dev/null
+++ b/spec/unit/chef_fs/file_system/cookbook_subdir_spec.rb
@@ -0,0 +1,34 @@
+#
+# Author:: John Keiser (<jkeiser@opscode.com>)
+# Copyright:: Copyright (c) 2012 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'spec_helper'
+require 'chef/chef_fs/file_system/cookbook_subdir'
+
+describe Chef::ChefFS::FileSystem::CookbookSubdir do
+ let(:root) do
+ Chef::ChefFS::FileSystem::BaseFSDir.new('', nil)
+ end
+
+ let(:cookbook_subdir) do
+ Chef::ChefFS::FileSystem::CookbookSubdir.new('test', root, false, true)
+ end
+
+ it 'can get child' do
+ cookbook_subdir.child('test')
+ end
+end