Skip to content

Commit

Permalink
Merge branch 'main' into generic_edit_actions
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Jun 21, 2024
2 parents 8aa6e81 + 1ef0793 commit 9b778d1
Show file tree
Hide file tree
Showing 6 changed files with 570 additions and 385 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/bump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Check & deploy API documentation

on:
push:
branches:
- main
paths:
- 'oas_docs/kibana.serverless.yaml'

pull_request:
branches:
- main
paths:
- 'oas_docs/kibana.serverless.yaml'

permissions:
contents: read
pull-requests: write

jobs:
deploy-doc:
if: ${{ github.event_name == 'push' }}
name: Deploy API documentation on Bump.sh
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Deploy API documentation
uses: bump-sh/github-action@v1
with:
doc: serverless
token: ${{secrets.BUMP_TOKEN}}
file: oas_docs/kibana.serverless.yaml

api-diff:
if: ${{ github.event_name == 'pull_request' }}
name: Check API diff on Bump.sh
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create Preview
uses: bump-sh/github-action@v1
with:
doc: serverless
token: ${{secrets.BUMP_TOKEN}}
file: oas_docs/kibana.serverless.yaml
command: preview
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Comment pull request with API diff
uses: bump-sh/github-action@v1
with:
doc: serverless
token: ${{secrets.BUMP_TOKEN}}
file: oas_docs/kibana.serverless.yaml
command: diff
fail_on_breaking: true
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
29 changes: 29 additions & 0 deletions packages/kbn-apm-config-loader/src/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,35 @@ describe('ApmConfiguration', () => {
);
});

it('flattens the `globalLabels` object', () => {
const kibanaConfig = {
elastic: {
apm: {
globalLabels: {
keyOne: 'k1',
objectOne: {
objectOneKeyOne: 'o1k1',
objectOneKeyTwo: {
objectOneKeyTwoSubkeyOne: 'o1k2s1',
},
},
},
},
},
};
const config = new ApmConfiguration(mockedRootDir, kibanaConfig, true);
expect(config.getConfig('serviceName')).toEqual(
expect.objectContaining({
globalLabels: {
git_rev: 'sha',
keyOne: 'k1',
'objectOne.objectOneKeyOne': 'o1k1',
'objectOne.objectOneKeyTwo.objectOneKeyTwoSubkeyOne': 'o1k2s1',
},
})
);
});

describe('env vars', () => {
beforeEach(() => {
delete process.env.ELASTIC_APM_ENVIRONMENT;
Expand Down
10 changes: 10 additions & 0 deletions packages/kbn-apm-config-loader/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { getDataPath } from '@kbn/utils';
import { readFileSync } from 'fs';
import type { AgentConfigOptions } from 'elastic-apm-node';
import type { AgentConfigOptions as RUMAgentConfigOptions } from '@elastic/apm-rum';
import { getFlattenedObject } from '@kbn/std';
import type { ApmConfigSchema } from './apm_config';

// https://www.elastic.co/guide/en/apm/agent/nodejs/current/configuration.html
Expand Down Expand Up @@ -129,6 +130,15 @@ export class ApmConfiguration {
) {
this.baseConfig = merge(this.baseConfig, centralizedConfig);
}

if (this.baseConfig?.globalLabels) {
// Global Labels need to be a key/value pair...
// Dotted names will be renamed to underscored ones by the agent, but we need to provide key/value pairs
// https://github.com/elastic/apm-agent-nodejs/issues/4096#issuecomment-2181621221
this.baseConfig.globalLabels = getFlattenedObject(
this.baseConfig.globalLabels as Record<string, unknown>
);
}
}

return this.baseConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
useEuiTheme,
useGeneratedHtmlId,
} from '@elastic/eui';
import { css } from '@emotion/react';
import { Form, FormikProvider, useFormik, useFormikContext } from 'formik';
import type { FunctionComponent } from 'react';
import React, { useRef, useState } from 'react';
Expand Down Expand Up @@ -64,6 +65,12 @@ import { FormRow, OptionalText } from '../../components/form_row';
import { ChangePasswordModal } from '../../management/users/edit_user/change_password_modal';
import { isUserReserved } from '../../management/users/user_utils';

const formRowCSS = css`
.euiFormRow__label {
flex: 1;
}
`;

export interface UserProfileProps {
user: AuthenticatedUser;
data?: UserProfileData;
Expand Down Expand Up @@ -128,30 +135,36 @@ const UserDetailsEditor: FunctionComponent<UserDetailsEditorProps> = ({ user })
}
>
<FormRow
css={formRowCSS}
label={
<FormLabel for="user.full_name">
<FormattedMessage
id="xpack.security.accountManagement.userProfile.fullNameLabel"
defaultMessage="Full name"
/>
<EuiFlexGroup justifyContent="spaceBetween">
<FormattedMessage
id="xpack.security.accountManagement.userProfile.fullNameLabel"
defaultMessage="Full name"
/>
<OptionalText />
</EuiFlexGroup>
</FormLabel>
}
labelAppend={<OptionalText />}
fullWidth
>
<FormField name="user.full_name" data-test-subj={'userProfileFullName'} fullWidth />
</FormRow>

<FormRow
css={formRowCSS}
label={
<FormLabel for="user.email">
<FormattedMessage
id="xpack.security.accountManagement.userProfile.emailLabel"
defaultMessage="Email address"
/>
<EuiFlexGroup justifyContent="spaceBetween">
<FormattedMessage
id="xpack.security.accountManagement.userProfile.emailLabel"
defaultMessage="Email address"
/>
<OptionalText />
</EuiFlexGroup>
</FormLabel>
}
labelAppend={<OptionalText />}
fullWidth
>
<FormField type="email" name="user.email" data-test-subj={'userProfileEmail'} fullWidth />
Expand Down
Loading

0 comments on commit 9b778d1

Please sign in to comment.