Skip to content

Commit

Permalink
[Infra UI] Removed unused saved object attribute and unused source co…
Browse files Browse the repository at this point in the history
…nfiguration code (#169430)

Resolves #168240

### Changes

- Removes `fields.message` from the `infrastructure-ui-source` saved
object who's value was being populated by
`xpack.infra.sources.default.fields.message` from config. See
https://www.elastic.co/guide/en/kibana/master/logs-ui-settings-kb.html
- Removes `getInternalSourceConfiguration` and
`defineInternalSourceConfiguration` functions introduced in
#36066 as I cannot see them being
used anywhere. Stops exposing `defineInternalSourceConfiguration` as
part of server plugin interface.
- Removes `getStaticDefaultSourceConfiguration` from InfraSources class
as we aren't using `sources` from kibana config in source configuration
anymore.
- Removes deprecations warning of removal in 8.0 for other fields
belonging to config xpack.infra.sources.* introduced in
#115103
- Removes `getAllSourceConfigurations` used only in removed deprecations
file
f427278#diff-081721894fc437938eb652beae0a0640ddeee532ec5e48af1f3093c8074f1eecL195
- Removed `getAllSavedSourceConfigurations` only used in
`getAllSourceConfigurations`

### How to test 
- `infrastructure-ui-source` saved object no longer has `fields`
attributes
- in kibana.yml set `xpack.infra.sources.default.fields.message:
['testmessage', '@testmessage']`
  - go to Infra -> Settings
  - Change the name and save the form
- view the `infrastructure-ui-source` saved object and no `fields`
attribute should exist (unless it previously existed in an already
existing `infrastructure-ui-source` saved object
- changes do not affect`fields.message` is used in logs_shared plugin
- i'm not sure how to easily test this and relying on someone with more
Logs knowledge to help out, but from what I can see logs accesses the
config directly (`xpack.infra.sources.default.fields.message`) and never
uses the saved object field being removed.
  • Loading branch information
neptunian authored Nov 7, 2023
1 parent cecd175 commit ea7ae45
Show file tree
Hide file tree
Showing 22 changed files with 17 additions and 589 deletions.
3 changes: 0 additions & 3 deletions x-pack/plugins/infra/common/source_configuration/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ export const defaultSourceConfiguration: InfraSourceConfiguration = {
type: 'index_name',
indexName: LOGS_INDEX_PATTERN,
},
fields: {
message: ['message', '@message'],
},
inventoryDefaultView: '0',
metricsExplorerDefaultView: '0',
logColumns: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,8 @@

/* eslint-disable @typescript-eslint/no-empty-interface */

import { omit } from 'lodash';
import * as rt from 'io-ts';

/**
* Source configuration config file properties.
* These are properties that can appear in the kibana.yml file.
* This is a legacy method of providing properties, and will be deprecated in the future (v 8.0.0).
*/

export const sourceConfigurationConfigFilePropertiesRT = rt.type({
sources: rt.type({
default: rt.partial({
fields: rt.partial({
message: rt.array(rt.string),
}),
}),
}),
});

export type SourceConfigurationConfigFileProperties = rt.TypeOf<
typeof sourceConfigurationConfigFilePropertiesRT
>;

/**
* Log columns
*/
Expand Down Expand Up @@ -104,47 +83,22 @@ export type LogIndexNameReference = rt.TypeOf<typeof logIndexNameReferenceRT>;
export const logIndexReferenceRT = rt.union([logIndexPatternReferenceRT, logIndexNameReferenceRT]);
export type LogIndexReference = rt.TypeOf<typeof logIndexReferenceRT>;

/**
* Fields
*/

const SourceConfigurationFieldsRT = rt.type({
message: rt.array(rt.string),
});

/**
* Properties that represent a full source configuration, which is the result of merging static values with
* saved values.
*/
export const SourceConfigurationRT = rt.type({
name: rt.string,
description: rt.string,
metricAlias: rt.string,
logIndices: logIndexReferenceRT,
inventoryDefaultView: rt.string,
metricsExplorerDefaultView: rt.string,
fields: SourceConfigurationFieldsRT,
logColumns: rt.array(SourceConfigurationColumnRuntimeType),
anomalyThreshold: rt.number,
});

/**
* Stored source configuration as read from and written to saved objects
*/
const SavedSourceConfigurationFieldsRuntimeType = rt.partial(
omit(SourceConfigurationFieldsRT.props, ['message'])
);

export type InfraSavedSourceConfigurationFields = rt.TypeOf<
typeof SavedSourceConfigurationFieldsRuntimeType
>;

export const SavedSourceConfigurationRuntimeType = rt.intersection([
rt.partial(omit(SourceConfigurationRT.props, ['fields'])),
rt.partial({
fields: SavedSourceConfigurationFieldsRuntimeType,
}),
]);
export const SavedSourceConfigurationRuntimeType = rt.partial(SourceConfigurationRT.props);

export interface InfraSavedSourceConfiguration
extends rt.TypeOf<typeof SavedSourceConfigurationRuntimeType> {}
Expand All @@ -154,10 +108,8 @@ export interface InfraSavedSourceConfiguration
* hardcoded defaults.
*/

const StaticSourceConfigurationFieldsRuntimeType = rt.partial(SourceConfigurationFieldsRT.props);
export const StaticSourceConfigurationRuntimeType = rt.partial({
...SourceConfigurationRT.props,
fields: StaticSourceConfigurationFieldsRuntimeType,
});

export interface InfraStaticSourceConfiguration
Expand All @@ -167,11 +119,8 @@ export interface InfraStaticSourceConfiguration
* Full source configuration type after all cleanup has been done at the edges
*/

export type InfraSourceConfigurationFields = rt.TypeOf<typeof SourceConfigurationFieldsRT>;

export const SourceConfigurationRuntimeType = rt.type({
...SourceConfigurationRT.props,
fields: SourceConfigurationFieldsRT,
logColumns: rt.array(SourceConfigurationColumnRuntimeType),
});

Expand Down
86 changes: 0 additions & 86 deletions x-pack/plugins/infra/server/deprecations.test.ts

This file was deleted.

Loading

0 comments on commit ea7ae45

Please sign in to comment.