Module: Chef::ResourceHelpers::PathHelpers
- Extended by:
- PathHelpers
- Includes:
- Mixin::Which
- Included in:
- Chef::Resource::ChefClientCron, Chef::Resource::ChefClientLaunchd, Chef::Resource::ChefClientScheduledTask, Chef::Resource::ChefClientSystemdTimer, PathHelpers
- Defined in:
- lib/chef/resource/helpers/path_helpers.rb
Overview
Helpers for path manipulation
Instance Method Summary collapse
-
#chef_client_hab_binary_path ⇒ String
This method returns the absolute path to the chef-client binary that is currently executing.
-
#chef_client_hab_package_binary_path ⇒ Object
once the binstubs under hab package have been fixed, restore this as the chef_client_hab_binary_path method.
- #hab_executable_binary_path ⇒ Object
Instance Method Details
#chef_client_hab_binary_path ⇒ String
This method returns the absolute path to the chef-client binary that is currently executing. In a Habitat environment, you might have multiple versions of chef-client installed, we want to ensure we get the path to the one currently running.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/chef/resource/helpers/path_helpers.rb', line 21 def chef_client_hab_binary_path path = File.realpath($PROGRAM_NAME) bin = File.basename(path) # On Windows, temporarily use the c:\\hab\\bin\\*.bat binstubs bat_path = "C:\\hab\\bin\\#{bin}.bat" return bat_path if File.exist?(bat_path) && ChefUtils.windows? return path if bin == "#{ChefUtils::Dist::Infra::CLIENT}" # Return empty string if no valid path is found "" end |
#chef_client_hab_package_binary_path ⇒ Object
once the binstubs under hab package have been fixed, restore this as the chef_client_hab_binary_path method
36 37 38 39 40 41 42 43 44 |
# File 'lib/chef/resource/helpers/path_helpers.rb', line 36 def chef_client_hab_package_binary_path path = File.realpath($PROGRAM_NAME) bin = File.basename(path) return path if bin == "#{ChefUtils::Dist::Infra::CLIENT}" # Return empty string if no valid path is found "" end |
#hab_executable_binary_path ⇒ Object
46 47 48 49 |
# File 'lib/chef/resource/helpers/path_helpers.rb', line 46 def hab_executable_binary_path # Find hab in PATH which("hab") || "" end |