Skip to content

Commit

Permalink
(PDK-1007) Remove unused TypeShim code
Browse files Browse the repository at this point in the history
Since `instances` now returns full `Puppet::Type` instances, this can
be removed. `ResourceShim`s are still used in `to_resource` to work
around the various manifest rendering bugs of the base implementation.
  • Loading branch information
DavidS committed Jun 11, 2018
1 parent b7fcc4e commit ef12b37
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 60 deletions.
23 changes: 0 additions & 23 deletions lib/puppet/resource_api/glue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,6 @@

module Puppet; end # rubocop:disable Style/Documentation
module Puppet::ResourceApi
# A trivial class to provide the functionality required to push data through the existing type/provider parts of puppet
class TypeShim
attr_reader :values, :typename, :namevars, :attr_def

def initialize(resource_hash, typename, namevars, attr_def)
# internalize and protect - needs to go deeper
@values = resource_hash.dup.freeze

@typename = typename
@namevars = namevars
@attr_def = attr_def
@resource = ResourceShim.new(@values, @typename, @namevars, @attr_def)
end

def to_resource
@resource
end

def name
@resource.title
end
end

# A trivial class to provide the functionality required to push data through the existing type/provider parts of puppet
class ResourceShim
attr_reader :values, :typename, :namevars, :attr_def
Expand Down
37 changes: 0 additions & 37 deletions spec/puppet/resource_api/glue_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,6 @@
# `puppet resource` read/write cycle to ensure that there is nothing
# funky happening with new puppet versions.
RSpec.describe 'the dirty bits' do
describe Puppet::ResourceApi::TypeShim do
subject(:instance) do
described_class.new({ attr: 'value', attr_ro: 'fixed' }, 'typename', [:namevarname],
namevarname: { type: 'String', behaviour: :namevar, desc: 'the title' },
attr: { type: 'String', desc: 'a string parameter' },
attr_ro: { type: 'String', desc: 'a string readonly', behaviour: :read_only })
end

describe '.values' do
it { expect(instance.values).to eq(attr: 'value', attr_ro: 'fixed') }
end

describe '.typename' do
it { expect(instance.typename).to eq 'typename' }
end

describe '.namevars' do
it { expect(instance.namevars).to eq [:namevarname] }
end

describe '.to_resource' do
it { expect(instance.to_resource).to be_a Puppet::ResourceApi::ResourceShim }

describe '.values' do
it { expect(instance.to_resource.values).to eq(attr: 'value', attr_ro: 'fixed') }
end

describe '.typename' do
it { expect(instance.to_resource.typename).to eq 'typename' }
end

describe '.namevars' do
it { expect(instance.to_resource.namevars).to eq [:namevarname] }
end
end
end

describe Puppet::ResourceApi::ResourceShim do
subject(:instance) do
described_class.new({ namevarname: title, attr: 'value', attr_ro: 'fixed' }, 'typename', [:namevarname],
Expand Down

0 comments on commit ef12b37

Please sign in to comment.