• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hercules-team / augeasproviders_postgresql / 52

pending completion
52

push

travis-ci-com

raphink
chore: remove FUNDING

54 of 116 relevant lines covered (46.55%)

0.93 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

63.64
/lib/puppet/type/pg_hba.rb
1
# Manages pg_hba entries
2

3
Puppet::Type.newtype(:pg_hba) do
2✔
4
  @doc = "Manages commands in pg_hba.conf."
2✔
5

6
  ensurable do
2✔
7
    defaultvalues
2✔
8
    block if block_given?
2✔
9

10
    newvalue(:positioned) do
2✔
11
      current = self.retrieve
×
12
      if current == :absent
×
13
        provider.create
×
14
      elsif !provider.in_position?
×
15
        provider.destroy
×
16
        provider.create
×
17
      end
18
    end
19

20
    def insync?(is)
2✔
21
      return true if should == :positioned and is == :present and provider.in_position?
×
22
      super
×
23
    end
24
  end
25

26
  newparam(:name) do
2✔
27
    desc "The default namevar"
2✔
28
  end
29

30
  newparam(:type) do
2✔
31
    desc "The type of host"
2✔
32
    isnamevar
2✔
33
    newvalues('local', 'host', 'hostssl', 'hostnossl')
2✔
34
    defaultto('local')
2✔
35
    munge do |value|
2✔
36
      value.to_s
×
37
    end
38
  end
39

40
  newparam(:database) do
2✔
41
    isnamevar
2✔
42
    desc "The database"
2✔
43
    defaultto(['all'])
2✔
44

45
    munge do |value|
2✔
46
      if value.is_a? Array
×
47
        value
×
48
      elsif value.is_a? String
×
49
        value.split(',')
×
50
      else
51
        [value]
×
52
      end
53
    end
54
  end
55

56
  newparam(:user) do
2✔
57
    isnamevar
2✔
58
    desc "The user"
2✔
59
    defaultto(['all'])
2✔
60

61
    munge do |value|
2✔
62
      if value.is_a? Array
×
63
        value
×
64
      elsif value.is_a? String
×
65
        value.split(',')
×
66
      else
67
        [value]
×
68
      end
69
    end
70
  end
71

72
  newparam(:address) do
2✔
73
    isnamevar
2✔
74
    desc "The address (for host, hostssl, hostnossl types)"
2✔
75
    validate do |value|
2✔
76
      unless value.nil? or @resource[:type] != 'local'
×
77
        raise ArgumentError, "address makes no sense for a local type"
×
78
      end
79
    end
80
  end
81

82
  newparam(:target) do
2✔
83
    isnamevar
2✔
84
    desc "The file in which to the pg_hba rule"
2✔
85
  end
86

87
  def self.title_patterns
2✔
88
    [
89
      [
90
        /^(local)\s+to\s+(\S+)\s+on\s+(\S+)\s+in\s+(.*)$/,
91
        [
92
          [ :type ],
93
          [ :user ],
94
          [ :database ],
95
          [ :target ],
96
        ]
97
      ],
×
98
      [
99
        /^(local)\s+to\s+(\S+)\s+on\s+(\S+)$/,
100
        [
101
          [ :type ],
102
          [ :user ],
103
          [ :database ],
104
        ]
105
      ],
106
      [
107
        /^(host\S*)\s+to\s+(\S+)\s+on\s+(\S+)\s+from\s+(\S+)\s+in\s+(.*)$/,
108
        [
109
          [ :type ],
110
          [ :user ],
111
          [ :database ],
112
          [ :address ],
113
          [ :target ]
114
        ]
115
      ],
116
      [
117
        /^(host\S*)\s+to\s+(\S+)\s+on\s+(\S+)\s+from\s+(\S+)$/,
118
        [
119
          [ :type ],
120
          [ :user ],
121
          [ :database ],
122
          [ :address ],
123
        ]
124
      ],
125
      [
126
        /(.*)/,
127
        [
128
          [ :name ],
129
        ]
130
      ]
131
    ]
132
  end
133

134
  newparam(:position) do
2✔
135
    desc "Where to place the new entry"
2✔
136
    validate do |value|
2✔
137
      raise "Wrong position statement '#{value}'" unless value =~ /^(before|after)/
×
138
    end
139
  end
140

141
  newproperty(:method) do
2✔
142
    desc "The authentication method"
2✔
143
  end
144

145
  newproperty(:options) do
2✔
146
    desc "The hash of authentication options"
2✔
147
    defaultto({})
2✔
148
  end
149

150
  autorequire(:file) do
2✔
151
    self[:target]
×
152
  end
153
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2023 Coveralls, Inc