-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Adding post create package callback #128744
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
Changes from all commits
348c5f7
2abdcad
cc49725
cfa7ef2
b229fcf
c9cb7a4
c213090
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 |
|---|---|---|
|
|
@@ -55,6 +55,7 @@ const PackagePolicyStreamsSchema = { | |
| }) | ||
| ) | ||
| ), | ||
| compiled_stream: schema.maybe(schema.any()), | ||
| }; | ||
|
|
||
| const PackagePolicyInputsSchema = { | ||
|
|
@@ -150,4 +151,24 @@ export const PackagePolicySchema = schema.object({ | |
| ...PackagePolicyBaseSchema, | ||
| id: schema.string(), | ||
| version: schema.maybe(schema.string()), | ||
| revision: schema.number(), | ||
| updated_at: schema.string(), | ||
| updated_by: schema.string(), | ||
| created_at: schema.string(), | ||
| created_by: schema.string(), | ||
| elasticsearch: schema.maybe( | ||
| schema.object({ | ||
| privileges: schema.maybe( | ||
| schema.object({ | ||
| cluster: schema.maybe(schema.arrayOf(schema.string())), | ||
| }) | ||
| ), | ||
| }) | ||
| ), | ||
| inputs: schema.arrayOf( | ||
| schema.object({ | ||
| ...PackagePolicyInputsSchema, | ||
| compiled_input: schema.maybe(schema.any()), | ||
| }) | ||
| ), | ||
|
Contributor
Author
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. Hey @joshdover, I re-request your review according to this change, I tried to use this scheme for validation and found that is not aligned with the PackagePolicy type. export interface PackagePolicy extends Omit<NewPackagePolicy, 'inputs'> {
id: string;
inputs: PackagePolicyInput[];
version?: string;
revision: number;
updated_at: string;
updated_by: string;
created_at: string;
created_by: string;
}
Contributor
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. Thanks for the ping, this change makes sense. At first I thought that maybe the In the future, we may want to try refactoring this to derive the TS types from the config schema using the |
||
| }); | ||
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.
FYI Calling this in the handler means this will not work for preconfigured package policies, we already have the bug for other callbacks so it should probably not be addressed here #129383
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.
Great callout, agreed it'd be ok to defer on this and fix it for all callbacks in the same PR. That way they're all at least consistent.
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.
🤔 because the extension points are executed from the PackagePolicy service, I'm assuming the fix to the mentioned issue is to call the service method (
runExternalCallbacks()) from the location where the preconfigured packages policies are added/updated while still leaving this code here in place.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.
I think the idea would be to have
packagePolicyService.createcallrunExternalCallbacksbefore returning the newly created policy to the caller. That way there is only a single call site that always runs regardless of how the package policy was created.