Skip to content

Commit cf31637

Browse files
committed
Fix title patterns to no longer use unsupported proc
Currently the title patterns with proc prevent `puppet generate types` from working: Error: /etc/puppetlabs/code/environments/production/modules/openldap/lib/puppet/type/openldap_access.rb: title patterns that use procs are not supported. Error: /etc/puppetlabs/code/environments/production/modules/openldap/lib/puppet/type/openldap_dbindex.rb: title patterns that use procs are not supported. Error: /etc/puppetlabs/code/environments/production/modules/openldap/lib/puppet/type/openldap_overlay.rb: title patterns that use procs are not supported. https://tickets.puppetlabs.com/browse/MODULES-4505?focusedCommentId=418416&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-418416 treydock/puppet-module-keycloak#21
1 parent 4334eed commit cf31637

File tree

4 files changed

+54
-25
lines changed

4 files changed

+54
-25
lines changed

lib/puppet/type/openldap_access.rb

+17-17
Original file line numberDiff line numberDiff line change
@@ -36,51 +36,51 @@ def self.title_patterns
3636
[
3737
/^(\{(\d+)\}to\s+(\S+)\s+(by\s+.+)\s+on\s+(.+))$/,
3838
[
39-
[ :name, lambda{|x| x} ],
40-
[ :position, lambda{|x| x} ],
41-
[ :what, lambda{|x| x} ],
39+
[ :name ],
40+
[ :position ],
41+
[ :what ],
4242
[ :access, lambda{ |x| a=[]; x.split(/(?= by .+)/).each { |b| a << b.lstrip }; a } ],
43-
[ :suffix, lambda{|x| x} ],
43+
[ :suffix ],
4444
],
4545
],
4646
[
47-
/^(\{(\d+)\}to\s+(\S+)\s+(by\s+.+)\s+)$/,
47+
/^(\{(\d+)\}to\s+(\S+)\s+(by\s+.+))$/,
4848
[
49-
[ :name, lambda{|x| x} ],
50-
[ :position, lambda{|x| x} ],
51-
[ :what, lambda{|x| x} ],
49+
[ :name ],
50+
[ :position ],
51+
[ :what ],
5252
[ :access, lambda{ |x| a=[]; x.split(/(?= by .+)/).each { |b| a << b.lstrip }; a } ],
5353
],
5454
],
5555
[
5656
/^(to\s+(\S+)\s+(by\s+.+)\s+on\s+(.+))$/,
5757
[
58-
[ :name, lambda{|x| x} ],
59-
[ :what, lambda{|x| x} ],
58+
[ :name ],
59+
[ :what ],
6060
[ :access, lambda{ |x| a=[]; x.split(/(?= by .+)/).each { |b| a << b.lstrip }; a } ],
61-
[ :suffix, lambda{|x| x} ],
61+
[ :suffix ],
6262
],
6363
],
6464
[
6565
/^(to\s+(\S+)\s+(by\s+.+))$/,
6666
[
67-
[ :name, lambda{|x| x} ],
68-
[ :what, lambda{|x| x} ],
67+
[ :name ],
68+
[ :what ],
6969
[ :access, lambda{ |x| a=[]; x.split(/(?= by .+)/).each { |b| a << b.lstrip }; a } ],
7070
],
7171
],
7272
[
7373
/^((\d+)\s+on\s+(.+))$/,
7474
[
75-
[ :name, lambda{|x| x} ],
76-
[ :position, lambda{|x| x} ],
77-
[ :suffix, lambda{|x| x} ],
75+
[ :name ],
76+
[ :position ],
77+
[ :suffix ],
7878
],
7979
],
8080
[
8181
/(.*)/,
8282
[
83-
[ :name, lambda{|x| x} ],
83+
[ :name ],
8484
],
8585
],
8686
]

lib/puppet/type/openldap_dbindex.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ def self.title_patterns
2525
[
2626
/^((\S+)\s+on\s+(.+))$/,
2727
[
28-
[ :name, lambda{|x| x} ],
29-
[ :attribute, lambda{|x| x} ],
30-
[ :suffix, lambda{|x| x} ],
28+
[ :name ],
29+
[ :attribute ],
30+
[ :suffix ],
3131
],
3232
],
3333
[
3434
/(.*)/,
3535
[
36-
[ :name, lambda{|x| x} ],
36+
[ :name ],
3737
],
3838
],
3939
]

lib/puppet/type/openldap_overlay.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ def self.title_patterns
2828
[
2929
/^((\S+)\s+on\s+(\S+))$/,
3030
[
31-
[ :name, lambda{|x| x} ],
32-
[ :overlay, lambda{|x| x} ],
33-
[ :suffix, lambda{|x| x} ],
31+
[ :name ],
32+
[ :overlay ],
33+
[ :suffix ],
3434
],
3535
],
3636
[
3737
/(.*)/,
3838
[
39-
[ :name, lambda{|x| x} ],
39+
[ :name ],
4040
],
4141
],
4242
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
require 'spec_helper'
2+
3+
describe Puppet::Type.type(:openldap_access) do
4+
describe 'namevar title patterns' do
5+
it 'should handle componsite name' do
6+
access = described_class.new(:name => 'to attrs=userPassword,shadowLastChange by dn="cn=admin,dc=example,dc=com" write by anonymous auth')
7+
expect(access[:name]).to eq('to attrs=userPassword,shadowLastChange by dn="cn=admin,dc=example,dc=com" write by anonymous auth')
8+
expect(access[:what]).to eq('attrs=userPassword,shadowLastChange')
9+
expect(access[:access]).to eq(['by dn="cn=admin,dc=example,dc=com" write', 'by anonymous auth'])
10+
end
11+
12+
it 'should handle componsite name with position' do
13+
access = described_class.new(:name => '{0}to attrs=userPassword,shadowLastChange by dn="cn=admin,dc=example,dc=com" write by anonymous auth')
14+
expect(access[:name]).to eq('{0}to attrs=userPassword,shadowLastChange by dn="cn=admin,dc=example,dc=com" write by anonymous auth')
15+
expect(access[:position]).to eq('0')
16+
expect(access[:what]).to eq('attrs=userPassword,shadowLastChange')
17+
expect(access[:access]).to eq(['by dn="cn=admin,dc=example,dc=com" write', 'by anonymous auth'])
18+
end
19+
20+
it 'should handle componsite name with position' do
21+
access = described_class.new(:name => '{0}to attrs=userPassword,shadowLastChange by dn="cn=admin,dc=example,dc=com" write by anonymous auth on dc=example,dc=com')
22+
expect(access[:name]).to eq('{0}to attrs=userPassword,shadowLastChange by dn="cn=admin,dc=example,dc=com" write by anonymous auth on dc=example,dc=com')
23+
expect(access[:position]).to eq('0')
24+
expect(access[:what]).to eq('attrs=userPassword,shadowLastChange')
25+
expect(access[:access]).to eq(['by dn="cn=admin,dc=example,dc=com" write', 'by anonymous auth'])
26+
expect(access[:suffix]).to eq('dc=example,dc=com')
27+
end
28+
end
29+
end

0 commit comments

Comments
 (0)