-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add xpack.cloud.full_story configuration #102363
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { config } from './config'; | ||
|
||
describe('xpack.cloud config', () => { | ||
describe('full_story', () => { | ||
it('allows orgId when enabled: false', () => { | ||
expect(() => | ||
config.schema.validate({ full_story: { enabled: false, org_id: 'asdf' } }) | ||
).not.toThrow(); | ||
}); | ||
|
||
it('rejects undefined or empty orgId when enabled: true', () => { | ||
expect(() => | ||
config.schema.validate({ full_story: { enabled: true } }) | ||
).toThrowErrorMatchingInlineSnapshot( | ||
`"[full_story.org_id]: expected value of type [string] but got [undefined]"` | ||
); | ||
expect(() => | ||
config.schema.validate({ full_story: { enabled: true, org_id: '' } }) | ||
).toThrowErrorMatchingInlineSnapshot( | ||
`"[full_story.org_id]: value has length [0] but it must have a minimum length of [1]."` | ||
); | ||
}); | ||
|
||
it('accepts orgId when enabled: true', () => { | ||
expect(() => | ||
config.schema.validate({ full_story: { enabled: true, org_id: 'asdf' } }) | ||
).not.toThrow(); | ||
}); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,16 @@ const apmConfigSchema = schema.object({ | |
), | ||
}); | ||
|
||
const fullStoryConfigSchema = schema.object({ | ||
enabled: schema.boolean({ defaultValue: false }), | ||
org_id: schema.conditional( | ||
schema.siblingRef('enabled'), | ||
true, | ||
schema.string({ minLength: 1 }), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we sure we want to set the min to 1? It seems very lenient to me. Maybe 3 would be better? It gives a few more combinations and permutations. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wasn't sure how long these strings could be from FullStory. I doubt we'd ever have one that is only 1 character, but not sure where to put the limit (3, 4, 5?). I figured instead of trying to figure that out to just guard against the most likely misconfiguration which is an empty string. |
||
schema.maybe(schema.string()) | ||
), | ||
}); | ||
|
||
const configSchema = schema.object({ | ||
enabled: schema.boolean({ defaultValue: true }), | ||
id: schema.maybe(schema.string()), | ||
|
@@ -27,6 +37,7 @@ const configSchema = schema.object({ | |
profile_url: schema.maybe(schema.string()), | ||
deployment_url: schema.maybe(schema.string()), | ||
organization_url: schema.maybe(schema.string()), | ||
full_story: fullStoryConfigSchema, | ||
}); | ||
|
||
export type CloudConfigType = TypeOf<typeof configSchema>; | ||
|
@@ -39,6 +50,7 @@ export const config: PluginConfigDescriptor<CloudConfigType> = { | |
profile_url: true, | ||
deployment_url: true, | ||
organization_url: true, | ||
full_story: true, | ||
}, | ||
schema: configSchema, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
orgId -> org_id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Auto merge got this, will fix on next PR.