mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
# Backport This will backport the following commits from `main` to `8.13`: - [[Synthetics] Allow Synthetics global params to include dashes (#178054)](https://github.com/elastic/kibana/pull/178054) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Justin Kambic","email":"jk@elastic.co"},"sourceCommit":{"committedDate":"2024-03-07T23:11:59Z","message":"[Synthetics] Allow Synthetics global params to include dashes (#178054)\n\n## Summary\r\n\r\nResolves #178053.\r\n\r\nIncludes `-` in the regex to filter param names.\r\n\r\n## Testing\r\n\r\n### Repro instructions\r\n\r\nTesting this is straightforward. You can verify the issue in `main` or\r\non a cloud instance. If you spin up an ESS that is the most\r\nstraightforward way.\r\n\r\n1. In Synthetics UI, go to Settings > Global Parameters.\r\n<img width=\"831\" alt=\"image\"\r\nsrc=\"f6dc78f6
-6e0c-4b84-a114-9e88266327e9\">\r\n\r\n2. Create a param with some dashes in the key, i.e. `TEST-PARAMS`.\r\n\r\n3. After saving, create an HTTP monitor. In the create form, you can\r\nscroll down and expand `Advanced options`. Include a check for `Request\r\nheaders`, specify a header name and for the value, reference your global\r\nparam using [Beats env\r\nsyntax](https://www.elastic.co/guide/en/beats/libbeat/current/config-file-format-env-vars.html#_examples).\r\n<img width=\"831\" alt=\"image\"\r\nsrc=\"bcf3c495
-1db8-499c-a394-781564744679\">\r\n\r\nYou can either use Test Now or wait for it to fail, and you'll see\r\nissues get logged similar to what is documented in the attached issue.\r\n\r\n### Testing the fix\r\n\r\nI will create an ESS deployment from this PR that will allow you to\r\nfollow the same steps above. You should be able to see your monitor\r\neither succeed (if the response headers you check for are actually\r\nthere), or fail for legitimate reasons. But you should not see the error\r\ndocumented in the attached issue, with a message like `io:job could not\r\nbe initialized...`.","sha":"d69045bd4d1b013cf92daf4992c836ea623a4968","branchLabelMapping":{"^v8.14.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:obs-ux-infra_services","v8.13.0","v8.14.0"],"title":"[Synthetics] Allow Synthetics global params to include dashes","number":178054,"url":"https://github.com/elastic/kibana/pull/178054","mergeCommit":{"message":"[Synthetics] Allow Synthetics global params to include dashes (#178054)\n\n## Summary\r\n\r\nResolves #178053.\r\n\r\nIncludes `-` in the regex to filter param names.\r\n\r\n## Testing\r\n\r\n### Repro instructions\r\n\r\nTesting this is straightforward. You can verify the issue in `main` or\r\non a cloud instance. If you spin up an ESS that is the most\r\nstraightforward way.\r\n\r\n1. In Synthetics UI, go to Settings > Global Parameters.\r\n<img width=\"831\" alt=\"image\"\r\nsrc=\"f6dc78f6
-6e0c-4b84-a114-9e88266327e9\">\r\n\r\n2. Create a param with some dashes in the key, i.e. `TEST-PARAMS`.\r\n\r\n3. After saving, create an HTTP monitor. In the create form, you can\r\nscroll down and expand `Advanced options`. Include a check for `Request\r\nheaders`, specify a header name and for the value, reference your global\r\nparam using [Beats env\r\nsyntax](https://www.elastic.co/guide/en/beats/libbeat/current/config-file-format-env-vars.html#_examples).\r\n<img width=\"831\" alt=\"image\"\r\nsrc=\"bcf3c495
-1db8-499c-a394-781564744679\">\r\n\r\nYou can either use Test Now or wait for it to fail, and you'll see\r\nissues get logged similar to what is documented in the attached issue.\r\n\r\n### Testing the fix\r\n\r\nI will create an ESS deployment from this PR that will allow you to\r\nfollow the same steps above. You should be able to see your monitor\r\neither succeed (if the response headers you check for are actually\r\nthere), or fail for legitimate reasons. But you should not see the error\r\ndocumented in the attached issue, with a message like `io:job could not\r\nbe initialized...`.","sha":"d69045bd4d1b013cf92daf4992c836ea623a4968"}},"sourceBranch":"main","suggestedTargetBranches":["8.13"],"targetPullRequestStates":[{"branch":"8.13","label":"v8.13.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.14.0","branchLabelMappingKey":"^v8.14.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/178054","number":178054,"mergeCommit":{"message":"[Synthetics] Allow Synthetics global params to include dashes (#178054)\n\n## Summary\r\n\r\nResolves #178053.\r\n\r\nIncludes `-` in the regex to filter param names.\r\n\r\n## Testing\r\n\r\n### Repro instructions\r\n\r\nTesting this is straightforward. You can verify the issue in `main` or\r\non a cloud instance. If you spin up an ESS that is the most\r\nstraightforward way.\r\n\r\n1. In Synthetics UI, go to Settings > Global Parameters.\r\n<img width=\"831\" alt=\"image\"\r\nsrc=\"f6dc78f6
-6e0c-4b84-a114-9e88266327e9\">\r\n\r\n2. Create a param with some dashes in the key, i.e. `TEST-PARAMS`.\r\n\r\n3. After saving, create an HTTP monitor. In the create form, you can\r\nscroll down and expand `Advanced options`. Include a check for `Request\r\nheaders`, specify a header name and for the value, reference your global\r\nparam using [Beats env\r\nsyntax](https://www.elastic.co/guide/en/beats/libbeat/current/config-file-format-env-vars.html#_examples).\r\n<img width=\"831\" alt=\"image\"\r\nsrc=\"bcf3c495
-1db8-499c-a394-781564744679\">\r\n\r\nYou can either use Test Now or wait for it to fail, and you'll see\r\nissues get logged similar to what is documented in the attached issue.\r\n\r\n### Testing the fix\r\n\r\nI will create an ESS deployment from this PR that will allow you to\r\nfollow the same steps above. You should be able to see your monitor\r\neither succeed (if the response headers you check for are actually\r\nthere), or fail for legitimate reasons. But you should not see the error\r\ndocumented in the attached issue, with a message like `io:job could not\r\nbe initialized...`.","sha":"d69045bd4d1b013cf92daf4992c836ea623a4968"}}]}] BACKPORT--> Co-authored-by: Justin Kambic <jk@elastic.co>
This commit is contained in:
parent
cc878396dd
commit
fe65d07305
2 changed files with 23 additions and 2 deletions
|
@ -20,6 +20,26 @@ describe('replaceStringWithParams', () => {
|
|||
expect(result).toEqual('https://elastic.co');
|
||||
});
|
||||
|
||||
it('works with dashes in the key', () => {
|
||||
const result = replaceStringWithParams(
|
||||
'${home-page-url}',
|
||||
{ 'home-page-url': 'https://elastic.co' },
|
||||
logger
|
||||
);
|
||||
|
||||
expect(result).toEqual('https://elastic.co');
|
||||
});
|
||||
|
||||
it('works with . in the key', () => {
|
||||
const result = replaceStringWithParams(
|
||||
'${home.pageUrl}',
|
||||
{ 'home.pageUrl': 'https://elastic.co' },
|
||||
logger
|
||||
);
|
||||
|
||||
expect(result).toEqual('https://elastic.co');
|
||||
});
|
||||
|
||||
it('returns empty value in case no param', () => {
|
||||
const result = replaceStringWithParams('${homePageUrl}', {}, logger);
|
||||
|
||||
|
|
|
@ -50,9 +50,10 @@ export const replaceStringWithParams = (
|
|||
return value as string | null;
|
||||
};
|
||||
|
||||
const SHELL_PARAMS_REGEX = /\$\{[a-zA-Z_][a-zA-Z0-9\._\-?:]*\}/g;
|
||||
|
||||
export const hasNoParams = (strVal: string) => {
|
||||
const shellParamsRegex = /\$\{[a-zA-Z_][a-zA-Z0-9_]*\}/g;
|
||||
return strVal.match(shellParamsRegex) === null;
|
||||
return strVal.match(SHELL_PARAMS_REGEX) === null;
|
||||
};
|
||||
|
||||
export const secondsToCronFormatter: FormatterFn = (fields, key) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue