(redisConfig)
| 121 | } |
| 122 | |
| 123 | function parseRedisConfig(redisConfig) { |
| 124 | const joiSchema = joi.object({ |
| 125 | password: joi.string().allow(''), |
| 126 | host: joi.string(), |
| 127 | port: joi.number(), |
| 128 | retry: joi.object({ |
| 129 | connectBackoff: joi.object({ |
| 130 | min: joi.number().required(), |
| 131 | max: joi.number().required(), |
| 132 | jitter: joi.number().required(), |
| 133 | factor: joi.number().required(), |
| 134 | deadline: joi.number().required(), |
| 135 | }), |
| 136 | }), |
| 137 | // sentinel config |
| 138 | sentinels: joi.alternatives().try( |
| 139 | joi.string() |
| 140 | .pattern(/^[a-zA-Z0-9.-]+:[0-9]+(,[a-zA-Z0-9.-]+:[0-9]+)*$/) |
| 141 | .custom(hosts => hosts.split(',').map(item => { |
| 142 | const [host, port] = item.split(':'); |
| 143 | return { host, port: Number.parseInt(port, 10) }; |
| 144 | })), |
| 145 | joi.array().items( |
| 146 | joi.object({ |
| 147 | host: joi.string().required(), |
| 148 | port: joi.number().required(), |
| 149 | }) |
| 150 | ).min(1), |
| 151 | ), |
| 152 | name: joi.string(), |
| 153 | sentinelPassword: joi.string().allow(''), |
| 154 | }) |
| 155 | .and('host', 'port') |
| 156 | .and('sentinels', 'name') |
| 157 | .xor('host', 'sentinels') |
| 158 | .without('sentinels', ['host', 'port']) |
| 159 | .without('host', ['sentinels', 'sentinelPassword']); |
| 160 | |
| 161 | return joi.attempt(redisConfig, joiSchema, 'bad config'); |
| 162 | } |
| 163 | |
| 164 | function parseSupportedLifecycleRules(supportedLifecycleRulesConfig) { |
| 165 | const supportedLifecycleRulesSchema = joi.array() |
no outgoing calls
no test coverage detected