-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[deb/rpm] Generate os package specific kibana.yml #98213
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
33f1ece
[deb/rpm] Generate os package specific kibana.yml
jbudz 6467862
verify writes
jbudz 66cd259
verify changes
jbudz 127a6b5
Merge branch 'master' into os/kibana_yml
kibanamachine 3dad550
Merge branch 'master' into os/kibana_yml
kibanamachine 8980fa6
Merge branch 'master' into os/kibana_yml
kibanamachine d569d62
Merge branch 'master' into os/kibana_yml
kibanamachine 3f6b7c9
Merge branch 'master' into os/kibana_yml
kibanamachine 4dcd009
Merge branch 'master' into os/kibana_yml
kibanamachine 0202d0f
Merge branch 'master' into os/kibana_yml
kibanamachine 08867af
Merge branch 'master' into os/kibana_yml
kibanamachine 9e7edbf
Merge branch 'master' into os/kibana_yml
kibanamachine 55f15b1
Merge branch 'master' into os/kibana_yml
kibanamachine 49692f9
Merge branch 'master' into os/kibana_yml
kibanamachine 67a906b
Merge branch 'master' into os/kibana_yml
kibanamachine 39aa285
Merge branch 'master' into os/kibana_yml
kibanamachine f78fdb6
Merge branch 'master' into os/kibana_yml
kibanamachine aa3a0ca
Merge branch 'master' into os/kibana_yml
kibanamachine dac637c
Merge branch 'master' into os/kibana_yml
kibanamachine a859c3d
Merge branch 'master' into os/kibana_yml
kibanamachine fca991d
Merge branch 'master' into os/kibana_yml
kibanamachine e22c352
Merge branch 'master' into os/kibana_yml
kibanamachine 3d1438e
Merge branch 'master' into os/kibana_yml
kibanamachine 3a4eec8
Merge branch 'master' into os/kibana_yml
kibanamachine f4b0f12
Merge branch 'master' into os/kibana_yml
kibanamachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/dev/build/tasks/os_packages/create_os_package_kibana_yml.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { readFileSync, writeFileSync } from 'fs'; | ||
import { resolve } from 'path'; | ||
import { Build, Config, mkdirp } from '../../lib'; | ||
|
||
export async function createOSPackageKibanaYML(config: Config, build: Build) { | ||
const configReadPath = config.resolveFromRepo('config', 'kibana.yml'); | ||
const configWriteDir = config.resolveFromRepo('build', 'os_packages', 'config'); | ||
const configWritePath = resolve(configWriteDir, 'kibana.yml'); | ||
|
||
await mkdirp(configWriteDir); | ||
|
||
let kibanaYML = readFileSync(configReadPath, { encoding: 'utf8' }); | ||
|
||
[ | ||
[/#pid.file:.*/g, 'pid.file: /run/kibana/kibana.pid'], | ||
[/#logging.dest:.*/g, 'logging.dest: /var/log/kibana/kibana.log'], | ||
].forEach((options) => { | ||
const [regex, setting] = options; | ||
const diff = kibanaYML; | ||
const match = kibanaYML.search(regex) >= 0; | ||
if (match) { | ||
if (typeof setting === 'string') { | ||
kibanaYML = kibanaYML.replace(regex, setting); | ||
} | ||
} | ||
|
||
if (!diff.localeCompare(kibanaYML)) { | ||
throw new Error( | ||
`OS package configuration unmodified. Verify match for ${regex} is available` | ||
); | ||
} | ||
}); | ||
|
||
try { | ||
writeFileSync(configWritePath, kibanaYML, { flag: 'wx' }); | ||
} catch (err) { | ||
if (err.code === 'EEXIST') { | ||
return; | ||
} | ||
throw err; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'm iffy on this approach, but it does work. I looked into templating kibana.yml while preserving it's relatively static nature. Turning it into a template would remove validity of the yml, leading to more duplication.
Any thoughts here?