module Chef::Telemetry::Decision

Constants

OPT_IN_FILE
OPT_OUT_FILE

Public Class Methods

env_opt_out?() click to toggle source
# File lib/chef/telemetry/decision.rb, line 30
def env_opt_out?
  ENV.key?("CHEF_TELEMETRY_OPT_OUT")
end
local_opt_out?() click to toggle source
# File lib/chef/telemetry/decision.rb, line 34
def local_opt_out?
  found = false
  full_path = working_directory.split(File::SEPARATOR)
  (full_path.length - 1).downto(0) do |i|
    candidate = File.join(full_path[0..i], ".chef", OPT_OUT_FILE)
    if File.exist?(candidate)
      # TODO: push up logging
      # Log.info "Found opt out at: #{candidate}"
      found = true
      break
    end
  end
  found
end
made?() click to toggle source

Check whether the user has made an explicit decision on their participation.

# File lib/chef/telemetry/decision.rb, line 18
def made?
  user_opted_in? || user_opted_out?
end
opt_out?() click to toggle source
# File lib/chef/telemetry/decision.rb, line 12
def opt_out?
  # We check that the user has made a decision so that we can have a default setting for robots
  user_opted_out? || env_opt_out? || local_opt_out? || !made?
end
user_opted_in?() click to toggle source
# File lib/chef/telemetry/decision.rb, line 26
def user_opted_in?
  File.exist?(File.join(home, OPT_IN_FILE))
end
user_opted_out?() click to toggle source
# File lib/chef/telemetry/decision.rb, line 22
def user_opted_out?
  File.exist?(File.join(home, OPT_OUT_FILE))
end

Private Class Methods

home() click to toggle source
# File lib/chef/telemetry/decision.rb, line 61
def home
  ChefConfig::PathHelper.home(".chef")
end
working_directory() click to toggle source
# File lib/chef/telemetry/decision.rb, line 51
def working_directory
  a = if ChefConfig.windows?
        ENV["CD"]
      else
        ENV["PWD"]
      end || Dir.pwd

  a
end