move getExpiration to upload-artifact

This commit is contained in:
Bethany committed 2023-08-09 13:12:30 -07:00
1 parent 04f8ae1cea
commit 36c70dd6ec
2 files changed
+13 -14

No files matched your search

-12
View File
@@ -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)
}
+13 -2
View File
@@ -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)
}