Skip to content

Commit 5e4bf49

Browse files
committed
Add ensure parameter and make content parameter toggleable for entry API config file
1 parent 004f613 commit 5e4bf49

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

manifests/uitdatabank/entry_api/deployment.pp

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,26 @@
22
String $config_source,
33
String $admin_permissions_source,
44
String $client_permissions_source,
5-
String $api_keys_matched_to_client_ids_source,
65
String $movie_fetcher_config_source,
76
String $completeness_source,
87
String $externalid_mapping_organizer_source,
98
String $externalid_mapping_place_source,
109
String $pubkey_uitidv1_source,
1110
String $pubkey_keycloak_source,
12-
String $version = 'latest',
13-
String $repository = 'uitdatabank-entry-api',
14-
Enum['present', 'absent'] $amqp_listener_uitpas = 'present',
15-
Enum['present', 'absent'] $bulk_label_offer_worker = 'present',
16-
Enum['present', 'absent'] $mail_worker = 'present',
17-
Integer[0] $event_export_worker_count = 1,
18-
Optional[String] $puppetdb_url = lookup('data::puppet::puppetdb::url', Optional[String], 'first', undef)
11+
String $version = 'latest',
12+
String $repository = 'uitdatabank-entry-api',
13+
Optional[String] $api_keys_matched_to_client_ids_source = undef,
14+
Enum['present', 'absent'] $amqp_listener_uitpas = 'present',
15+
Enum['present', 'absent'] $bulk_label_offer_worker = 'present',
16+
Enum['present', 'absent'] $mail_worker = 'present',
17+
Integer[0] $event_export_worker_count = 1,
18+
Optional[String] $puppetdb_url = lookup('data::puppet::puppetdb::url', Optional[String], 'first', undef)
1919
) inherits ::profiles {
2020

2121
$basedir = '/var/www/udb3-backend'
2222
$secrets = lookup('vault:uitdatabank/udb3-backend')
2323
$mount_target_dns_name = lookup('terraform::efs::mount_target_dns_name', Optional[String], 'first', undef)
2424
$file_default_attributes = {
25-
ensure => 'file',
2625
owner => 'www-data',
2726
group => 'www-data',
2827
require => [Group['www-data'], User['www-data'], Package['uitdatabank-entry-api']],
@@ -50,60 +49,76 @@
5049
}
5150

5251
file { 'uitdatabank-entry-api-config':
52+
ensure => 'file',
5353
path => "${basedir}/config.php",
5454
content => template($config_source),
5555
* => $file_default_attributes
5656
}
5757

5858
file { 'uitdatabank-entry-api-admin-permissions':
59+
ensure => 'file',
5960
path => "${basedir}/config.allow_all.php",
6061
content => template($admin_permissions_source),
6162
* => $file_default_attributes
6263
}
6364

6465
file { 'uitdatabank-entry-api-client-permissions':
66+
ensure => 'file',
6567
path => "${basedir}/config.client_permissions.php",
6668
content => template($client_permissions_source),
6769
* => $file_default_attributes
6870
}
6971

7072
file { 'uitdatabank-entry-api-api-keys-matched-to-client-ids':
73+
ensure => $api_keys_matched_to_client_ids_source ? {
74+
undef => 'absent',
75+
default => 'file'
76+
},
7177
path => "${basedir}/config.api_keys_matched_to_client_ids.php",
72-
content => template($api_keys_matched_to_client_ids_source),
78+
content => $api_keys_matched_to_client_ids_source ? {
79+
undef => undef,
80+
default => template($api_keys_matched_to_client_ids_source),
81+
},
7382
* => $file_default_attributes
7483
}
7584

7685
file { 'uitdatabank-entry-api-movie-fetcher-config':
86+
ensure => 'file',
7787
path => "${basedir}/config.kinepolis.php",
7888
content => template($movie_fetcher_config_source),
7989
* => $file_default_attributes
8090
}
8191

8292
file { 'uitdatabank-entry-api-completeness':
93+
ensure => 'file',
8394
path => "${basedir}/config.completeness.php",
8495
content => template($completeness_source),
8596
* => $file_default_attributes
8697
}
8798

8899
file { 'uitdatabank-entry-api-externalid-mapping-organizer':
100+
ensure => 'file',
89101
path => "${basedir}/config.external_id_mapping_organizer.php",
90102
content => template($externalid_mapping_organizer_source),
91103
* => $file_default_attributes
92104
}
93105

94106
file { 'uitdatabank-entry-api-externalid-mapping-place':
107+
ensure => 'file',
95108
path => "${basedir}/config.external_id_mapping_place.php",
96109
content => template($externalid_mapping_place_source),
97110
* => $file_default_attributes
98111
}
99112

100113
file { 'uitdatabank-entry-api-pubkey-uitidv1':
114+
ensure => 'file',
101115
path => "${basedir}/public.pem",
102116
content => template($pubkey_uitidv1_source),
103117
* => $file_default_attributes
104118
}
105119

106120
file { 'uitdatabank-entry-api-pubkey-keycloak':
121+
ensure => 'file',
107122
path => "${basedir}/public-keycloak.pem",
108123
content => template($pubkey_keycloak_source),
109124
* => $file_default_attributes

spec/classes/uitdatabank/entry_api/deployment_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@
305305
'config_source' => 'appconfig/uitdatabank/udb3-backend/my.config.php',
306306
'admin_permissions_source' => 'appconfig/uitdatabank/udb3-backend/config.my.allow_all.php',
307307
'client_permissions_source' => 'appconfig/uitdatabank/udb3-backend/config.my.client_permissions.php',
308-
'api_keys_matched_to_client_ids_source_source' => 'appconfig/uitdatabank/udb3-backend/config.my.api_keys_matched_to_client_ids_source.php',
308+
'api_keys_matched_to_client_ids_source' => 'appconfig/uitdatabank/udb3-backend/config.my.api_keys_matched_to_client_ids.php',
309309
'movie_fetcher_config_source' => 'appconfig/uitdatabank/udb3-backend/config.my.kinepolis.php',
310310
'completeness_source' => 'appconfig/uitdatabank/udb3-backend/config.my.completeness.php',
311311
'externalid_mapping_organizer_source' => 'appconfig/uitdatabank/udb3-backend/config.my.external_id_mapping_organizer.php',
@@ -365,7 +365,6 @@
365365
it { expect { catalogue }.to raise_error(Puppet::ParseError, /expects a value for parameter 'config_source'/) }
366366
it { expect { catalogue }.to raise_error(Puppet::ParseError, /expects a value for parameter 'admin_permissions_source'/) }
367367
it { expect { catalogue }.to raise_error(Puppet::ParseError, /expects a value for parameter 'client_permissions_source'/) }
368-
it { expect { catalogue }.to raise_error(Puppet::ParseError, /expects a value for parameter 'api_keys_matched_to_client_ids_source'/) }
369368
it { expect { catalogue }.to raise_error(Puppet::ParseError, /expects a value for parameter 'movie_fetcher_config_source'/) }
370369
it { expect { catalogue }.to raise_error(Puppet::ParseError, /expects a value for parameter 'completeness_source'/) }
371370
it { expect { catalogue }.to raise_error(Puppet::ParseError, /expects a value for parameter 'externalid_mapping_place_source'/) }

spec/support/appconfig/templates/uitdatabank/udb3-backend/config.api_keys_matched_to_client_ids copy.php renamed to spec/support/appconfig/templates/uitdatabank/udb3-backend/config.api_keys_matched_to_client_ids.php

File renamed without changes.

0 commit comments

Comments
 (0)