-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathassert_supported_architecture.pp
82 lines (80 loc) · 2.44 KB
/
assert_supported_architecture.pp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# @summary Assert that the architecture given is a supported one
function peadm::assert_supported_architecture (
TargetSpec $primary_host,
Variant[TargetSpec, Undef] $replica_host = undef,
Variant[TargetSpec, Undef] $primary_postgresql_host = undef,
Variant[TargetSpec, Undef] $replica_postgresql_host = undef,
Variant[TargetSpec, Undef] $compiler_hosts = undef,
) >> Hash {
$result = case [
!!($primary_host),
!!($replica_host),
!!($primary_postgresql_host),
!!($replica_postgresql_host),
] {
[true, false, false, false]: { # Standard or Large, no DR
({ 'disaster-recovery' => false, 'architecture' => $compiler_hosts ? {
undef => 'standard',
default => 'large',
} })
}
[true, true, false, false]: { # Standard or Large, DR
({ 'disaster-recovery' => true, 'architecture' => $compiler_hosts ? {
undef => 'standard',
default => 'large',
} })
}
[true, false, true, false]: { # Extra Large, no DR
({ 'disaster-recovery' => false, 'architecture' => 'extra-large' })
}
[true, true, true, true]: { # Extra Large, DR
({ 'disaster-recovery' => true, 'architecture' => 'extra-large' })
}
# lint:ignore:strict_indent
default: { # Invalid
out::message(inline_epp(@(HEREDOC)))
Invalid architecture! Received:
- primary
<% if $replica_host { -%>
- primary-replica
<% } -%>
<% if $primary_postgresql_host { -%>
- pdb-database
<% } -%>
<% if $replica_postgresql_host { -%>
- pdb-database-replica
<% } -%>
<% if $compiler_hosts { -%>
- compilers
<% } -%>
Supported architectures include:
Standard
- primary
Standard with DR
- primary
- primary-replica
Large
- primary
- compilers
Large with DR
- primary
- primary-replica
- compilers
Extra Large
- primary
- pdb-database
- compilers (optional)
Extra Large with DR
- primary
- primary-replica
- pdb-database
- pdb-database-replica
- compilers (optional)
| HEREDOC
fail('Invalid architecture!')
}
}
# lint:endignore
# Return value
return({ 'supported' => true } + $result)
}