diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2019-11-08 14:06:33 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2019-11-08 14:06:33 -0800 |
commit | 8a7e29d52882c39d0c903eef83bd3472e4f334af (patch) | |
tree | a25a7b76416e07ebdb54e569fb0006079cf012db /lib/chef/chef_fs | |
parent | c31625406530b560fab02b11fa2447955ed2faef (diff) | |
download | chef-8a7e29d52882c39d0c903eef83bd3472e4f334af.tar.gz |
Add chef-utils gem with various recipe DSL helpers
This is the implementation of [RFC-087](https://github.com/chef-boneyard/chef-rfc/blob/master/rfc087-distro-sugar-helpers.md)
although some of the specifics have been iterated on and changed.
The documentation will be in the [README.md](https://github.com/chef/chef/tree/master/chef-utils/README.md) once this is merged.
While this PR mostly moves chef-sugar utilities into core-chef via this chef-utils gem, the scope of the chef-utils gem
should be considered larger than just that. As an example this PR moves the Mash class into this gem for reuse in ohai
as well.
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/chef_fs')
7 files changed, 12 insertions, 12 deletions
diff --git a/lib/chef/chef_fs/file_pattern.rb b/lib/chef/chef_fs/file_pattern.rb index f4889fbd86..32c5e80bac 100644 --- a/lib/chef/chef_fs/file_pattern.rb +++ b/lib/chef/chef_fs/file_pattern.rb @@ -245,7 +245,7 @@ class Chef end def self.pattern_special_characters - if Chef::ChefFS.windows? + if ChefUtils.windows? @pattern_special_characters ||= /(\*\*|\*|\?|[\*\?\.\|\(\)\[\]\{\}\+\\\\\^\$])/ else # Unix also supports character regexes and backslashes diff --git a/lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb b/lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb index c99c689a71..974bbc91fd 100644 --- a/lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb +++ b/lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb @@ -86,7 +86,7 @@ class Chef # the symlink without removing the original contents if we # are running on windows # - if Chef::Platform.windows? + if ChefUtils.windows? Dir.rmdir proxy_cookbook_path end end diff --git a/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb b/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb index 739a42b124..9a65f70f33 100644 --- a/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb +++ b/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb @@ -91,7 +91,7 @@ class Chef # the symlink without removing the original contents if we # are running on windows # - if Chef::Platform.windows? + if ChefUtils.windows? Dir.rmdir proxy_cookbook_path end end diff --git a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb index de1f071fb3..f156faf817 100644 --- a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +++ b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb @@ -1,6 +1,6 @@ # # Author:: John Keiser (<jkeiser@chef.io>) -# Copyright:: Copyright 2012-2016, Chef Software, Inc. +# Copyright:: Copyright 2012-2019, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -44,7 +44,7 @@ require_relative "../../data_handler/role_data_handler" require_relative "../../data_handler/user_data_handler" require_relative "../../data_handler/group_data_handler" require_relative "../../data_handler/container_data_handler" -require_relative "../../../win32/security" if Chef::Platform.windows? +require_relative "../../../win32/security" if ChefUtils.windows? class Chef module ChefFS @@ -112,7 +112,7 @@ class Chef begin ::FileUtils.mkdir_p(path) ::FileUtils.chmod(0700, path) - if Chef::Platform.windows? + if ChefUtils.windows? all_mask = Chef::ReservedNames::Win32::API::Security::GENERIC_ALL administrators = Chef::ReservedNames::Win32::Security::SID.Administrators owner = Chef::ReservedNames::Win32::Security::SID.default_security_object_owner diff --git a/lib/chef/chef_fs/file_system/repository/nodes_dir.rb b/lib/chef/chef_fs/file_system/repository/nodes_dir.rb index 3edd442121..56118ffcd1 100644 --- a/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +++ b/lib/chef/chef_fs/file_system/repository/nodes_dir.rb @@ -1,7 +1,7 @@ # # Author:: John Keiser (<jkeiser@chef.io>) # Author:: Ho-Sheng Hsiao (<hosh@chef.io>) -# Copyright:: Copyright 2012-2016, Chef Software Inc. +# Copyright:: Copyright 2012-2019, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,7 +20,7 @@ require_relative "node" require_relative "directory" require_relative "../exceptions" -require_relative "../../../win32/security" if Chef::Platform.windows? +require_relative "../../../win32/security" if ChefUtils.windows? class Chef module ChefFS @@ -35,7 +35,7 @@ class Chef def create_child(child_name, file_contents = nil) child = super File.chmod(0600, child.file_path) - if Chef::Platform.windows? + if ChefUtils.windows? read_mask = Chef::ReservedNames::Win32::API::Security::GENERIC_READ write_mask = Chef::ReservedNames::Win32::API::Security::GENERIC_WRITE administrators = Chef::ReservedNames::Win32::Security::SID.Administrators diff --git a/lib/chef/chef_fs/knife.rb b/lib/chef/chef_fs/knife.rb index 288acac10a..84301c92e4 100644 --- a/lib/chef/chef_fs/knife.rb +++ b/lib/chef/chef_fs/knife.rb @@ -18,7 +18,7 @@ require_relative "../knife" require "pathname" unless defined?(Pathname) -require "chef/dist" +require_relative "../dist" class Chef module ChefFS diff --git a/lib/chef/chef_fs/path_utils.rb b/lib/chef/chef_fs/path_utils.rb index c490f50c17..b894359e2a 100644 --- a/lib/chef/chef_fs/path_utils.rb +++ b/lib/chef/chef_fs/path_utils.rb @@ -58,7 +58,7 @@ class Chef end def self.regexp_path_separator - Chef::ChefFS.windows? ? '[\/\\\\]' : "/" + ChefUtils.windows? ? '[\/\\\\]' : "/" end # Given a server path, determines if it is absolute. @@ -103,7 +103,7 @@ class Chef # Compares two path fragments according to the case-sentitivity of the host platform. def self.os_path_eq?(left, right) - Chef::ChefFS.windows? ? left.casecmp(right) == 0 : left == right + ChefUtils.windows? ? left.casecmp(right) == 0 : left == right end # Given two general OS-dependent file paths, determines the relative path of the |