Commit 40e9b567 authored by Andrew Roetker's avatar Andrew Roetker

(PDB-1957) Retire Puppet 3.x support in the terminus

This commit retires Puppet 3.x support in the terminus.
parent 1acfba24
......@@ -16,24 +16,13 @@ class Puppet::Node::Facts::Puppetdb < Puppet::Indirector::REST
trusted.to_h
end
def maybe_strip_internal(facts)
if Puppet::Node::Facts.method_defined? :strip_internal
facts.strip_internal
else
facts.values
end
end
def save(request)
profile("facts#save", [:puppetdb, :facts, :save, request.key]) do
payload = profile("Encode facts command submission payload",
[:puppetdb, :facts, :encode]) do
facts = request.instance.dup
facts.values = facts.strip_internal.dup
if ! Puppet::Util::Puppetdb.puppet3compat? || Puppet[:trusted_node_data]
facts.values[:trusted] = get_trusted_info(request.node)
end
facts.values = facts.values.dup
facts.values[:trusted] = get_trusted_info(request.node)
{
"certname" => facts.name,
"values" => facts.values,
......
......@@ -28,10 +28,6 @@ module Puppet::Util::Puppetdb
@config
end
def self.puppet3compat?
defined?(Puppet::Parser::AST::HashOrArrayAccess)
end
# Given an instance of ruby's Time class, this method converts it to a String
# that conforms to PuppetDB's wire format for representing a date/time.
def self.to_wire_time(time)
......
......@@ -14,11 +14,9 @@ require 'puppet/util/puppetdb'
require 'puppet/util/log'
def create_environmentdir(environment)
if not Puppet::Util::Puppetdb.puppet3compat?
envdir = File.join(Puppet[:environmentpath], environment)
if not Dir.exists?(envdir)
Dir.mkdir(envdir)
end
envdir = File.join(Puppet[:environmentpath], environment)
if not Dir.exists?(envdir)
Dir.mkdir(envdir)
end
end
......
......@@ -112,24 +112,6 @@ describe Puppet::Resource::Catalog::Puppetdb do
end
end
describe "#stringify_titles" do
if Puppet::Util::Puppetdb.puppet3compat?
it "should make all resource titles strings if they aren't" do
Puppet[:code] = <<-MANIFEST
$foo = true
notify { $foo: }
MANIFEST
hash = catalog.to_data_hash
result = subject.stringify_titles(hash)
result['resources'].should be_any { |res|
res['type'] == 'Notify' and res['title'] == 'true'
}
end
end
end
describe "#add_namevar_aliases" do
it "should add namevar to aliases if it's not already present" do
name = 'with a different name'
......@@ -455,30 +437,6 @@ describe Puppet::Resource::Catalog::Puppetdb do
result['edges'].should include(edge)
end
if Puppet::Util::Puppetdb.puppet3compat?
it "should add edges which refer to collected virtual resources with hyphens in the classname" do
Puppet[:code] = <<-MANIFEST
define foo-bar- (){}
@foo-bar- { 'baz': }
notify { source:
before => Foo-bar-[baz],
}
Foo-bar- <| |>
MANIFEST
result = subject.munge_catalog(catalog)
other_edge = {
'source' => {'type' => 'Notify', 'title' => 'source'},
'target' => {'type' => 'Foo-bar-', 'title' => 'baz'},
'relationship' => 'before'
}
result['edges'].should include(other_edge)
end
end
it "should add edges defined on collected virtual resources" do
Puppet[:code] = <<-MANIFEST
@notify { source:
......
......@@ -38,40 +38,14 @@ describe Puppet::Node::Facts::Puppetdb do
subject.save(Puppet::Node::Facts.indirection.request(:save, facts.name, facts, options))
end
it "should POST the facts as a JSON string" do
Puppet::Util::Puppetdb.stubs(:puppet3compat?).returns(true)
f = {
"certname" => facts.name,
"values" => subject.maybe_strip_internal(facts),
"environment" => "my_environment",
"producer_timestamp" => "a test",
}
payload = {
:command => CommandReplaceFacts,
:version => 4,
:payload => f,
}.to_json
http.expects(:post).with do |uri, body, headers|
expect(body).to eq(payload)
end.returns response
save
end
it "should POST the trusted data we tell it to" do
if Puppet::Util::Puppetdb.puppet3compat?
Puppet[:trusted_node_data] = true
end
trusted_data = {"foo" => "foobar", "certname" => "testing_posting"}
subject.stubs(:get_trusted_info).returns trusted_data
f = {
"certname" => facts.name,
"values" => subject.maybe_strip_internal(facts).merge({"trusted" => trusted_data}),
"values" => facts.values.merge({"trusted" => trusted_data}),
"environment" => "my_environment",
"producer_timestamp" => "a test",
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment