Skip to content

Commit 359cd1a

Browse files
committed
event more stringent on type checking and existence of haproxy config data
1 parent 776d4dd commit 359cd1a

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# if: tag IS present
22
language: php
33
php:
4-
- '7.2'
4+
- '7.3'
55
sudo: required
66
services:
77
- docker

src/KubernetesPfSenseController/Plugin/HAProxyConfig.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ public function save()
2828
*/
2929
public function getFrontends()
3030
{
31-
if (!key_exists('ha_backends', $this->data)) {
31+
if (!is_array($this->data['ha_backends'])) {
3232
return [];
3333
}
34-
if (!key_exists('item', $this->data['ha_backends'])) {
34+
if (!is_array($this->data['ha_backends']['item'])) {
3535
return [];
3636
}
3737

@@ -60,10 +60,10 @@ public function getFrontendNames()
6060
*/
6161
public function getBackends()
6262
{
63-
if (!key_exists('ha_pools', $this->data)) {
63+
if (!is_array($this->data['ha_pools'])) {
6464
return [];
6565
}
66-
if (!key_exists('item', $this->data['ha_pools'])) {
66+
if (!is_array($this->data['ha_pools']['item'])) {
6767
return [];
6868
}
6969

@@ -93,10 +93,10 @@ public function getBackendNames()
9393
*/
9494
public function frontendExists($name)
9595
{
96-
if (!key_exists('ha_backends', $this->data)) {
96+
if (!is_array($this->data['ha_backends'])) {
9797
return false;
9898
}
99-
if (!key_exists('item', $this->data['ha_backends'])) {
99+
if (!is_array($this->data['ha_backends']['item'])) {
100100
return false;
101101
}
102102

@@ -117,10 +117,10 @@ public function frontendExists($name)
117117
*/
118118
public function backendExists($name)
119119
{
120-
if (!key_exists('ha_pools', $this->data)) {
120+
if (!is_array($this->data['ha_pools'])) {
121121
return false;
122122
}
123-
if (!key_exists('item', $this->data['ha_pools'])) {
123+
if (!is_array($this->data['ha_pools']['item'])) {
124124
return false;
125125
}
126126

@@ -141,10 +141,10 @@ public function backendExists($name)
141141
*/
142142
public function getFrontend($name)
143143
{
144-
if (!key_exists('ha_backends', $this->data)) {
144+
if (!is_array($this->data['ha_backends'])) {
145145
return;
146146
}
147-
if (!key_exists('item', $this->data['ha_backends'])) {
147+
if (!is_array($this->data['ha_backends']['item'])) {
148148
return;
149149
}
150150

@@ -163,10 +163,10 @@ public function getFrontend($name)
163163
*/
164164
public function getFrontendKey($name)
165165
{
166-
if (!key_exists('ha_backends', $this->data)) {
166+
if (!is_array($this->data['ha_backends'])) {
167167
return;
168168
}
169-
if (!key_exists('item', $this->data['ha_backends'])) {
169+
if (!is_array($this->data['ha_backends']['item'])) {
170170
return;
171171
}
172172

@@ -185,10 +185,10 @@ public function getFrontendKey($name)
185185
*/
186186
public function getBackend($name)
187187
{
188-
if (!key_exists('ha_pools', $this->data)) {
188+
if (!is_array($this->data['ha_pools'])) {
189189
return;
190190
}
191-
if (!key_exists('item', $this->data['ha_pools'])) {
191+
if (!is_array($this->data['ha_pools']['item'])) {
192192
return;
193193
}
194194

@@ -207,10 +207,10 @@ public function getBackend($name)
207207
*/
208208
public function getBackendKey($name)
209209
{
210-
if (!key_exists('ha_pools', $this->data)) {
210+
if (!is_array($this->data['ha_pools'])) {
211211
return;
212212
}
213-
if (!key_exists('item', $this->data['ha_pools'])) {
213+
if (!is_array($this->data['ha_pools']['item'])) {
214214
return;
215215
}
216216

@@ -228,10 +228,10 @@ public function getBackendKey($name)
228228
*/
229229
public function removeFrontend($name)
230230
{
231-
if (!key_exists('ha_backends', $this->data)) {
231+
if (!is_array($this->data['ha_backends'])) {
232232
return;
233233
}
234-
if (!key_exists('item', $this->data['ha_backends'])) {
234+
if (!is_array($this->data['ha_backends']['item'])) {
235235
return;
236236
}
237237

@@ -253,10 +253,10 @@ public function removeFrontend($name)
253253
*/
254254
public function removeBackend($name)
255255
{
256-
if (!key_exists('ha_pools', $this->data)) {
256+
if (!is_array($this->data['ha_pools'])) {
257257
return;
258258
}
259-
if (!key_exists('item', $this->data['ha_pools'])) {
259+
if (!is_array($this->data['ha_pools']['item'])) {
260260
return;
261261
}
262262

@@ -282,10 +282,10 @@ public function putFrontend($item)
282282
$key = $this->getFrontendKey($item['name']);
283283
$this->data['ha_backends']['item'][$key] = $item;
284284
} else {
285-
if (!key_exists('ha_backends', $this->data)) {
285+
if (!is_array($this->data['ha_backends'])) {
286286
$this->data['ha_backends'] = [];
287287
}
288-
if (!key_exists('item', $this->data['ha_backends'])) {
288+
if (!is_array($this->data['ha_backends']['item'])) {
289289
$this->data['ha_backends']['item'] = [];
290290
}
291291

@@ -304,10 +304,10 @@ public function putBackend($item)
304304
$key = $this->getBackendKey($item['name']);
305305
$this->data['ha_pools']['item'][$key] = $item;
306306
} else {
307-
if (!key_exists('ha_pools', $this->data)) {
307+
if (!is_array($this->data['ha_pools'])) {
308308
$this->data['ha_pools'] = [];
309309
}
310-
if (!key_exists('item', $this->data['ha_pools'])) {
310+
if (!is_array($this->data['ha_pools']['item'])) {
311311
$this->data['ha_pools']['item'] = [];
312312
}
313313

src/KubernetesPfSenseController/Plugin/MetalLB.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function init()
2929
$nodeLabelSelector = $pluginConfig['nodeLabelSelector'];
3030
$nodeFieldSelector = $pluginConfig['nodeFieldSelector'];
3131

32-
//metallb config
32+
// metallb config
3333
$watch = $controller->getKubernetesClient()->createWatch('/api/v1/watch/namespaces/metallb-system/configmaps/config', [], $this->getMetalLbConfigWatchCallback());
3434
$this->addWatch($watch);
3535

0 commit comments

Comments
 (0)