Skip to content

Commit

Permalink
Merge branch 'main' into szaffarano/fix-tests-kbn-9
Browse files Browse the repository at this point in the history
  • Loading branch information
szaffarano authored Sep 13, 2024
2 parents c893f75 + 25225c3 commit a677bc5
Show file tree
Hide file tree
Showing 121 changed files with 1,398 additions and 1,808 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,8 @@ src/plugins/image_embeddable @elastic/appex-sharedux
packages/kbn-import-locator @elastic/kibana-operations
packages/kbn-import-resolver @elastic/kibana-operations
x-pack/plugins/index_lifecycle_management @elastic/kibana-management
x-pack/packages/index-management @elastic/kibana-management
x-pack/plugins/index_management @elastic/kibana-management
x-pack/packages/index-management/index_management_shared_types @elastic/kibana-management
test/plugin_functional/plugins/index_patterns @elastic/kibana-data-discovery
x-pack/packages/ml/inference_integration_flyout @elastic/ml-ui
x-pack/plugins/inference @elastic/appex-ai-infra
Expand Down
4 changes: 2 additions & 2 deletions docs/CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,11 @@ you make the necessary updates after you upgrade to 8.15.0.

[discrete]
[[deprecation-uptime]]
.Uptime is deprecated in 8.15.0 and will be removed in 9.0.0.
.Uptime is deprecated in 8.15.0 and will be removed in a future version.
[%collapsible]
====
*Details* +
The Uptime app is already hidden from Kibana when there is no recent Heartbeat data, but will be completely removed in 9.0.0. You should migrate to Synthetics as an alternative. For more details, refer to the {observability-guide}/uptime-intro.html[Uptime documentation].
The Uptime app is already hidden from Kibana when there is no recent Heartbeat data, and will be completely removed in early 2026. You should migrate to Synthetics as an alternative. For more details, refer to the {observability-guide}/uptime-intro.html[Uptime documentation].
====

[float]
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,8 @@
"@kbn/iframe-embedded-plugin": "link:x-pack/test/functional_embedded/plugins/iframe_embedded",
"@kbn/image-embeddable-plugin": "link:src/plugins/image_embeddable",
"@kbn/index-lifecycle-management-plugin": "link:x-pack/plugins/index_lifecycle_management",
"@kbn/index-management": "link:x-pack/packages/index-management",
"@kbn/index-management-plugin": "link:x-pack/plugins/index_management",
"@kbn/index-management-shared-types": "link:x-pack/packages/index-management/index_management_shared_types",
"@kbn/index-patterns-test-plugin": "link:test/plugin_functional/plugins/index_patterns",
"@kbn/inference-plugin": "link:x-pack/plugins/inference",
"@kbn/inference_integration_flyout": "link:x-pack/packages/ml/inference_integration_flyout",
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-mock-idp-plugin/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const config = {
// The plugin should only be enabled in Serverless.
enabled: offeringBasedSchema({
serverless: schema.boolean({ defaultValue: true }),
traditional: schema.boolean({ defaultValue: false }),
options: { defaultValue: false },
}),
}),
Expand Down
37 changes: 21 additions & 16 deletions packages/kbn-mock-idp-plugin/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import type { PluginInitializer, Plugin } from '@kbn/core-plugins-server';
import { schema } from '@kbn/config-schema';
import type { TypeOf } from '@kbn/config-schema';
import { MOCK_IDP_LOGIN_PATH, MOCK_IDP_LOGOUT_PATH, createSAMLResponse } from '@kbn/mock-idp-utils';
import { SERVERLESS_ROLES_ROOT_PATH, readRolesFromResource } from '@kbn/es';
import {
SERVERLESS_ROLES_ROOT_PATH,
STATEFUL_ROLES_ROOT_PATH,
readRolesFromResource,
} from '@kbn/es';
import { resolve } from 'path';
import { CloudSetup } from '@kbn/cloud-plugin/server';

Expand Down Expand Up @@ -42,6 +46,11 @@ const readServerlessRoles = (projectType: string) => {
}
};

const readStatefulRoles = () => {
const rolesResourcePath = resolve(STATEFUL_ROLES_ROOT_PATH, 'roles.yml');
return readRolesFromResource(rolesResourcePath);
};

export type CreateSAMLResponseParams = TypeOf<typeof createSAMLResponseSchema>;

export const plugin: PluginInitializer<
Expand Down Expand Up @@ -73,22 +82,18 @@ export const plugin: PluginInitializer<
options: { authRequired: false },
},
(context, request, response) => {
const projectType = plugins.cloud.serverless?.projectType;
if (!projectType) {
return response.customError({ statusCode: 500, body: 'projectType is not defined' });
} else {
try {
if (roles.length === 0) {
roles.push(...readServerlessRoles(projectType));
}
return response.ok({
body: {
roles,
},
});
} catch (err) {
return response.customError({ statusCode: 500, body: err.message });
try {
if (roles.length === 0) {
const projectType = plugins.cloud?.serverless?.projectType;
roles.push(...(projectType ? readServerlessRoles(projectType) : readStatefulRoles()));
}
return response.ok({
body: {
roles,
},
});
} catch (err) {
return response.customError({ statusCode: 500, body: err.message });
}
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export const processDiscontinued = (schema: OpenAPIV3.SchemaObject): void => {
};

/** Just for type convenience */
export const deleteField = (schema: Record<any, unknown>, field: string): void => {
delete schema[field];
export const deleteField = (schema: object, field: string): void => {
delete (schema as Record<string, unknown>)[field];
};

export const isAnyType = (schema: OpenAPIV3.SchemaObject): boolean => {
Expand Down
21 changes: 21 additions & 0 deletions packages/kbn-router-to-openapispec/src/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
getXsrfHeaderForMethod,
mergeResponseContent,
prepareRoutes,
getPathParameters,
} from './util';
import { assignToPaths, extractTags } from './util';

Expand Down Expand Up @@ -230,3 +231,23 @@ describe('getXsrfHeaderForMethod', () => {
expect(getXsrfHeaderForMethod(method as RouteMethod, options)).toEqual(expected);
});
});

describe('getPathParameters', () => {
test.each([
['', {}],
['/', {}],
['{}', {}],
['{{}', {}],
['{badinput', {}],
['{ok}', { ok: { optional: false } }],
['{ok?}', { ok: { optional: true } }],
['{ok??}', {}],
['/api/{path}/is/{cool}', { path: { optional: false }, cool: { optional: false } }],
[
'/{required}/and/{optional?}',
{ required: { optional: false }, optional: { optional: true } },
],
])('%s', (input, output) => {
expect(getPathParameters(input)).toEqual(output);
});
});
2 changes: 1 addition & 1 deletion packages/kbn-router-to-openapispec/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const buildGlobalTags = (paths: OpenAPIV3.PathsObject, additionalTags: st
};

export const getPathParameters = (path: string): KnownParameters => {
return Array.from(path.matchAll(/\{(.+?)\}/g)).reduce<KnownParameters>((acc, [_, key]) => {
return Array.from(path.matchAll(/\{([^{}?]+\??)\}/g)).reduce<KnownParameters>((acc, [_, key]) => {
const optional = key.endsWith('?');
acc[optional ? key.slice(0, key.length - 1) : key] = { optional };
return acc;
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-text-based-editor/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { CoreStart } from '@kbn/core/public';
import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
import type { AggregateQuery } from '@kbn/es-query';
import type { ExpressionsStart } from '@kbn/expressions-plugin/public';
import type { IndexManagementPluginSetup } from '@kbn/index-management';
import type { IndexManagementPluginSetup } from '@kbn/index-management-shared-types';
import type { FieldsMetadataPublicStart } from '@kbn/fields-metadata-plugin/public';

export interface TextBasedLanguagesEditorProps {
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-text-based-editor/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@kbn/data-plugin",
"@kbn/expressions-plugin",
"@kbn/data-views-plugin",
"@kbn/index-management",
"@kbn/index-management-shared-types",
"@kbn/code-editor",
"@kbn/shared-ux-markdown",
"@kbn/fields-metadata-plugin",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/esql/public/kibana_services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { BehaviorSubject } from 'rxjs';
import type { CoreStart } from '@kbn/core/public';
import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
import type { ExpressionsStart } from '@kbn/expressions-plugin/public';
import type { IndexManagementPluginSetup } from '@kbn/index-management';
import type { IndexManagementPluginSetup } from '@kbn/index-management-shared-types';
import type { FieldsMetadataPublicStart } from '@kbn/fields-metadata-plugin/public';

export let core: CoreStart;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/esql/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { Plugin, CoreStart, CoreSetup } from '@kbn/core/public';
import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
import type { ExpressionsStart } from '@kbn/expressions-plugin/public';
import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
import type { IndexManagementPluginSetup } from '@kbn/index-management';
import type { IndexManagementPluginSetup } from '@kbn/index-management-shared-types';
import type { UiActionsSetup, UiActionsStart } from '@kbn/ui-actions-plugin/public';
import type { FieldsMetadataPublicStart } from '@kbn/fields-metadata-plugin/public';
import {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/esql/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@kbn/core",
"@kbn/expressions-plugin",
"@kbn/data-views-plugin",
"@kbn/index-management",
"@kbn/index-management-shared-types",
"@kbn/i18n",
"@kbn/config-schema",
"@kbn/esql-utils",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
'xpack.ccr.ui.enabled (boolean?)',
'xpack.cloud.base_url (string?)',
'xpack.cloud.cname (string?)',
'xpack.cloud.csp (string?)',
'xpack.cloud.deployment_url (string?)',
'xpack.cloud.deployments_url (string?)',
'xpack.cloud.is_elastic_staff_owned (boolean?)',
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -1010,10 +1010,10 @@
"@kbn/import-resolver/*": ["packages/kbn-import-resolver/*"],
"@kbn/index-lifecycle-management-plugin": ["x-pack/plugins/index_lifecycle_management"],
"@kbn/index-lifecycle-management-plugin/*": ["x-pack/plugins/index_lifecycle_management/*"],
"@kbn/index-management": ["x-pack/packages/index-management"],
"@kbn/index-management/*": ["x-pack/packages/index-management/*"],
"@kbn/index-management-plugin": ["x-pack/plugins/index_management"],
"@kbn/index-management-plugin/*": ["x-pack/plugins/index_management/*"],
"@kbn/index-management-shared-types": ["x-pack/packages/index-management/index_management_shared_types"],
"@kbn/index-management-shared-types/*": ["x-pack/packages/index-management/index_management_shared_types/*"],
"@kbn/index-patterns-test-plugin": ["test/plugin_functional/plugins/index_patterns"],
"@kbn/index-patterns-test-plugin/*": ["test/plugin_functional/plugins/index_patterns/*"],
"@kbn/inference_integration_flyout": ["x-pack/packages/ml/inference_integration_flyout"],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# @kbn/index-management
# @kbn/index-management-shared-types

Contains types and functions used and exported by the index management plugin. Primarily used to avoid cyclical dependencies.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

module.exports = {
preset: '@kbn/test',
rootDir: '../../..',
roots: ['<rootDir>/x-pack/packages/index-management'],
rootDir: '../../../..',
roots: ['<rootDir>/x-pack/packages/index-management/index_management_shared_types'],
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "shared-common",
"id": "@kbn/index-management",
"id": "@kbn/index-management-shared-types",
"owner": "@elastic/kibana-management"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@kbn/index-management",
"name": "@kbn/index-management-shared-types",
"private": true,
"version": "1.0.0",
"license": "Elastic License 2.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"types": [
Expand Down
6 changes: 6 additions & 0 deletions x-pack/plugins/cloud/public/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ describe('Cloud Plugin', () => {
...baseConfig,
id: 'cloudId',
cname: 'cloud.elastic.co',
csp: 'aws',
...configParts,
});
const plugin = new CloudPlugin(initContext);
Expand Down Expand Up @@ -86,6 +87,11 @@ describe('Cloud Plugin', () => {
expect(setup.cname).toBe('cloud.elastic.co');
});

it('exposes csp', () => {
const { setup } = setupPlugin();
expect(setup.csp).toBe('aws');
});

it('exposes registerCloudService', () => {
const { setup } = setupPlugin();
expect(setup.registerCloudService).toBeDefined();
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/cloud/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface CloudConfigType {
id?: string;
organization_id?: string;
cname?: string;
csp?: string;
base_url?: string;
profile_url?: string;
deployments_url?: string;
Expand Down Expand Up @@ -82,6 +83,7 @@ export class CloudPlugin implements Plugin<CloudSetup> {
base_url: baseUrl,
trial_end_date: trialEndDate,
is_elastic_staff_owned: isElasticStaffOwned,
csp,
} = this.config;

let decodedId: DecodedCloudId | undefined;
Expand All @@ -94,6 +96,7 @@ export class CloudPlugin implements Plugin<CloudSetup> {
organizationId: this.config.organization_id,
deploymentId: parseDeploymentIdFromDeploymentUrl(this.config.deployment_url),
cname,
csp,
baseUrl,
...this.getCloudUrls(),
elasticsearchUrl: decodedId?.elasticsearchUrl,
Expand Down
6 changes: 6 additions & 0 deletions x-pack/plugins/cloud/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ export interface CloudSetup {
* @example `cloud.elastic.co`
*/
cname?: string;
/**
* The cloud service provider identifier.
*
* @note Expected to be one of `aws`, `gcp` or `azure`, but could be something different.
*/
csp?: string;
/**
* This is the URL of the Cloud interface.
*/
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions x-pack/plugins/cloud/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const configSchema = schema.object({
apm: schema.maybe(apmConfigSchema),
base_url: schema.maybe(schema.string()),
cname: schema.maybe(schema.string()),
csp: schema.maybe(schema.string()),
deployments_url: schema.string({ defaultValue: '/deployments' }),
deployment_url: schema.maybe(schema.string()),
id: schema.maybe(schema.string()),
Expand Down Expand Up @@ -59,6 +60,7 @@ export const config: PluginConfigDescriptor<CloudConfigType> = {
exposeToBrowser: {
base_url: true,
cname: true,
csp: true,
deployments_url: true,
deployment_url: true,
id: true,
Expand Down
6 changes: 6 additions & 0 deletions x-pack/plugins/cloud/server/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('Cloud Plugin', () => {
...baseConfig,
id: 'cloudId',
cname: 'cloud.elastic.co',
csp: 'aws',
...configParts,
});
const plugin = new CloudPlugin(initContext);
Expand Down Expand Up @@ -77,6 +78,11 @@ describe('Cloud Plugin', () => {
);
});

it('exposes csp', () => {
const { setup } = setupPlugin();
expect(setup.csp).toBe('aws');
});

it('exposes components decoded from the cloudId', () => {
const decodedId: DecodedCloudId = {
defaultPort: '9000',
Expand Down
7 changes: 7 additions & 0 deletions x-pack/plugins/cloud/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ export interface CloudSetup {
* @note The `cloudId` is a concatenation of the deployment name and a hash. Users can update the deployment name, changing the `cloudId`. However, the changed `cloudId` will not be re-injected into `kibana.yml`. If you need the current `cloudId` the best approach is to split the injected `cloudId` on the semi-colon, and replace the first element with the `persistent.cluster.metadata.display_name` value as provided by a call to `GET _cluster/settings`.
*/
cloudId?: string;
/**
* The cloud service provider identifier.
*
* @note Expected to be one of `aws`, `gcp` or `azure`, but could be something different.
*/
csp?: string;
/**
* The Elastic Cloud Organization that owns this deployment/project.
*/
Expand Down Expand Up @@ -199,6 +205,7 @@ export class CloudPlugin implements Plugin<CloudSetup, CloudStart> {
return {
...this.getCloudUrls(),
cloudId: this.config.id,
csp: this.config.csp,
organizationId,
instanceSizeMb: readInstanceSizeMb(),
deploymentId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
import { DataPublicPluginStart } from '@kbn/data-plugin/public';

import { GuidedOnboardingPluginStart } from '@kbn/guided-onboarding-plugin/public';
import { IndexMappingProps } from '@kbn/index-management';
import { IndexMappingProps } from '@kbn/index-management-shared-types';
import { LensPublicStart } from '@kbn/lens-plugin/public';
import { MlPluginStart } from '@kbn/ml-plugin/public';
import { ELASTICSEARCH_URL_PLACEHOLDER } from '@kbn/search-api-panels/constants';
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/enterprise_search/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { DataPublicPluginStart } from '@kbn/data-plugin/public';
import { GuidedOnboardingPluginStart } from '@kbn/guided-onboarding-plugin/public';
import type { HomePublicPluginSetup } from '@kbn/home-plugin/public';
import { i18n } from '@kbn/i18n';
import type { IndexManagementPluginStart } from '@kbn/index-management';
import type { IndexManagementPluginStart } from '@kbn/index-management-shared-types';
import { LensPublicStart } from '@kbn/lens-plugin/public';
import { LicensingPluginStart } from '@kbn/licensing-plugin/public';
import { MlPluginStart } from '@kbn/ml-plugin/public';
Expand Down
Loading

0 comments on commit a677bc5

Please sign in to comment.