Skip to content

Commit 9c523b9

Browse files
committed
Fix bug in Joi config
1 parent 2f410ac commit 9c523b9

File tree

1 file changed

+8
-14
lines changed
  • src/legacy/core_plugins/telemetry

1 file changed

+8
-14
lines changed

src/legacy/core_plugins/telemetry/index.ts

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,13 @@ const telemetry = (kibana: any) => {
4646
config(Joi: typeof JoiNamespace) {
4747
return Joi.object({
4848
enabled: Joi.boolean().default(true),
49-
optIn: Joi.boolean()
50-
.allow(null)
51-
.default(null),
49+
optIn: Joi.when('allowChangingOptInStatus', {
50+
is: false,
51+
then: Joi.valid(true),
52+
otherwise: Joi.boolean()
53+
.allow(null)
54+
.default(null),
55+
}),
5256
allowChangingOptInStatus: Joi.boolean().default(true),
5357
// `config` is used internally and not intended to be set
5458
config: Joi.string().default(Joi.ref('$defaultConfigPath')),
@@ -65,17 +69,7 @@ const telemetry = (kibana: any) => {
6569
`https://telemetry.elastic.co/xpack/${ENDPOINT_VERSION}/send`
6670
),
6771
}),
68-
})
69-
.when(
70-
Joi.object({
71-
optIn: Joi.valid(null).valid(false),
72-
allowChangingOptInStatus: false,
73-
}).unknown(),
74-
{
75-
then: Joi.object({ allowChangingOptInStatus: Joi.invalid(false) }),
76-
}
77-
)
78-
.default();
72+
}).default();
7973
},
8074
uiExports: {
8175
managementSections: ['plugins/telemetry/views/management'],

0 commit comments

Comments
 (0)