Skip to content

Commit 9fe3ef5

Browse files
committed
Create new type correctly
In the past there have been multiple ways how to create a new type. Apparently they are not all working anymore so we switch to `Puppet::Type.newtype`
1 parent 8b9ae94 commit 9fe3ef5

File tree

2 files changed

+38
-36
lines changed

2 files changed

+38
-36
lines changed

lib/puppet/provider/oratab/parsed.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'puppet/provider/parsedfile'
24

35
oratab = case Facter.value(:operatingsystem)

lib/puppet/type/oratab.rb

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
1+
# frozen_string_literal: true
2+
13
require 'puppet/provider/parsedfile'
24

3-
module Puppet
4-
newtype(:oratab) do
5+
Puppet::Type.newtype(:oratab) do
56

6-
@doc = "Define database instaces in /etc/oratab with instance name
7-
home directory and a flag which indicates if the instance should
8-
be started together with the database"
7+
@doc = "Define database instaces in /etc/oratab with instance name
8+
home directory and a flag which indicates if the instance should
9+
be started together with the database"
910

10-
newparam(:name) do
11-
desc "The instance's name"
11+
newparam(:name) do
12+
desc "The instance's name"
1213

13-
isnamevar
14+
isnamevar
1415

15-
validate do |value|
16-
raise Puppet::Error, "Name must not contain whitespace: #{value}" if value =~ /\s/
17-
raise Puppet::Error, "Name must not be empty" if value.empty?
18-
end
16+
validate do |value|
17+
raise Puppet::Error, "Name must not contain whitespace: #{value}" if value =~ /\s/
18+
raise Puppet::Error, "Name must not be empty" if value.empty?
1919
end
20+
end
2021

21-
ensurable
22+
ensurable
2223

23-
newproperty(:home) do
24-
desc "The home directory of the instance. This must be an absolute
25-
path"
24+
newproperty(:home) do
25+
desc "The home directory of the instance. This must be an absolute
26+
path"
2627

27-
validate do |value|
28-
raise Puppet::Error, "Home must be an absolute path: #{value}" unless value =~ /^\//
29-
end
28+
validate do |value|
29+
raise Puppet::Error, "Home must be an absolute path: #{value}" unless value =~ /^\//
3030
end
31+
end
3132

32-
newproperty(:atboot) do
33-
desc "If the instance should start together with the database itself
34-
set this property to `yes` otherwise to `no`"
33+
newproperty(:atboot) do
34+
desc "If the instance should start together with the database itself
35+
set this property to `yes` otherwise to `no`"
3536

36-
newvalues :yes, :no
37-
aliasvalue :Y, :yes
38-
aliasvalue :N, :no
39-
end
37+
newvalues :yes, :no
38+
aliasvalue :Y, :yes
39+
aliasvalue :N, :no
40+
end
4041

41-
newproperty(:description) do
42-
desc "An optional description that will be added as an inline comment
43-
in the target file"
42+
newproperty(:description) do
43+
desc "An optional description that will be added as an inline comment
44+
in the target file"
4445

45-
end
46+
end
4647

47-
newproperty(:target) do
48-
desc "The path of the target file to store the instance information in"
48+
newproperty(:target) do
49+
desc "The path of the target file to store the instance information in"
4950

50-
defaultto do
51-
if @resource.class.defaultprovider.ancestors.include?(Puppet::Provider::ParsedFile)
52-
@resource.class.defaultprovider.default_target
53-
end
51+
defaultto do
52+
if @resource.class.defaultprovider.ancestors.include?(Puppet::Provider::ParsedFile)
53+
@resource.class.defaultprovider.default_target
5454
end
5555
end
5656
end

0 commit comments

Comments
 (0)