-
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
[Ingest Manager] Simplify createInstallation interface #83180
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 |
---|---|---|
|
@@ -4,18 +4,24 @@ | |
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { SavedObject, SavedObjectsClientContract } from 'src/core/server'; | ||
import semver from 'semver'; | ||
import Boom from '@hapi/boom'; | ||
import { UnwrapPromise } from '@kbn/utility-types'; | ||
import { BulkInstallPackageInfo, InstallSource, defaultPackages } from '../../../../common'; | ||
import { SavedObject, SavedObjectsClientContract } from 'src/core/server'; | ||
import { generateESIndexPatterns } from '../elasticsearch/template/template'; | ||
import { isRequiredPackage } from './index'; | ||
import { | ||
BulkInstallPackageInfo, | ||
InstallablePackage, | ||
InstallSource, | ||
defaultPackages, | ||
} from '../../../../common'; | ||
import { PACKAGES_SAVED_OBJECT_TYPE, MAX_TIME_COMPLETE_INSTALL } from '../../../constants'; | ||
import { | ||
AssetReference, | ||
Installation, | ||
CallESAsCurrentUser, | ||
AssetType, | ||
KibanaAssetReference, | ||
EsAssetReference, | ||
InstallType, | ||
KibanaAssetType, | ||
|
@@ -346,31 +352,19 @@ export const updateVersion = async ( | |
}; | ||
export async function createInstallation(options: { | ||
savedObjectsClient: SavedObjectsClientContract; | ||
pkgName: string; | ||
pkgVersion: string; | ||
internal: boolean; | ||
removable: boolean; | ||
installed_kibana: KibanaAssetReference[]; | ||
installed_es: EsAssetReference[]; | ||
toSaveESIndexPatterns: Record<string, string>; | ||
packageInfo: InstallablePackage; | ||
installSource: InstallSource; | ||
}) { | ||
const { | ||
savedObjectsClient, | ||
pkgName, | ||
pkgVersion, | ||
internal, | ||
removable, | ||
installed_kibana: installedKibana, | ||
installed_es: installedEs, | ||
toSaveESIndexPatterns, | ||
installSource, | ||
} = options; | ||
await savedObjectsClient.create<Installation>( | ||
const { savedObjectsClient, packageInfo, installSource } = options; | ||
const { internal = false, name: pkgName, version: pkgVersion } = packageInfo; | ||
const removable = !isRequiredPackage(pkgName); | ||
const toSaveESIndexPatterns = generateESIndexPatterns(packageInfo.data_streams); | ||
|
||
const created = await savedObjectsClient.create<Installation>( | ||
PACKAGES_SAVED_OBJECT_TYPE, | ||
{ | ||
installed_kibana: installedKibana, | ||
installed_es: installedEs, | ||
installed_kibana: [], | ||
installed_es: [], | ||
es_index_patterns: toSaveESIndexPatterns, | ||
name: pkgName, | ||
version: pkgVersion, | ||
|
@@ -383,7 +377,8 @@ export async function createInstallation(options: { | |
}, | ||
{ id: pkgName, overwrite: true } | ||
); | ||
return [...installedKibana, ...installedEs]; | ||
|
||
return created; | ||
Comment on lines
-386
to
+381
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. If I understand the existing code correctly (both reading & running with logging), we always passed empty arrays for the two Even if they had values, rather than return the caller data they gave, return the result of the function. The return value isn't used by the one caller so this is safe and unnoticed. |
||
} | ||
|
||
export const saveKibanaAssetsRefs = async ( | ||
|
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.
Swapped the condition to avoid the double-negative (!!installedPkg)