Commit 09289b8
committed
Prefer $connect_settings over explicit parameters
This is the outcome of a large refactoring in #1450 and discussions on
IRC and slack. We noticed that the behaviour of `$connect_settings` is
currently inconsistent. Sometimes it's preferred over explicity
parameters, sometimes not.
Reminder: The idea of `$connect_settings` is to provide a hash with
environment variable to tell puppet to manage a remote database instead
of a local instance.
One example is: https://github.com/puppetlabs/puppetlabs-postgresql/blob/93386b48861ff41d5f47033afee592e0506526c5/manifests/server/grant.pp#L80-L86
```
if $port {
$port_override = $port
} elsif 'PGPORT' in $connect_settings {
$port_override = undef
} else {
$port_override = $postgresql::server::port
}
```
Here the local $port parameter is preferred over `$connect_settings`.
The problem is that we now cannot set a default in the resource for
`$port`. The default is hardcoded to `$postgresql::server::port`. This
becomes. Other classes handle it in a different way:
https://github.com/puppetlabs/puppetlabs-postgresql/blob/93386b48861ff41d5f47033afee592e0506526c5/manifests/server/database.pp#L41-L46
```
if 'PGPORT' in $connect_settings {
$port_override = undef
} else {
$port_override = $port
}
```
Here `$connct_settings` is checked first. It defaults to an empty hash.
If `PGPORT` isn't in it, `$port` is used. The logic is shorter and
enables us to expose $port as a parameter with a default value. With
this approach users can decide if they pass `$port` or
`$connect_settings`.
At the moment the remote database support is broken because the logic to
parse `$connect_settings` isn't consistent. The goal of this PR is to
unify the logic and prefer `$connect_settings` if it's provided by the
user.1 parent e4b334d commit 09289b8
File tree
17 files changed
+84
-132
lines changed- manifests/server
- spec/defines/server
17 files changed
+84
-132
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
178 | | - | |
| 178 | + | |
179 | 179 | | |
180 | | - | |
| 180 | + | |
181 | 181 | | |
182 | | - | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
183 | 187 | | |
184 | 188 | | |
185 | 189 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
420 | 420 | | |
421 | 421 | | |
422 | 422 | | |
423 | | - | |
| 423 | + | |
424 | 424 | | |
425 | 425 | | |
426 | 426 | | |
| |||
434 | 434 | | |
435 | 435 | | |
436 | 436 | | |
437 | | - | |
| 437 | + | |
438 | 438 | | |
439 | 439 | | |
440 | 440 | | |
441 | 441 | | |
442 | 442 | | |
443 | 443 | | |
444 | 444 | | |
445 | | - | |
| 445 | + | |
446 | 446 | | |
447 | 447 | | |
448 | 448 | | |
449 | 449 | | |
450 | 450 | | |
451 | 451 | | |
452 | 452 | | |
453 | | - | |
| 453 | + | |
454 | 454 | | |
455 | 455 | | |
456 | 456 | | |
457 | 457 | | |
458 | 458 | | |
459 | 459 | | |
460 | 460 | | |
461 | | - | |
| 461 | + | |
462 | 462 | | |
463 | 463 | | |
464 | 464 | | |
| |||
660 | 660 | | |
661 | 661 | | |
662 | 662 | | |
663 | | - | |
| 663 | + | |
664 | 664 | | |
665 | 665 | | |
666 | 666 | | |
| |||
1124 | 1124 | | |
1125 | 1125 | | |
1126 | 1126 | | |
1127 | | - | |
| 1127 | + | |
1128 | 1128 | | |
1129 | 1129 | | |
1130 | 1130 | | |
1131 | 1131 | | |
1132 | 1132 | | |
1133 | 1133 | | |
1134 | 1134 | | |
1135 | | - | |
| 1135 | + | |
1136 | 1136 | | |
1137 | 1137 | | |
1138 | 1138 | | |
1139 | 1139 | | |
1140 | 1140 | | |
1141 | 1141 | | |
1142 | 1142 | | |
1143 | | - | |
| 1143 | + | |
1144 | 1144 | | |
1145 | 1145 | | |
1146 | 1146 | | |
| |||
1268 | 1268 | | |
1269 | 1269 | | |
1270 | 1270 | | |
1271 | | - | |
| 1271 | + | |
1272 | 1272 | | |
1273 | 1273 | | |
1274 | 1274 | | |
| |||
1754 | 1754 | | |
1755 | 1755 | | |
1756 | 1756 | | |
1757 | | - | |
| 1757 | + | |
1758 | 1758 | | |
1759 | 1759 | | |
1760 | 1760 | | |
1761 | | - | |
| 1761 | + | |
1762 | 1762 | | |
1763 | 1763 | | |
1764 | 1764 | | |
1765 | | - | |
| 1765 | + | |
1766 | 1766 | | |
1767 | 1767 | | |
1768 | 1768 | | |
1769 | | - | |
| 1769 | + | |
1770 | 1770 | | |
1771 | 1771 | | |
1772 | 1772 | | |
| |||
2116 | 2116 | | |
2117 | 2117 | | |
2118 | 2118 | | |
2119 | | - | |
| 2119 | + | |
2120 | 2120 | | |
2121 | 2121 | | |
2122 | 2122 | | |
2123 | | - | |
| 2123 | + | |
2124 | 2124 | | |
2125 | 2125 | | |
2126 | 2126 | | |
| |||
2267 | 2267 | | |
2268 | 2268 | | |
2269 | 2269 | | |
2270 | | - | |
| 2270 | + | |
2271 | 2271 | | |
2272 | 2272 | | |
2273 | 2273 | | |
2274 | | - | |
| 2274 | + | |
2275 | 2275 | | |
2276 | 2276 | | |
2277 | 2277 | | |
| |||
2585 | 2585 | | |
2586 | 2586 | | |
2587 | 2587 | | |
2588 | | - | |
| 2588 | + | |
2589 | 2589 | | |
2590 | 2590 | | |
2591 | 2591 | | |
2592 | 2592 | | |
2593 | 2593 | | |
2594 | 2594 | | |
2595 | 2595 | | |
2596 | | - | |
| 2596 | + | |
2597 | 2597 | | |
2598 | 2598 | | |
2599 | 2599 | | |
| |||
2700 | 2700 | | |
2701 | 2701 | | |
2702 | 2702 | | |
2703 | | - | |
| 2703 | + | |
2704 | 2704 | | |
2705 | 2705 | | |
2706 | 2706 | | |
| |||
2753 | 2753 | | |
2754 | 2754 | | |
2755 | 2755 | | |
2756 | | - | |
| 2756 | + | |
2757 | 2757 | | |
2758 | 2758 | | |
2759 | 2759 | | |
| |||
2785 | 2785 | | |
2786 | 2786 | | |
2787 | 2787 | | |
2788 | | - | |
| 2788 | + | |
2789 | 2789 | | |
2790 | 2790 | | |
2791 | 2791 | | |
| |||
2818 | 2818 | | |
2819 | 2819 | | |
2820 | 2820 | | |
2821 | | - | |
| 2821 | + | |
2822 | 2822 | | |
2823 | 2823 | | |
2824 | 2824 | | |
| |||
2884 | 2884 | | |
2885 | 2885 | | |
2886 | 2886 | | |
2887 | | - | |
| 2887 | + | |
2888 | 2888 | | |
2889 | 2889 | | |
2890 | 2890 | | |
| |||
2951 | 2951 | | |
2952 | 2952 | | |
2953 | 2953 | | |
2954 | | - | |
| 2954 | + | |
2955 | 2955 | | |
2956 | 2956 | | |
2957 | 2957 | | |
| |||
3554 | 3554 | | |
3555 | 3555 | | |
3556 | 3556 | | |
3557 | | - | |
| 3557 | + | |
3558 | 3558 | | |
3559 | 3559 | | |
3560 | 3560 | | |
3561 | | - | |
| 3561 | + | |
3562 | 3562 | | |
3563 | 3563 | | |
3564 | 3564 | | |
| |||
3697 | 3697 | | |
3698 | 3698 | | |
3699 | 3699 | | |
| 3700 | + | |
3700 | 3701 | | |
3701 | 3702 | | |
3702 | 3703 | | |
| |||
3730 | 3731 | | |
3731 | 3732 | | |
3732 | 3733 | | |
| 3734 | + | |
| 3735 | + | |
| 3736 | + | |
| 3737 | + | |
| 3738 | + | |
| 3739 | + | |
| 3740 | + | |
| 3741 | + | |
3733 | 3742 | | |
3734 | 3743 | | |
3735 | 3744 | | |
| |||
3840 | 3849 | | |
3841 | 3850 | | |
3842 | 3851 | | |
| 3852 | + | |
3843 | 3853 | | |
3844 | 3854 | | |
3845 | 3855 | | |
| |||
3879 | 3889 | | |
3880 | 3890 | | |
3881 | 3891 | | |
| 3892 | + | |
| 3893 | + | |
| 3894 | + | |
| 3895 | + | |
| 3896 | + | |
| 3897 | + | |
| 3898 | + | |
| 3899 | + | |
3882 | 3900 | | |
3883 | 3901 | | |
3884 | 3902 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
| 33 | + | |
| 34 | + | |
47 | 35 | | |
48 | 36 | | |
49 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 38 | + | |
| 39 | + | |
45 | 40 | | |
46 | 41 | | |
47 | 42 | | |
| |||
59 | 54 | | |
60 | 55 | | |
61 | 56 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | 57 | | |
74 | 58 | | |
75 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
| 79 | + | |
89 | 80 | | |
90 | 81 | | |
91 | 82 | | |
| |||
0 commit comments