summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2020-07-21 19:52:04 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2020-07-21 19:52:04 -0700
commiteea6d8b2f711225ec266206cbedeff4c147aedb0 (patch)
tree8ceaf0f324920ed8faa3b1baddc93d7037b063e0
parent1cc00a22a6b5cdcabb64644ec322c82adafa7681 (diff)
downloadchef-lcg/extract-mixlib-shellout.tar.gz
clean up the chefutils wiring with a common helper classlcg/extract-mixlib-shellout
also fixes a FIXME in the YARD Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r--chef-utils/lib/chef-utils/internal.rb4
-rw-r--r--lib/chef/dsl/platform_introspection.rb9
-rw-r--r--lib/chef/mixin/chef_utils_wiring.rb40
-rw-r--r--lib/chef/mixin/shell_out.rb17
-rw-r--r--lib/chef/mixin/which.rb7
-rw-r--r--lib/chef/platform/service_helpers.rb16
6 files changed, 50 insertions, 43 deletions
diff --git a/chef-utils/lib/chef-utils/internal.rb b/chef-utils/lib/chef-utils/internal.rb
index 6986b5250a..aa52005912 100644
--- a/chef-utils/lib/chef-utils/internal.rb
+++ b/chef-utils/lib/chef-utils/internal.rb
@@ -75,9 +75,9 @@ module ChefUtils
end
end
- # This should be set to a Train::FIXME instance. You should wire this up to nil for not using a train transport connection.
+ # This should be set to a Train::Plugins::Transport instance. You should wire this up to nil for not using a train transport connection.
#
- # @return [Train::FIXME]
+ # @return [Train::Plugins::Transport]
#
# @api private
#
diff --git a/lib/chef/dsl/platform_introspection.rb b/lib/chef/dsl/platform_introspection.rb
index 4cf381c037..8755644689 100644
--- a/lib/chef/dsl/platform_introspection.rb
+++ b/lib/chef/dsl/platform_introspection.rb
@@ -17,6 +17,7 @@
#
require "chef-utils" unless defined?(ChefUtils::CANARY)
+require "chef/mixin/chef_utils_wiring" unless defined?(Chef::Mixin::ChefUtilsWiring)
class Chef
module DSL
@@ -25,6 +26,7 @@ class Chef
# #value_for_platform.
module PlatformIntrospection
include ChefUtils
+ include Chef::Mixin::ChefUtilsWiring
# Implementation class for determining platform dependent values
class PlatformDependentValue
@@ -258,13 +260,6 @@ class Chef
# ^^^^^^ NOTE: PLEASE DO NOT CONTINUE TO ADD THESE KINDS OF PLATFORM_VERSION APIS WITHOUT ^^^^^^^
# ^^^^^^ GOING THROUGH THE DESIGN REVIEW PROCESS AND ADDRESS THE EXISTING CHEF-SUGAR ONES ^^^^^^^
# ^^^^^^ DO "THE HARD RIGHT THING" AND ADDRESS THE BROADER PROBLEM AND FIX IT ALL. ^^^^^^^
-
- private
-
- # dependency injection, see: ChefUtils::Internal
- def __transport_connection
- Chef.run_context.transport_connection
- end
end
end
end
diff --git a/lib/chef/mixin/chef_utils_wiring.rb b/lib/chef/mixin/chef_utils_wiring.rb
new file mode 100644
index 0000000000..938520059c
--- /dev/null
+++ b/lib/chef/mixin/chef_utils_wiring.rb
@@ -0,0 +1,40 @@
+#--
+# Copyright:: Copyright (c) Chef Software 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_relative "../log"
+require_relative "../config"
+require_relative "../chef_class"
+
+class Chef
+ module Mixin
+ # Common Dependency Injection wiring for ChefUtils-related modules
+ module ChefUtilsWiring
+ private
+
+ def __config
+ Chef::Config
+ end
+
+ def __log
+ Chef::Log
+ end
+
+ def __transport_connection
+ Chef.run_context&.transport_connection
+ end
+ end
+ end
+end
diff --git a/lib/chef/mixin/shell_out.rb b/lib/chef/mixin/shell_out.rb
index e136fe09ba..c3eacc57f0 100644
--- a/lib/chef/mixin/shell_out.rb
+++ b/lib/chef/mixin/shell_out.rb
@@ -16,26 +16,13 @@
# limitations under the License.
require "mixlib/shellout/helper" unless defined?(Mixlib::ShellOut::Helper)
-require_relative "../log"
-require_relative "../config"
-require_relative "../chef_class"
+require "chef/mixin/chef_utils_wiring" unless defined?(Chef::Mixin::ChefUtilsWiring)
class Chef
module Mixin
module ShellOut
include Mixlib::ShellOut::Helper
-
- def __config
- Chef::Config
- end
-
- def __log
- Chef::Log
- end
-
- def __transport_connection
- Chef.run_context&.transport_connection
- end
+ include Chef::Mixin::ChefUtilsWiring
end
end
end
diff --git a/lib/chef/mixin/which.rb b/lib/chef/mixin/which.rb
index 2e6fd13b68..01357d76a5 100644
--- a/lib/chef/mixin/which.rb
+++ b/lib/chef/mixin/which.rb
@@ -17,12 +17,14 @@
require "chef-utils/dsl/which" unless defined?(ChefUtils::DSL::Which)
require "chef-utils/dsl/path_sanity" unless defined?(ChefUtils::DSL::PathSanity)
+require "chef/mixin/chef_utils_wiring" unless defined?(Chef::Mixin::ChefUtilsWiring)
class Chef
module Mixin
module Which
include ChefUtils::DSL::Which
include ChefUtils::DSL::PathSanity
+ include ChefUtilsWiring
private
@@ -32,11 +34,6 @@ class Chef
def __extra_path
__sane_paths
end
-
- # dependency injection, see: ChefUtils::Internal
- def __transport_connection
- Chef.run_context&.transport_connection
- end
end
end
end
diff --git a/lib/chef/platform/service_helpers.rb b/lib/chef/platform/service_helpers.rb
index 456e679e03..627fd8d694 100644
--- a/lib/chef/platform/service_helpers.rb
+++ b/lib/chef/platform/service_helpers.rb
@@ -18,11 +18,13 @@
require_relative "../chef_class"
require "chef-utils" unless defined?(ChefUtils::CANARY)
+require "chef/mixin/chef_utils_wiring" unless defined?(Chef::Mixin::ChefUtilsWiring)
class Chef
class Platform
module ServiceHelpers
include ChefUtils::DSL::Service
+ include Chef::Mixin::ChefUtilsWiring
def service_resource_providers
providers = []
@@ -49,20 +51,6 @@ class Chef
configs
end
- private
-
- def __config
- Chef::Config
- end
-
- def __log
- Chef::Log
- end
-
- def __transport_connection
- Chef.run_context&.transport_connection
- end
-
extend self
end
end