Skip to content

Commit

Permalink
pkgVersion optional
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaElastic committed Dec 7, 2021
1 parent 9aa9a61 commit 023af3e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 7 additions & 3 deletions x-pack/plugins/fleet/server/routes/epm/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,14 @@ export const getInfoHandler: FleetRequestHandler<TypeOf<typeof GetInfoRequestSch
try {
const savedObjectsClient = context.fleet.epm.internalSoClient;
const { pkgName, pkgVersion } = request.params;
if (!semverValid(pkgVersion)) {
if (pkgVersion && !semverValid(pkgVersion)) {
throw new IngestManagerError('Package version is not a valid semver');
}
const res = await getPackageInfo({ savedObjectsClient, pkgName, pkgVersion });
const res = await getPackageInfo({
savedObjectsClient,
pkgName,
pkgVersion: pkgVersion || '',
});
const body: GetInfoResponse = {
item: res,
};
Expand Down Expand Up @@ -254,7 +258,7 @@ export const installPackageFromRegistryHandler: FleetRequestHandler<
const res = await installPackage({
installSource: 'registry',
savedObjectsClient,
pkgkey: `${pkgName}-${pkgVersion}`,
pkgkey: pkgVersion ? `${pkgName}-${pkgVersion}` : pkgName,
esClient,
force: request.body?.force,
});
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/fleet/server/types/rest_spec/epm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const GetFileRequestSchema = {
export const GetInfoRequestSchema = {
params: schema.object({
pkgName: schema.string(),
pkgVersion: schema.string(),
pkgVersion: schema.maybe(schema.string()),
}),
};

Expand All @@ -45,7 +45,7 @@ export const GetInfoRequestSchemaDeprecated = {
export const UpdatePackageRequestSchema = {
params: schema.object({
pkgName: schema.string(),
pkgVersion: schema.string(),
pkgVersion: schema.maybe(schema.string()),
}),
body: schema.object({
keepPoliciesUpToDate: schema.boolean(),
Expand All @@ -70,7 +70,7 @@ export const GetStatsRequestSchema = {
export const InstallPackageFromRegistryRequestSchema = {
params: schema.object({
pkgName: schema.string(),
pkgVersion: schema.string(),
pkgVersion: schema.maybe(schema.string()),
}),
body: schema.nullable(
schema.object({
Expand Down

0 comments on commit 023af3e

Please sign in to comment.