-
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
How to load / process fields.yml #50325
Conversation
Pinging @elastic/epm (Feature:EPM) |
} | ||
|
||
function keyword() { | ||
const property = getDefaultProperties(); |
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.
Another option is
const property = getDefaultProperties(); | |
const property = Object.assign(getDefaultProperties(), {type: 'keyword'}); |
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.
There will be quite a few more fields which will be added to the properties object but with if / else conditions. So I wonder if it is discouraged in js
to use the dot notation to do this directly?
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.
One situation where this is necessary is if you type the object (in TypeScript) and the properties are mandatory. Then Object.assign()
is a good way to prefill everything in one go. Other than that, I don't think so.
x-pack/legacy/plugins/integrations_manager/server/packages/fields.test.ts
Outdated
Show resolved
Hide resolved
💔 Build Failed |
…lds.test.ts Co-Authored-By: John Schulz <[email protected]>
return property; | ||
} | ||
|
||
function getBaseTemplate() { |
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.
@skh Our base elasticsearch template. Putting all these things for now but I'm aware it will not end up in the tests.
💔 Build Failed |
Would you mind adding some information what a PR is about, even if its an early draft? |
@skh Done |
const data = safeLoad(yaml.toString()); | ||
|
||
console.log(keyword()); | ||
data.forEach(data => { |
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.
Does this work? I'd do data.forEach(item => {...})
, i.e. name the argument to the callback different from the object you forEach
over, if only for readability.
|
||
console.log(keyword()); | ||
data.forEach(data => { | ||
console.log(data as Field); |
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.
as
is a TypeScript keyword, similar to a cast in Java (but as all type information is transpiled away, also not like a cast in Java. It basically makes the red squiggly underlines go away when nothing else works). It does nothing here, in particular it won't give you any added information in the console output.
💔 Build Failed |
Closing this in favor of #50474 The template has already been merged previously. |
This PR is about dumping ideas around fields.yml, templates, index patterns. The draft PR makes it possible to discuss these ideas as code often says more then a 1000 words. I don't expect that this PR itself will be merged but rather that many PR's come out of this discussions.