Skip to content

Commit

Permalink
[Maps] Remove proxyElasticMapsServiceInMaps (#116184)
Browse files Browse the repository at this point in the history
Removes the map.proxyElasticMapsServiceInMaps yml setting.
  • Loading branch information
thomasneirynck authored Oct 26, 2021
1 parent 3c9a656 commit 4a988dc
Show file tree
Hide file tree
Showing 16 changed files with 6 additions and 648 deletions.
5 changes: 0 additions & 5 deletions docs/setup/settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,6 @@ When `includeElasticMapsService` is turned off, only tile layer configured by <<
| `map.emsUrl:`
| Specifies the URL of a self hosted <<elastic-maps-server,{hosted-ems}>>

| `map.proxyElasticMapsServiceInMaps:`
| deprecated:[7.14.0,"In 8.0 and later, this setting will no longer be supported."]
Set to `true` to proxy all <<maps, Maps application>> Elastic Maps Service
requests through the {kib} server. *Default: `false`*

| [[tilemap-settings]] `map.tilemap.options.attribution:` {ess-icon}
| The map attribution string.
*Default: `"© [Elastic Maps Service](https://www.elastic.co/elastic-maps-service)"`*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ kibana_vars=(
logging.root.appenders
logging.root.level
map.includeElasticMapsService
map.proxyElasticMapsServiceInMaps
map.regionmap
map.tilemap.options.attribution
map.tilemap.options.maxZoom
map.tilemap.options.minZoom
Expand Down
8 changes: 1 addition & 7 deletions src/plugins/maps_ems/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,7 @@ export const tilemapConfigSchema = schema.object({
export const emsConfigSchema = schema.object({
tilemap: tilemapConfigSchema,
includeElasticMapsService: schema.boolean({ defaultValue: true }),
proxyElasticMapsServiceInMaps: schema.boolean({ defaultValue: false }),
emsUrl: schema.conditional(
schema.siblingRef('proxyElasticMapsServiceInMaps'),
true,
schema.never(),
schema.string({ defaultValue: '' })
),
emsUrl: schema.string({ defaultValue: '' }),
emsFileApiUrl: schema.string({ defaultValue: DEFAULT_EMS_FILE_API_URL }),
emsTileApiUrl: schema.string({ defaultValue: DEFAULT_EMS_TILE_API_URL }),
emsLandingPageUrl: schema.string({ defaultValue: DEFAULT_EMS_LANDING_PAGE_URL }),
Expand Down
1 change: 0 additions & 1 deletion src/plugins/maps_ems/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export const config: PluginConfigDescriptor<MapsEmsConfig> = {
exposeToBrowser: {
tilemap: true,
includeElasticMapsService: true,
proxyElasticMapsServiceInMaps: true,
emsUrl: true,
emsFileApiUrl: true,
emsTileApiUrl: true,
Expand Down
18 changes: 0 additions & 18 deletions x-pack/plugins/maps/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,6 @@ import { i18n } from '@kbn/i18n';
import { FeatureCollection } from 'geojson';

export const EMS_APP_NAME = 'kibana';

export const EMS_FILES_CATALOGUE_PATH = 'ems/files';
export const EMS_FILES_API_PATH = 'ems/files';
export const EMS_FILES_DEFAULT_JSON_PATH = 'file';
export const EMS_GLYPHS_PATH = 'fonts';
export const EMS_SPRITES_PATH = 'sprites';

export const EMS_TILES_CATALOGUE_PATH = 'ems/tiles';
export const EMS_TILES_API_PATH = 'ems/tiles';
export const EMS_TILES_RASTER_STYLE_PATH = 'raster/style';
export const EMS_TILES_RASTER_TILE_PATH = 'raster/tile';

export const EMS_TILES_VECTOR_STYLE_PATH = 'vector/style';
export const EMS_TILES_VECTOR_SOURCE_PATH = 'vector/source';
export const EMS_TILES_VECTOR_TILE_PATH = 'vector/tile';

export const MAP_SAVED_OBJECT_TYPE = 'map';
export const APP_ID = 'maps';
export const APP_ICON = 'gisApp';
Expand Down Expand Up @@ -306,5 +290,3 @@ export const MAPS_NEW_VECTOR_LAYER_META_CREATED_BY = 'maps-new-vector-layer';
export const MAX_DRAWING_SIZE_BYTES = 10485760; // 10MB

export const emsWorldLayerId = 'world_countries';
export const emsRegionLayerId = 'administrative_regions_lvl2';
export const emsUsaZipLayerId = 'usa_zip_codes';
1 change: 0 additions & 1 deletion x-pack/plugins/maps/common/ems_settings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const IS_ENTERPRISE_PLUS = () => true;
describe('EMSSettings', () => {
const mockConfig: IEMSConfig = {
includeElasticMapsService: true,
proxyElasticMapsServiceInMaps: false,
emsUrl: '',
emsFileApiUrl: DEFAULT_EMS_FILE_API_URL,
emsTileApiUrl: DEFAULT_EMS_TILE_API_URL,
Expand Down
5 changes: 0 additions & 5 deletions x-pack/plugins/maps/common/ems_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
export interface IEMSConfig {
emsUrl?: string;
includeElasticMapsService?: boolean;
proxyElasticMapsServiceInMaps?: boolean;
emsFileApiUrl?: string;
emsTileApiUrl?: string;
emsLandingPageUrl?: string;
Expand Down Expand Up @@ -63,10 +62,6 @@ export class EMSSettings {
}
}

isProxyElasticMapsServiceInMaps(): boolean {
return !!this._config.proxyElasticMapsServiceInMaps;
}

getEMSTileApiUrl(): string {
if (this._config.emsTileApiUrl !== DEFAULT_EMS_TILE_API_URL || !this.isEMSUrlSet()) {
return this._config.emsTileApiUrl!;
Expand Down
16 changes: 0 additions & 16 deletions x-pack/plugins/maps/public/util.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,11 @@ describe('getGlyphUrl', () => {
});
});

describe('EMS proxy enabled', () => {
beforeAll(() => {
require('./kibana_services').getEMSSettings = () => {
return {
...MOCK_EMS_SETTINGS,
isProxyElasticMapsServiceInMaps: () => true,
};
};
});

test('should return proxied EMS fonts URL', async () => {
expect(getGlyphUrl()).toBe('http://localhost/api/maps/ems/tiles/fonts/{fontstack}/{range}');
});
});

describe('EMS proxy disabled', () => {
beforeAll(() => {
require('./kibana_services').getEMSSettings = () => {
return {
...MOCK_EMS_SETTINGS,
isProxyElasticMapsServiceInMaps: () => false,
};
};
});
Expand Down
36 changes: 4 additions & 32 deletions x-pack/plugins/maps/public/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,7 @@

import { i18n } from '@kbn/i18n';
import { EMSClient, FileLayer, TMSService } from '@elastic/ems-client';
import _ from 'lodash';
import {
GIS_API_PATH,
EMS_FILES_CATALOGUE_PATH,
EMS_TILES_CATALOGUE_PATH,
EMS_GLYPHS_PATH,
EMS_APP_NAME,
FONTS_API_PATH,
} from '../common/constants';
import { EMS_APP_NAME, FONTS_API_PATH } from '../common/constants';
import { getHttp, getTilemap, getKibanaVersion, getEMSSettings } from './kibana_services';
import { getLicenseId } from './licensed_features';

Expand All @@ -39,28 +31,14 @@ export async function getEmsTmsServices(): Promise<TMSService[]> {
return getEMSClient().getTMSServices();
}

function relativeToAbsolute(url: string): string {
const a = document.createElement('a');
a.setAttribute('href', url);
return a.href;
}

let emsClient: EMSClient | null = null;
let latestLicenseId: string | undefined;
export function getEMSClient(): EMSClient {
if (!emsClient) {
const emsSettings = getEMSSettings();
const proxyPath = '';
const tileApiUrl = emsSettings!.isProxyElasticMapsServiceInMaps()
? relativeToAbsolute(
getHttp().basePath.prepend(`/${GIS_API_PATH}/${EMS_TILES_CATALOGUE_PATH}`)
)
: emsSettings!.getEMSTileApiUrl();
const fileApiUrl = emsSettings!.isProxyElasticMapsServiceInMaps()
? relativeToAbsolute(
getHttp().basePath.prepend(`/${GIS_API_PATH}/${EMS_FILES_CATALOGUE_PATH}`)
)
: emsSettings!.getEMSFileApiUrl();
const tileApiUrl = emsSettings!.getEMSTileApiUrl();
const fileApiUrl = emsSettings!.getEMSFileApiUrl();

emsClient = new EMSClient({
language: i18n.getLocale(),
Expand Down Expand Up @@ -89,13 +67,7 @@ export function getGlyphUrl(): string {
return getHttp().basePath.prepend(`/${FONTS_API_PATH}/{fontstack}/{range}`);
}

return emsSettings!.isProxyElasticMapsServiceInMaps()
? relativeToAbsolute(
getHttp().basePath.prepend(
`/${GIS_API_PATH}/${EMS_TILES_CATALOGUE_PATH}/${EMS_GLYPHS_PATH}`
)
) + `/{fontstack}/{range}`
: emsSettings!.getEMSFontLibraryUrl();
return emsSettings!.getEMSFontLibraryUrl();
}

export function isRetina(): boolean {
Expand Down
34 changes: 0 additions & 34 deletions x-pack/plugins/maps/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
* 2.0.
*/

import _ from 'lodash';
import { i18n } from '@kbn/i18n';
import { AddConfigDeprecation } from '@kbn/config';
import { PluginInitializerContext } from 'src/core/server';
import { PluginConfigDescriptor } from 'kibana/server';
import { MapsPlugin } from './plugin';
Expand All @@ -21,37 +18,6 @@ export const config: PluginConfigDescriptor<MapsXPackConfig> = {
preserveDrawingBuffer: true,
},
schema: configSchema,
deprecations: () => [
(
completeConfig: Record<string, any>,
rootPath: string,
addDeprecation: AddConfigDeprecation
) => {
if (_.get(completeConfig, 'map.proxyElasticMapsServiceInMaps') === undefined) {
return completeConfig;
}
addDeprecation({
configPath: 'map.proxyElasticMapsServiceInMaps',
documentationUrl:
'https://www.elastic.co/guide/en/kibana/current/maps-connect-to-ems.html#elastic-maps-server',
message: i18n.translate('xpack.maps.deprecation.proxyEMS.message', {
defaultMessage: 'map.proxyElasticMapsServiceInMaps is deprecated and is no longer used',
}),
correctiveActions: {
manualSteps: [
i18n.translate('xpack.maps.deprecation.proxyEMS.step1', {
defaultMessage:
'Remove "map.proxyElasticMapsServiceInMaps" in the Kibana config file, CLI flag, or environment variable (in Docker only).',
}),
i18n.translate('xpack.maps.deprecation.proxyEMS.step2', {
defaultMessage: 'Host Elastic Maps Service locally.',
}),
],
},
});
return completeConfig;
},
],
};

export const plugin = (initializerContext: PluginInitializerContext) =>
Expand Down
Loading

0 comments on commit 4a988dc

Please sign in to comment.