From 4dda3ab8a06d451a09ada283e074a0601095d7e2 Mon Sep 17 00:00:00 2001 From: Bethany Date: Wed, 9 Aug 2023 13:12:30 -0700 Subject: [PATCH] move getExpiration to upload-artifact --- packages/artifact/src/internal/shared/util.ts | 12 ------------ .../src/internal/upload/upload-artifact.ts | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/packages/artifact/src/internal/shared/util.ts b/packages/artifact/src/internal/shared/util.ts index 50844a40..bc98abde 100644 --- a/packages/artifact/src/internal/shared/util.ts +++ b/packages/artifact/src/internal/shared/util.ts @@ -1,6 +1,5 @@ import {getRuntimeToken} from './config' import jwt_decode from 'jwt-decode' -import {Timestamp} from '../../generated' export interface BackendIds { workflowRunBackendId: string @@ -64,14 +63,3 @@ export function getBackendIdsFromToken(): BackendIds { throw InvalidJwtError } - -export function getExpiration(retentionDays?: number): Timestamp | undefined { - if (!retentionDays) { - return undefined - } - - const expirationDate = new Date() - expirationDate.setDate(expirationDate.getDate() + retentionDays) - - return Timestamp.fromDate(expirationDate) -} diff --git a/packages/artifact/src/internal/upload/upload-artifact.ts b/packages/artifact/src/internal/upload/upload-artifact.ts index 8ad52390..087493a3 100644 --- a/packages/artifact/src/internal/upload/upload-artifact.ts +++ b/packages/artifact/src/internal/upload/upload-artifact.ts @@ -8,8 +8,8 @@ import { getUploadZipSpecification, validateRootDirectory } from './upload-zip-specification' -import {getBackendIdsFromToken, getExpiration} from '../shared/util' -import {CreateArtifactRequest} from 'src/generated' +import {getBackendIdsFromToken} from '../shared/util' +import {CreateArtifactRequest, Timestamp} from 'src/generated' export async function uploadArtifact( name: string, @@ -91,3 +91,14 @@ export async function uploadArtifact( return uploadResponse } + +function getExpiration(retentionDays?: number): Timestamp | undefined { + if (!retentionDays) { + return undefined + } + + const expirationDate = new Date() + expirationDate.setDate(expirationDate.getDate() + retentionDays) + + return Timestamp.fromDate(expirationDate) +}