Skip to content
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

Closed
wants to merge 3 commits into from

Conversation

ruflin
Copy link
Member

@ruflin ruflin commented Nov 12, 2019

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.

@ruflin ruflin added the Feature:EPM Fleet team's Elastic Package Manager (aka Integrations) project label Nov 12, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/epm (Feature:EPM)

}

function keyword() {
const property = getDefaultProperties();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option is

Suggested change
const property = getDefaultProperties();
const property = Object.assign(getDefaultProperties(), {type: 'keyword'});

Copy link
Member Author

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?

Copy link
Contributor

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.

@elasticmachine
Copy link
Contributor

💔 Build Failed

return property;
}

function getBaseTemplate() {
Copy link
Member Author

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.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@skh
Copy link
Contributor

skh commented Nov 13, 2019

No description provided.

Would you mind adding some information what a PR is about, even if its an early draft?

@ruflin
Copy link
Member Author

ruflin commented Nov 13, 2019

@skh Done

const data = safeLoad(yaml.toString());

console.log(keyword());
data.forEach(data => {
Copy link
Contributor

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);
Copy link
Contributor

@skh skh Nov 13, 2019

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.

@ruflin ruflin self-assigned this Nov 18, 2019
@ruflin ruflin changed the base branch from feature-integrations-manager to feature-ingest November 19, 2019 08:40
@elasticmachine
Copy link
Contributor

💔 Build Failed

@ruflin
Copy link
Member Author

ruflin commented Nov 20, 2019

Closing this in favor of #50474 The template has already been merged previously.

@ruflin ruflin closed this Nov 20, 2019
@jen-huang jen-huang added the Team:Fleet Team label for Observability Data Collection Fleet team label Mar 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:EPM Fleet team's Elastic Package Manager (aka Integrations) project Team:Fleet Team label for Observability Data Collection Fleet team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants