Skip to content

Commit d60ec93

Browse files
committed
lazy
1 parent beaaf36 commit d60ec93

File tree

1 file changed

+65
-2
lines changed

1 file changed

+65
-2
lines changed

src/ConfigEntry/ProxyConfigEntry.php

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function __construct(
7575
$this->MeshGateway = $MeshGateway ?? new MeshGatewayConfig();
7676
$this->Expose = $Expose ?? new ExposeConfig();
7777
$this->AccessLogs = $AccessLogs;
78-
$this->EnvoyExtensions = $this->setEnvoyExtensions(...$EnvoyExtensions);
78+
$this->setEnvoyExtensions(...$EnvoyExtensions);
7979
$this->FailoverPolicy = $FailoverPolicy;
8080
$this->PrioritizeByLocality = $PrioritizeByLocality;
8181
$this->Meta = $Meta;
@@ -241,7 +241,29 @@ public static function jsonUnserialize(\stdClass $decoded, null|self $into = nul
241241
{
242242
$n = $into ?? new self();
243243
foreach ($decoded as $k => $v) {
244-
$n->{$k} = $v;
244+
if ('ProxyMode' === $k) {
245+
$n->Mode = ProxyMode::from($v);
246+
} elseif ('TransparentProxy' === $k || 'transparent_proxy' === $k) {
247+
$n->TransparentProxy = TransparentProxyConfig::jsonUnserialize($v);
248+
} elseif ('MutualTLSMode' === $k || 'mutual_tls_mode' === $k) {
249+
$n->MutualTLSMode = MutualTLSMode::from($v);
250+
} elseif ('MeshGateway' === $k || 'mesh_gateway' === $k) {
251+
$n->MeshGateway = MeshGatewayConfig::jsonUnserialize($v);
252+
} elseif ('Expose' === $k) {
253+
$n->Expose = ExposeConfig::jsonUnserialize($v);
254+
} elseif ('AccessLogs' === $k || 'access_logs' === $k) {
255+
$n->AccessLogs = AccessLogsConfig::jsonUnserialize($v);
256+
} elseif ('EnvoyExtensions' === $k || 'envoy_extensions' === $k) {
257+
foreach ($v as $ext) {
258+
$n->EnvoyExtensions[] = EnvoyExtension::jsonUnserialize($ext);
259+
}
260+
} elseif ('FailoverPolicy' === $k || 'failover_policy' === $k) {
261+
$n->FailoverPolicy = ServiceResolverFailoverPolicy::jsonUnserialize($v);
262+
} elseif ('PrioritizeByLocality' === $k || 'prioritize_by_locality' === $k) {
263+
$n->PrioritizeByLocality = ServiceResolverPrioritizeByLocality::jsonUnserialize($v);
264+
} else {
265+
$n->{$k} = $v;
266+
}
245267
}
246268
return $n;
247269
}
@@ -252,4 +274,45 @@ public function jsonSerialize(): \stdClass
252274
foreach ($this->_getDynamicFields() as $k => $v) {
253275
$out->{$k} = $v;
254276
}
277+
$out->Kind = $this->Kind;
278+
$out->Name = $this->Name;
279+
if ('' !== $this->Partition) {
280+
$out->Partition = $this->Partition;
281+
}
282+
if (ProxyMode::Default !== $this->Mode) {
283+
$out->ProxyMode = $this->Mode->value;
284+
}
285+
if (null !== $this->TransparentProxy) {
286+
$out->TransparentProxy = $this->TransparentProxy->jsonSerialize();
287+
}
288+
if (MutualTLSMode::Default !== $this->MutualTLSMode) {
289+
$out->MutualTLSMode = $this->MutualTLSMode->value;
290+
}
291+
if (null !== $this->Config) {
292+
$out->Config = $this->Config;
293+
}
294+
$out->MeshGateway = $this->MeshGateway;
295+
$out->Expose = $this->Expose;
296+
if (null !== $this->AccessLogs) {
297+
$out->AccessLogs = $this->AccessLogs->jsonSerialize();
298+
}
299+
if ([] !== $this->EnvoyExtensions) {
300+
$out->EnvoyExtensions = $this->EnvoyExtensions;
301+
}
302+
if (null !== $this->FailoverPolicy) {
303+
$out->FailoverPolicy = $this->FailoverPolicy->jsonSerialize();
304+
}
305+
if (null !== $this->PrioritizeByLocality) {
306+
$out->PrioritizeByLocality = $this->PrioritizeByLocality->jsonSerialize();
307+
}
308+
if ('' !== $this->Namespace) {
309+
$out->Namespace = $this->Namespace;
310+
}
311+
if (null !== $this->Meta) {
312+
$out->Meta = $this->Meta;
313+
}
314+
$out->CreateIndex = $this->CreateIndex;
315+
$out->ModifyIndex = $this->ModifyIndex;
316+
return $out;
317+
}
255318
}

0 commit comments

Comments
 (0)