Skip to content

Commit

Permalink
[8.10] [Enterprise Search] Update config template for self managed co…
Browse files Browse the repository at this point in the history
…nnectors. (elastic#164854) (elastic#164874)

# Backport

This will backport the following commits from `main` to `8.10`:
- [[Enterprise Search] Update config template for self managed
connectors. (elastic#164854)](elastic#164854)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Efe Gürkan
YALAMAN","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-08-25T17:06:01Z","message":"[Enterprise
Search] Update config template for self managed connectors.
(elastic#164854)\n\n##
Summary\r\n\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/1410658/e9e1dfb3-1acd-4255-9abf-b9b58f1a060a","sha":"7e4b67e2390ff0d2637b10153c049da73ee6ab34","branchLabelMapping":{"^v8.11.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","ci:cloud-deploy","v8.10.0","v8.11.0"],"number":164854,"url":"https://github.com/elastic/kibana/pull/164854","mergeCommit":{"message":"[Enterprise
Search] Update config template for self managed connectors.
(elastic#164854)\n\n##
Summary\r\n\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/1410658/e9e1dfb3-1acd-4255-9abf-b9b58f1a060a","sha":"7e4b67e2390ff0d2637b10153c049da73ee6ab34"}},"sourceBranch":"main","suggestedTargetBranches":["8.10"],"targetPullRequestStates":[{"branch":"8.10","label":"v8.10.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.11.0","labelRegex":"^v8.11.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/164854","number":164854,"mergeCommit":{"message":"[Enterprise
Search] Update config template for self managed connectors.
(elastic#164854)\n\n##
Summary\r\n\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/1410658/e9e1dfb3-1acd-4255-9abf-b9b58f1a060a","sha":"7e4b67e2390ff0d2637b10153c049da73ee6ab34"}}]}]
BACKPORT-->

Co-authored-by: Efe Gürkan YALAMAN <[email protected]>
  • Loading branch information
kibanamachine and efegurkan authored Aug 25, 2023
1 parent 63d021f commit 4f85aa3
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { createApiLogic } from '../../../shared/api_logic/create_api_logic';
import { HttpLogic } from '../../../shared/http';

interface ApiKey {
export interface ApiKey {
api_key: string;
encoded: string;
id: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { FormattedMessage } from '@kbn/i18n-react';

import { ConnectorStatus } from '../../../../../../common/types/connectors';
import { BetaConnectorCallout } from '../../../../shared/beta/beta_connector_callout';
import { useCloudDetails } from '../../../../shared/cloud_details/cloud_details';
import { docLinks } from '../../../../shared/doc_links';
import { generateEncodedPath } from '../../../../shared/encode_path_params';
import { EuiButtonTo, EuiLinkTo } from '../../../../shared/react_router_helpers';
Expand All @@ -45,14 +46,16 @@ import { SearchIndexTabId } from '../search_index';
import { ApiKeyConfig } from './api_key_configuration';
import { ConnectorConfigurationConfig } from './connector_configuration_config';
import { ConnectorNameAndDescription } from './connector_name_and_description/connector_name_and_description';
import { BETA_CONNECTORS, CONNECTORS } from './constants';
import { BETA_CONNECTORS, CONNECTORS, getConnectorTemplate } from './constants';
import { NativeConnectorConfiguration } from './native_connector_configuration/native_connector_configuration';

export const ConnectorConfiguration: React.FC = () => {
const { data: apiKeyData } = useValues(GenerateConnectorApiKeyApiLogic);
const { index, recheckIndexLoading } = useValues(IndexViewLogic);
const { indexName } = useValues(IndexNameLogic);
const { recheckIndex } = useActions(IndexViewLogic);
const cloudContext = useCloudDetails();

if (!isConnectorIndex(index)) {
return <></>;
}
Expand Down Expand Up @@ -151,15 +154,14 @@ export const ConnectorConfiguration: React.FC = () => {
</EuiText>
<EuiSpacer />
<EuiCodeBlock fontSize="m" paddingSize="m" color="dark" isCopyable>
{`connectors:
-
connector_id: "${index.connector.id}"
service_type: "${index.connector.service_type || 'changeme'}"${
apiKeyData?.encoded
? `
api_key: "${apiKeyData?.encoded}"`
: ''
}`}
{getConnectorTemplate({
apiKeyData,
connectorData: {
id: index.connector.id,
service_type: index.connector.service_type,
},
host: cloudContext.elasticsearchUrl,
})}
</EuiCodeBlock>
<EuiSpacer />
<EuiText size="s">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
* 2.0.
*/

import dedent from 'dedent';

import { CONNECTOR_DEFINITIONS } from '../../../../../../common/connectors/connectors';

import { docLinks } from '../../../../shared/doc_links';
import { CONNECTOR_ICONS } from '../../../../shared/icons/connector_icons';
import { ApiKey } from '../../../api/connector/generate_connector_api_key_api_logic';

import { ConnectorClientSideDefinition } from './types';

Expand Down Expand Up @@ -163,3 +166,29 @@ export const CUSTOM_CONNECTORS = CONNECTORS.filter(({ isNative }) => !isNative);
export const NATIVE_CONNECTORS = CONNECTORS.filter(({ isNative }) => isNative);

export const BETA_CONNECTORS = CONNECTORS.filter(({ isBeta }) => isBeta);

export const getConnectorTemplate = ({
apiKeyData,
connectorData,
host,
}: {
apiKeyData: ApiKey | undefined;
connectorData: {
id: string;
service_type: string | null;
};
host?: string;
}) => dedent`connectors:
-
connector_id: "${connectorData.id}"
service_type: "${connectorData.service_type || 'changeme'}"${
apiKeyData?.encoded
? `
api_key: "${apiKeyData?.encoded}"`
: ''
}
elasticsearch:
host: "${host || 'https://locahost:9200'}"
api_key: "${apiKeyData?.encoded || ''}"
`;

0 comments on commit 4f85aa3

Please sign in to comment.