Snapshot names that contain date math may require capital letters, e.g. "<snapshot-{now/d{yyyy.MM.dd|+09:00}}>". This change fixes a bug which complained that capital letters are not allowed in snapshot names, by scoping this validation to only the name part of this pattern, ignoring the date math part. Co-authored-by: Jimmy Kuang <jimmy@elastic.co>
This commit is contained in:
parent
55efa3b55f
commit
e5bfc138a9
|
@ -347,7 +347,7 @@ export const PolicyStepLogistics: React.FunctionComponent<StepProps> = ({
|
|||
onChange={e => {
|
||||
updatePolicy(
|
||||
{
|
||||
snapshotName: e.target.value.toLowerCase(),
|
||||
snapshotName: e.target.value,
|
||||
},
|
||||
{
|
||||
managedRepository,
|
||||
|
|
|
@ -15,6 +15,16 @@ const isStringEmpty = (str: string | null): boolean => {
|
|||
return str ? !Boolean(str.trim()) : true;
|
||||
};
|
||||
|
||||
// strExcludeDate is the concat results of the SnapshotName ...{...}>... without the date
|
||||
// This way we can check only the SnapshotName portion for lowercasing
|
||||
// For example: <logstash-{now/d}> would give strExcludeDate = <logstash->
|
||||
|
||||
const isSnapshotNameNotLowerCase = (str: string): boolean => {
|
||||
const strExcludeDate =
|
||||
str.substring(0, str.search('{')) + str.substring(str.search('}>') + 1, str.length);
|
||||
return strExcludeDate !== strExcludeDate.toLowerCase() ? true : false;
|
||||
};
|
||||
|
||||
export const validatePolicy = (
|
||||
policy: SlmPolicyPayload,
|
||||
validationHelperData: {
|
||||
|
@ -61,6 +71,14 @@ export const validatePolicy = (
|
|||
);
|
||||
}
|
||||
|
||||
if (isSnapshotNameNotLowerCase(snapshotName)) {
|
||||
validation.errors.snapshotName.push(
|
||||
i18n.translate('xpack.snapshotRestore.policyValidation.snapshotNameLowerCaseErrorMessage', {
|
||||
defaultMessage: 'Snapshot name needs to be lowercase.',
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
if (isStringEmpty(schedule)) {
|
||||
validation.errors.schedule.push(
|
||||
i18n.translate('xpack.snapshotRestore.policyValidation.scheduleRequiredErrorMessage', {
|
||||
|
|
|
@ -25,6 +25,7 @@ export class WebhookAction extends BaseAction {
|
|||
this.username = get(props, 'username');
|
||||
this.password = get(props, 'password');
|
||||
this.contentType = get(props, 'contentType');
|
||||
|
||||
this.fullPath = `${this.host}:${this.port}${this.path ? '/' + this.path : ''}`;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue