From c241dcd401bd2af5c37b4f15899d7dbb7d69f7fb Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Fri, 29 Oct 2021 09:47:36 -0700 Subject: [PATCH] [Fleet] Fix branch conditions to check against `main` and add skip version check config option (#116530) --- x-pack/plugins/fleet/common/types/index.ts | 3 +++ x-pack/plugins/fleet/server/index.ts | 4 ++++ x-pack/plugins/fleet/server/mocks/index.ts | 4 ++-- x-pack/plugins/fleet/server/services/epm/registry/index.ts | 7 +++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/fleet/common/types/index.ts b/x-pack/plugins/fleet/common/types/index.ts index bd970fc2cd83e..6eb31fd79aa77 100644 --- a/x-pack/plugins/fleet/common/types/index.ts +++ b/x-pack/plugins/fleet/common/types/index.ts @@ -32,6 +32,9 @@ export interface FleetConfigType { packages?: PreconfiguredPackage[]; outputs?: PreconfiguredOutput[]; agentIdVerificationEnabled?: boolean; + developer?: { + disableRegistryVersionCheck?: boolean; + }; } // Calling Object.entries(PackagesGroupedByStatus) gave `status: string` diff --git a/x-pack/plugins/fleet/server/index.ts b/x-pack/plugins/fleet/server/index.ts index 9ce361503ddf3..cdc0dfddc01e5 100644 --- a/x-pack/plugins/fleet/server/index.ts +++ b/x-pack/plugins/fleet/server/index.ts @@ -120,6 +120,10 @@ export const config: PluginConfigDescriptor = { agentPolicies: PreconfiguredAgentPoliciesSchema, outputs: PreconfiguredOutputsSchema, agentIdVerificationEnabled: schema.boolean({ defaultValue: true }), + developer: schema.object({ + // TODO: change default to false as soon as EPR issue fixed. Blocker for 8.0. + disableRegistryVersionCheck: schema.boolean({ defaultValue: true }), + }), }), }; diff --git a/x-pack/plugins/fleet/server/mocks/index.ts b/x-pack/plugins/fleet/server/mocks/index.ts index 9300e0bb6c3e1..282135c7b1bcd 100644 --- a/x-pack/plugins/fleet/server/mocks/index.ts +++ b/x-pack/plugins/fleet/server/mocks/index.ts @@ -57,8 +57,8 @@ export const createAppContextStartContractMock = (): MockedFleetAppContext => { agentIdVerificationEnabled: true, }, config$, - kibanaVersion: '8.0.0', - kibanaBranch: 'master', + kibanaVersion: '8.99.0', // Fake version :) + kibanaBranch: 'main', }; }; diff --git a/x-pack/plugins/fleet/server/services/epm/registry/index.ts b/x-pack/plugins/fleet/server/services/epm/registry/index.ts index aa2c3f1d4da3c..63779ccf944d3 100644 --- a/x-pack/plugins/fleet/server/services/epm/registry/index.ts +++ b/x-pack/plugins/fleet/server/services/epm/registry/index.ts @@ -140,6 +140,13 @@ export async function fetchFile(filePath: string): Promise { } function setKibanaVersion(url: URL) { + // TODO: change default to false as soon as EPR issue fixed. Blocker for 8.0. + const disableVersionCheck = + appContextService.getConfig()?.developer?.disableRegistryVersionCheck ?? true; + if (disableVersionCheck) { + return; + } + const kibanaVersion = appContextService.getKibanaVersion().split('-')[0]; // may be x.y.z-SNAPSHOT const kibanaBranch = appContextService.getKibanaBranch();