Remove package_manifest
This was created 5 years ago and is not useful anymore, let's remove it. Depends-On: https://review.opendev.org/753324 Change-Id: Iac8ba86958fe2fba0c9b48cef02ba41f8d4c32cf
This commit is contained in:
parent
ce090228c0
commit
18e54f5692
@ -1,39 +0,0 @@
|
|||||||
|
|
||||||
require 'set'
|
|
||||||
|
|
||||||
|
|
||||||
Puppet::Type.type(:package_manifest).provide(:flat_file) do
|
|
||||||
|
|
||||||
desc "Write package manifest to a flat file"
|
|
||||||
|
|
||||||
def exists?
|
|
||||||
# exists? is always run before create, so we can create package list here
|
|
||||||
@packages = resource.catalog.resources.collect { |r|
|
|
||||||
r.name if r.type == :package
|
|
||||||
}.compact.sort
|
|
||||||
|
|
||||||
exists = File.exist?(resource[:path])
|
|
||||||
if exists
|
|
||||||
new_content = Set.new @packages
|
|
||||||
old_content = Set.new(
|
|
||||||
File.open(resource[:path], 'r').each_line.collect{ |pkg| pkg.strip() }
|
|
||||||
)
|
|
||||||
exists = new_content == old_content
|
|
||||||
end
|
|
||||||
exists
|
|
||||||
end
|
|
||||||
|
|
||||||
def create
|
|
||||||
FileUtils.mkdir_p(File.dirname(resource[:path]))
|
|
||||||
File.open(resource[:path], 'w') do |f|
|
|
||||||
@packages.each do |pkg_name|
|
|
||||||
f.puts(pkg_name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def destroy
|
|
||||||
File.delete(resource[:path])
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
@ -1,8 +0,0 @@
|
|||||||
Puppet::Type.newtype(:package_manifest) do
|
|
||||||
|
|
||||||
ensurable
|
|
||||||
newparam(:path, :namevar => true) do
|
|
||||||
newvalues(/\S+\/\S+/)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
@ -1,37 +0,0 @@
|
|||||||
|
|
||||||
require 'puppet'
|
|
||||||
require 'puppet/type/package_manifest'
|
|
||||||
|
|
||||||
describe 'Puppet::Type.type(:package_manifest)' do
|
|
||||||
before :each do
|
|
||||||
@manifest = Puppet::Type.type(:package_manifest).new(
|
|
||||||
:path => '/tmp/test_package_manifest.txt', :ensure => 'present'
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should require a path' do
|
|
||||||
expect {
|
|
||||||
Puppet::Type.type(:package_manifest).new({})
|
|
||||||
}.to raise_error Puppet::Error
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not require a value when ensure is absent' do
|
|
||||||
Puppet::Type.type(:package_manifest).new(
|
|
||||||
:path => '/tmp/test_package_manifest.txt', :ensure => :absent
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should accept valid ensure values' do
|
|
||||||
@manifest[:ensure] = :present
|
|
||||||
expect(@manifest[:ensure]).to eq(:present)
|
|
||||||
@manifest[:ensure] = :absent
|
|
||||||
expect(@manifest[:ensure]).to eq(:absent)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not accept invalid ensure values' do
|
|
||||||
expect {
|
|
||||||
@manifest[:ensure] = :latest
|
|
||||||
}.to raise_error(Puppet::Error, /Invalid value/)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
Loading…
Reference in New Issue
Block a user