1 | <?php |
||
15 | class ConsulEnvManager |
||
16 | { |
||
17 | /** |
||
18 | * @var KVInterface |
||
19 | */ |
||
20 | protected $kv; |
||
21 | |||
22 | /** |
||
23 | * @var bool |
||
24 | */ |
||
25 | protected $overwriteEvenIfDefined = false; |
||
26 | |||
27 | /** |
||
28 | * ConsulEnvManager constructor. |
||
29 | * |
||
30 | * @param KVInterface $kv |
||
31 | * @param bool $overwriteEvenIfDefined |
||
32 | */ |
||
33 | 8 | public function __construct(KVInterface $kv, bool $overwriteEvenIfDefined = false) |
|
38 | |||
39 | /** |
||
40 | * Add missing environment variables from Consul. |
||
41 | * |
||
42 | * @param array $mappings |
||
43 | */ |
||
44 | 3 | public function getEnvVarsFromConsul(array $mappings) |
|
56 | |||
57 | /** |
||
58 | * Expose a set of mappings into the container builder. |
||
59 | * |
||
60 | * @param ContainerBuilder $container |
||
61 | * @param array $mappings |
||
62 | * |
||
63 | * @return ContainerBuilder |
||
64 | */ |
||
65 | 1 | public function exposeEnvironmentIntoContainer(ContainerBuilder $container, array $mappings): ContainerBuilder |
|
73 | |||
74 | /** |
||
75 | * Check if an environment key is defined. |
||
76 | * |
||
77 | * @param string $environmentKey |
||
78 | * |
||
79 | * @return bool |
||
80 | */ |
||
81 | 3 | private function keyIsDefined(string $environmentKey): bool |
|
91 | |||
92 | /** |
||
93 | * Get a key value from Consul. |
||
94 | * |
||
95 | * @param string $kvPath |
||
96 | * |
||
97 | * @return string |
||
98 | */ |
||
99 | 2 | private function getKeyValueFromConsul(string $kvPath): string |
|
103 | |||
104 | /** |
||
105 | * Save the value of a key in an environment variable. |
||
106 | * |
||
107 | * @param string $envKey |
||
108 | * @param string $kvValue |
||
109 | */ |
||
110 | 2 | private function saveKeyValueInEnvironmentVars($envKey, $kvValue) |
|
114 | } |
||
115 |