Wizard: Parse old snapshot dates when editing

This updates format of the snapshot date when the blueprint with the old format gets edited.
This commit is contained in:
regexowl 2025-01-07 15:52:25 +01:00 committed by Klara Simickova
parent 44685f4c76
commit 563ff04054

View file

@ -173,9 +173,27 @@ function commonRequestToState(
(image) => image.image_type === 'azure'
);
const snapshot_date =
const snapshotDateFromRequest =
request.image_requests.find((image) => !!image.snapshot_date)
?.snapshot_date || '';
let snapshot_date = '';
// Previously DateOnly format of the snapshot date was used (YYYY-MM-DD),
// meaning this is a format that can be present in already existing blueprints.
// Currently used format is RFC3339 (YYYY-MM-DDTHH:MM:SSZ), this condition
// checks which format is getting parsed and converts DateOnly to RFC3339
// when necessary.
if (
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+\d{2}:\d{2}$/.test(
snapshotDateFromRequest
)
) {
snapshot_date = snapshotDateFromRequest;
} else if (/^\d{4}-\d{2}-\d{2}$/.test(snapshotDateFromRequest)) {
snapshot_date = snapshotDateFromRequest + 'T00:00:00+00:00';
} else {
snapshot_date = '';
}
const awsUploadOptions = aws?.upload_request
.options as AwsUploadRequestOptions;