Skip to content

Commit

Permalink
Rename HttpServerInfo.host to hostname (#70792)
Browse files Browse the repository at this point in the history
* rename host to hostname

* update generated doc

* adapt tests

* fix types
  • Loading branch information
pgayvallet authored Jul 7, 2020
1 parent 2f905e7 commit e7c54d3
Show file tree
Hide file tree
Showing 16 changed files with 19 additions and 32 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface HttpServerInfo

| Property | Type | Description |
| --- | --- | --- |
| [host](./kibana-plugin-core-server.httpserverinfo.host.md) | <code>string</code> | The hostname of the server |
| [hostname](./kibana-plugin-core-server.httpserverinfo.hostname.md) | <code>string</code> | The hostname of the server |
| [name](./kibana-plugin-core-server.httpserverinfo.name.md) | <code>string</code> | The name of the Kibana server |
| [port](./kibana-plugin-core-server.httpserverinfo.port.md) | <code>number</code> | The port the server is listening on |
| [protocol](./kibana-plugin-core-server.httpserverinfo.protocol.md) | <code>'http' &#124; 'https' &#124; 'socket'</code> | The protocol used by the server |
Expand Down
4 changes: 2 additions & 2 deletions src/core/server/http/http_server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ describe('setup contract', () => {
let { getServerInfo } = await server.setup(config);

expect(getServerInfo()).toEqual({
host: '127.0.0.1',
hostname: '127.0.0.1',
name: 'kibana',
port: 10002,
protocol: 'http',
Expand All @@ -1065,7 +1065,7 @@ describe('setup contract', () => {
}));

expect(getServerInfo()).toEqual({
host: 'localhost',
hostname: 'localhost',
name: 'custom-name',
port: 12345,
protocol: 'http',
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/http/http_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class HttpServer {
getAuthHeaders: this.authRequestHeaders.get,
getServerInfo: () => ({
name: config.name,
host: config.host,
hostname: config.host,
port: config.port,
protocol: this.server!.info.protocol,
}),
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/http/http_service.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const createInternalSetupContractMock = () => {
mock.createRouter.mockImplementation(() => mockRouter.create());
mock.getAuthHeaders.mockReturnValue({ authorization: 'authorization-header' });
mock.getServerInfo.mockReturnValue({
host: 'localhost',
hostname: 'localhost',
name: 'kibana',
port: 80,
protocol: 'http',
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/http/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ export interface HttpServerInfo {
/** The name of the Kibana server */
name: string;
/** The hostname of the server */
host: string;
hostname: string;
/** The port the server is listening on */
port: number;
/** The protocol used by the server */
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ export type HttpResponsePayload = undefined | string | Record<string, any> | Buf

// @public (undocumented)
export interface HttpServerInfo {
host: string;
hostname: string;
name: string;
port: number;
protocol: 'http' | 'https' | 'socket';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const registerRoutes = ({
(await settingsService.getSettings(soClient)).kibana_url ||
url.format({
protocol: serverInfo.protocol,
hostname: serverInfo.host,
hostname: serverInfo.hostname,
port: serverInfo.port,
pathname: basePath.serverBasePath,
});
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/ingest_manager/server/services/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export async function setupIngestManager(
const flagsUrl = appContextService.getConfig()?.fleet?.kibana?.host;
const defaultUrl = url.format({
protocol: serverInfo.protocol,
hostname: serverInfo.host,
hostname: serverInfo.hostname,
port: serverInfo.port,
pathname: basePath.serverBasePath,
});
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/monitoring/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ export class Plugin {
uuid: core.uuid.getInstanceUuid(),
name: serverInfo.name,
index: get(legacyConfig, 'kibana.index'),
host: serverInfo.host,
host: serverInfo.hostname,
locale: i18n.getLocale(),
port: serverInfo.port.toString(),
transport_address: `${serverInfo.host}:${serverInfo.port}`,
transport_address: `${serverInfo.hostname}:${serverInfo.port}`,
version: this.initializerContext.env.packageInfo.version,
snapshot: snapshotRegex.test(this.initializerContext.env.packageInfo.version),
},
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/reporting/server/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const buildConfig = async (
},
server: {
basePath: core.http.basePath.serverBasePath,
host: serverInfo.host,
host: serverInfo.hostname,
name: serverInfo.name,
port: serverInfo.port,
uuid: core.uuid.getInstanceUuid(),
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/reporting/server/config/create_config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { createConfig$ } from './create_config';
import { ReportingConfigType } from './schema';

interface KibanaServer {
host?: string;
hostname?: string;
port?: number;
protocol?: string;
}
Expand Down Expand Up @@ -41,7 +41,7 @@ describe('Reporting server createConfig$', () => {
let mockLogger: LevelLogger;

beforeEach(() => {
mockCoreSetup = makeMockCoreSetup({ host: 'kibanaHost', port: 5601, protocol: 'http' });
mockCoreSetup = makeMockCoreSetup({ hostname: 'kibanaHost', port: 5601, protocol: 'http' });
mockInitContext = makeMockInitContext({
kibanaServer: {},
});
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/reporting/server/config/create_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function createConfig$(
// kibanaServer.hostname, default to server.host, don't allow "0"
let kibanaServerHostname = reportingServer.hostname
? reportingServer.hostname
: serverInfo.host;
: serverInfo.hostname;
if (kibanaServerHostname === '0') {
logger.warn(
i18n.translate('xpack.reporting.serverConfig.invalidServerHostname', {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/security/server/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('Security Plugin', () => {

mockCoreSetup = coreMock.createSetup();
mockCoreSetup.http.getServerInfo.mockReturnValue({
host: 'localhost',
hostname: 'localhost',
name: 'kibana',
port: 80,
protocol: 'https',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export class IframeEmbeddedPlugin implements Plugin {
validate: false,
},
async (context, request, response) => {
const { protocol, port, host } = core.http.getServerInfo();
const { protocol, port, hostname } = core.http.getServerInfo();

const kibanaUrl = Url.format({ protocol, hostname: host, port });
const kibanaUrl = Url.format({ protocol, hostname, port });

return response.renderHtml({
body: renderBody(kibanaUrl),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function initRoutes(core: CoreSetup) {
async (context, request, response) => {
const samlResponse = await getSAMLResponse({
inResponseTo: await getSAMLRequestId(request.url.href!),
destination: `${serverInfo.protocol}://${serverInfo.host}:${serverInfo.port}/api/security/saml/callback`,
destination: `${serverInfo.protocol}://${serverInfo.hostname}:${serverInfo.port}/api/security/saml/callback`,
});

return response.renderHtml({
Expand Down

0 comments on commit e7c54d3

Please sign in to comment.