Skip to content

Commit

Permalink
Rename getRegistryPackage to getPackage
Browse files Browse the repository at this point in the history
  • Loading branch information
criamico committed Oct 6, 2022
1 parent f5d89d8 commit c50b7f6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const createClientMock = (): jest.Mocked<PackageClient> => ({
getInstallation: jest.fn(),
ensureInstalledPackage: jest.fn(),
fetchFindLatestPackage: jest.fn(),
getRegistryPackage: jest.fn(),
getPackage: jest.fn(),
reinstallEsAssets: jest.fn(),
});

Expand Down
10 changes: 5 additions & 5 deletions x-pack/plugins/fleet/server/services/epm/package_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { checkSuperuser } from '../../routes/security';
import { FleetUnauthorizedError } from '../../errors';

import { installTransforms, isTransform } from './elasticsearch/transform/install';
import { fetchFindLatestPackageOrThrow, getRegistryPackage } from './registry';
import { fetchFindLatestPackageOrThrow, getPackage } from './registry';
import { ensureInstalledPackage, getInstallation } from './packages';

export type InstalledAssetType = EsAssetReference;
Expand All @@ -47,7 +47,7 @@ export interface PackageClient {

fetchFindLatestPackage(packageName: string): Promise<RegistryPackage | BundledPackage>;

getRegistryPackage(
getPackage(
packageName: string,
packageVersion: string
): Promise<{ packageInfo: ArchivePackage; paths: string[] }>;
Expand Down Expand Up @@ -121,13 +121,13 @@ class PackageClientImpl implements PackageClient {
return fetchFindLatestPackageOrThrow(packageName);
}

public async getRegistryPackage(
public async getPackage(
packageName: string,
packageVersion: string,
options?: Parameters<typeof getRegistryPackage>['2']
options?: Parameters<typeof getPackage>['2']
) {
await this.#runPreflight();
return getRegistryPackage(packageName, packageVersion, options);
return getPackage(packageName, packageVersion, options);
}

public async reinstallEsAssets(
Expand Down
12 changes: 6 additions & 6 deletions x-pack/plugins/fleet/server/services/epm/packages/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,12 @@ export async function getPackageFromSource(options: {
logger.debug(`retrieved installed package ${pkgName}-${pkgVersion} from ES`);
}
}
// for packages not in cache or package storage and installed from registry, check registry
// install source is now archive in all cases
// See https://github.com/elastic/kibana/issues/115032
if (!res && pkgInstallSource === 'registry') {
try {
res = await Registry.getRegistryPackage(pkgName, pkgVersion);
logger.debug(`retrieved installed package ${pkgName}-${pkgVersion} from registry`);
res = await Registry.getPackage(pkgName, pkgVersion);
logger.debug(`retrieved installed package ${pkgName}-${pkgVersion}`);
} catch (error) {
if (error instanceof PackageFailedVerificationError) {
throw error;
Expand All @@ -291,9 +292,8 @@ export async function getPackageFromSource(options: {
}
}
} else {
// else package is not installed or installed and missing from cache and storage and installed from registry
res = await Registry.getRegistryPackage(pkgName, pkgVersion, { ignoreUnverified });
logger.debug(`retrieved uninstalled package ${pkgName}-${pkgVersion} from registry`);
res = await Registry.getPackage(pkgName, pkgVersion, { ignoreUnverified });
logger.debug(`retrieved uninstalled package ${pkgName}-${pkgVersion}`);
}
if (!res) {
throw new FleetError(`package info for ${pkgName}-${pkgVersion} does not exist`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ async function installPackageFromRegistry({
Registry.fetchFindLatestPackageOrThrow(pkgName, {
ignoreConstraints,
}),
Registry.getRegistryPackage(pkgName, pkgVersion, {
Registry.getPackage(pkgName, pkgVersion, {
ignoreUnverified: force && !neverIgnoreVerificationError,
}),
]);
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/fleet/server/services/epm/registry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ async function getPackageInfoFromArchiveOrCache(
}
}

export async function getRegistryPackage(
export async function getPackage(
name: string,
version: string,
options?: { ignoreUnverified?: boolean }
Expand Down

0 comments on commit c50b7f6

Please sign in to comment.