Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion x-pack/plugins/ingest_manager/common/constants/epm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@

export const PACKAGES_SAVED_OBJECT_TYPE = 'epm-packages';
export const INDEX_PATTERN_SAVED_OBJECT_TYPE = 'index-pattern';
export const DEFAULT_REGISTRY_URL = 'https://epr-snapshot.ea-web.elastic.dev';
export const INDEX_PATTERN_PLACEHOLDER_SUFFIX = '-index_pattern_placeholder';
1 change: 0 additions & 1 deletion x-pack/plugins/ingest_manager/server/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,4 @@ export {
// Defaults
DEFAULT_AGENT_CONFIG,
DEFAULT_OUTPUT,
DEFAULT_REGISTRY_URL,
} from '../../common';
2 changes: 1 addition & 1 deletion x-pack/plugins/ingest_manager/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { schema, TypeOf } from '@kbn/config-schema';
import { PluginInitializerContext } from 'src/core/server';
import { IngestManagerPlugin } from './plugin';
export { AgentService, ESIndexPatternService } from './services';
export { AgentService, ESIndexPatternService, getRegistryUrl } from './services';
export {
IngestManagerSetupContract,
IngestManagerSetupDeps,
Expand Down
15 changes: 7 additions & 8 deletions x-pack/plugins/ingest_manager/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
HttpServiceSetup,
} from 'kibana/server';
import { UsageCollectionSetup } from 'src/plugins/usage_collection/server';
import packageJSON from '../../../../package.json';
import { LicensingPluginSetup, ILicense } from '../../licensing/server';
import {
EncryptedSavedObjectsPluginStart,
Expand Down Expand Up @@ -84,9 +83,9 @@ export interface IngestManagerAppContext {
security?: SecurityPluginSetup;
config$?: Observable<IngestManagerConfigType>;
savedObjects: SavedObjectsServiceStart;
isProductionMode: boolean;
kibanaVersion: string;
kibanaBranch: string;
isProductionMode: PluginInitializerContext['env']['mode']['prod'];
kibanaVersion: PluginInitializerContext['env']['packageInfo']['version'];
kibanaBranch: PluginInitializerContext['env']['packageInfo']['branch'];
cloud?: CloudSetup;
logger?: Logger;
httpSetup?: HttpServiceSetup;
Expand Down Expand Up @@ -145,17 +144,17 @@ export class IngestManagerPlugin
private cloud: CloudSetup | undefined;
private logger: Logger | undefined;

private isProductionMode: boolean;
private kibanaVersion: string;
private kibanaBranch: string;
private isProductionMode: IngestManagerAppContext['isProductionMode'];
private kibanaVersion: IngestManagerAppContext['kibanaVersion'];
private kibanaBranch: IngestManagerAppContext['kibanaBranch'];
private httpSetup: HttpServiceSetup | undefined;
private encryptedSavedObjectsSetup: EncryptedSavedObjectsPluginSetup | undefined;

constructor(private readonly initializerContext: PluginInitializerContext) {
this.config$ = this.initializerContext.config.create<IngestManagerConfigType>();
this.isProductionMode = this.initializerContext.env.mode.prod;
this.kibanaVersion = this.initializerContext.env.packageInfo.version;
this.kibanaBranch = packageJSON.branch;
this.kibanaBranch = this.initializerContext.env.packageInfo.branch;
this.logger = this.initializerContext.logger.get();
}

Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/ingest_manager/server/services/app_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class AppContextService {
private config$?: Observable<IngestManagerConfigType>;
private configSubject$?: BehaviorSubject<IngestManagerConfigType>;
private savedObjects: SavedObjectsServiceStart | undefined;
private isProductionMode: boolean = false;
private kibanaVersion: string | undefined;
private kibanaBranch: string | undefined;
private isProductionMode: IngestManagerAppContext['isProductionMode'] = false;
private kibanaVersion: IngestManagerAppContext['kibanaVersion'] | undefined;
private kibanaBranch: IngestManagerAppContext['kibanaBranch'] | undefined;
private cloud?: CloudSetup;
private logger: Logger | undefined;
private httpSetup?: HttpServiceSetup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,43 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { DEFAULT_REGISTRY_URL } from '../../../constants';
import { appContextService, licenseService } from '../../';

// from https://github.com/elastic/package-registry#docker (maybe from OpenAPI one day)
// the unused variables cause a TS warning about unused values
// chose to comment them out vs @ts-ignore or @ts-expect-error on each line

const PRODUCTION_REGISTRY_URL_CDN = 'https://epr.elastic.co';
// const STAGING_REGISTRY_URL_CDN = 'https://epr-staging.elastic.co';
// const EXPERIMENTAL_REGISTRY_URL_CDN = 'https://epr-experimental.elastic.co/';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Experimental should not be here as this will never apply for master or anything coming out of master. Same on line 19.

const SNAPSHOT_REGISTRY_URL_CDN = 'https://epr-snapshot.elastic.co';

// const PRODUCTION_REGISTRY_URL_NO_CDN = 'https://epr.ea-web.elastic.dev';
// const STAGING_REGISTRY_URL_NO_CDN = 'https://epr-staging.ea-web.elastic.dev';
// const EXPERIMENTAL_REGISTRY_URL_NO_CDN = 'https://epr-experimental.ea-web.elastic.dev/';
// const SNAPSHOT_REGISTRY_URL_NO_CDN = 'https://epr-snapshot.ea-web.elastic.dev';

const getDefaultRegistryUrl = (): string => {
const branch = appContextService.getKibanaBranch();
if (branch === 'master') {
return SNAPSHOT_REGISTRY_URL_CDN;
} else {
return PRODUCTION_REGISTRY_URL_CDN;
}
};

export const getRegistryUrl = (): string => {
const license = licenseService.getLicenseInformation();
const customUrl = appContextService.getConfig()?.registryUrl;
const isGoldPlus = license?.isAvailable && license?.isActive && license?.hasAtLeast('gold');

if (
customUrl &&
license &&
license.isAvailable &&
license.hasAtLeast('gold') &&
license.isActive
) {
if (customUrl && isGoldPlus) {
return customUrl;
}

if (customUrl) {
appContextService.getLogger().warn('Gold license is required to use a custom registry url.');
}

return DEFAULT_REGISTRY_URL;
return getDefaultRegistryUrl();
};
2 changes: 2 additions & 0 deletions x-pack/plugins/ingest_manager/server/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { AgentStatus, Agent } from '../types';
import * as settingsService from './settings';
export { ESIndexPatternSavedObjectService } from './es_index_pattern';

export { getRegistryUrl } from './epm/registry/registry_url';

/**
* Service to return the index pattern of EPM packages
*/
Expand Down
4 changes: 2 additions & 2 deletions x-pack/test/security_solution_endpoint/apps/endpoint/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { DEFAULT_REGISTRY_URL } from '../../../../plugins/ingest_manager/common';
import { getRegistryUrl as getRegistryUrlFromIngest } from '../../../../plugins/ingest_manager/server';
import { FtrProviderContext } from '../../ftr_provider_context';
import {
isRegistryEnabled,
Expand All @@ -22,7 +22,7 @@ export default function (providerContext: FtrProviderContext) {
log.warning('These tests are being run with an external package registry');
}

const registryUrl = getRegistryUrl() ?? DEFAULT_REGISTRY_URL;
const registryUrl = getRegistryUrl() ?? getRegistryUrlFromIngest();
log.info(`Package registry URL for tests: ${registryUrl}`);

before(async () => {
Expand Down
4 changes: 2 additions & 2 deletions x-pack/test/security_solution_endpoint_api_int/apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
import { FtrProviderContext } from '../ftr_provider_context';
import { isRegistryEnabled, getRegistryUrl } from '../registry';
import { DEFAULT_REGISTRY_URL } from '../../../plugins/ingest_manager/common';
import { getRegistryUrl as getRegistryUrlFromIngest } from '../../../plugins/ingest_manager/server';

export default function endpointAPIIntegrationTests(providerContext: FtrProviderContext) {
const { loadTestFile, getService } = providerContext;
Expand All @@ -20,7 +20,7 @@ export default function endpointAPIIntegrationTests(providerContext: FtrProvider
log.warning('These tests are being run with an external package registry');
}

const registryUrl = getRegistryUrl() ?? DEFAULT_REGISTRY_URL;
const registryUrl = getRegistryUrl() ?? getRegistryUrlFromIngest();
log.info(`Package registry URL for tests: ${registryUrl}`);

before(async () => {
Expand Down