Skip to content

Commit

Permalink
Merge pull request #241 from jpogran/revert-gh-238
Browse files Browse the repository at this point in the history
Revert "(GH-238) Monkey patch Facter for minimal resets"
  • Loading branch information
glennsarti authored Apr 23, 2020
2 parents 339c42f + 882fa21 commit f2e758e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 25 deletions.
1 change: 0 additions & 1 deletion lib/puppet-languageserver-sidecar/facter_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def self.retrieve_facts(_cache, _options = {})
facts = PuppetLanguageServer::Sidecar::Protocol::FactList.new
begin
req = Puppet::Indirector::Request.new(:facts, :find, 'language_server', nil, environment: current_environment)
Facter.monkey_allow_reset # This is a monkey patched method onto Facter
result = Puppet::Node::Facts::Facter.new.find(req)
result.values.each do |key, value|
# TODO: This isn't strictly correct e.g. fully qualified facts will look a bit odd.
Expand Down
24 changes: 0 additions & 24 deletions lib/puppet-languageserver-sidecar/puppet_monkey_patches.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,30 +80,6 @@ def newtype(name, options = {}, &block)
end
end

# Due to Facter 4.0.16 calling reset as part of to_hash, we need to monkey patch the reset
# method so it only gets called once during to_hash, not multiple times. Otherwise it drops the
# puppet cache dir for facts. We could monkey patch the Puppet Facts indirector, but as this was
# only introduced in Factor 4.0.16, that seems like the wrong place to patch.
# Reference - https://github.com/puppetlabs/facter-ng/commit/bc2aca66d6f69d5f958ba7685b6e143416617e2c#diff-0e966bb45d33ec9251cfcda152227f1bR189
require 'facter'
module Facter
class << self
alias_method :original_reset, :reset

@singleton_reset = false

def reset
return nil if @singleton_reset
@singleton_reset = true
original_reset
end

def monkey_allow_reset
@singleton_reset = false
end
end
end

# MUST BE LAST!!!!!!
# Suppress any warning messages to STDOUT. It can pollute stdout when running in STDIO mode
Puppet::Util::Log.newdesttype :null_logger do
Expand Down

0 comments on commit f2e758e

Please sign in to comment.