condense parameters
Signed-off-by: Meredith Lancaster <[email protected]>
This commit is contained in:
@@ -5,22 +5,37 @@ import {RequestHeaders} from '@octokit/types'
|
|||||||
const CREATE_STORAGE_RECORD_REQUEST = 'POST /orgs/{owner}/artifacts/metadata/storage-record'
|
const CREATE_STORAGE_RECORD_REQUEST = 'POST /orgs/{owner}/artifacts/metadata/storage-record'
|
||||||
const DEFAULT_RETRY_COUNT = 5
|
const DEFAULT_RETRY_COUNT = 5
|
||||||
|
|
||||||
|
export type ArtifactParams = {
|
||||||
|
name: string
|
||||||
|
digest: string
|
||||||
|
version?: string
|
||||||
|
status?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type PackageRegistryParams = {
|
||||||
|
registryUrl: string
|
||||||
|
artifactUrl?: string
|
||||||
|
registryRepo?: string
|
||||||
|
path?: string
|
||||||
|
}
|
||||||
|
|
||||||
export type WriteOptions = {
|
export type WriteOptions = {
|
||||||
retry?: number
|
retry?: number
|
||||||
headers?: RequestHeaders
|
headers?: RequestHeaders
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a storage record on behalf of an artifact
|
* Writes a storage record on behalf of an artifact that has been attested
|
||||||
* @param artifactName - The name of the artifact.
|
* @param artifactParams - parameters for the artifact.
|
||||||
* @param artifactDigest - The digest of the artifact.
|
* @param packageRegistryParams - parameters for the package registry.
|
||||||
* @param token - The GitHub token for authentication.
|
* @param token - The GitHub token for authentication.
|
||||||
|
* @param options - Optional parameters for the write operation.
|
||||||
* @returns The ID of the storage record.
|
* @returns The ID of the storage record.
|
||||||
* @throws Error if the storage record fails to persist.
|
* @throws Error if the storage record fails to persist.
|
||||||
*/
|
*/
|
||||||
export const createStorageRecord = async (
|
export const createStorageRecord = async (
|
||||||
artifactName: string,
|
artifactParams: ArtifactParams,
|
||||||
artifactDigest: string,
|
packageRegistryParams: PackageRegistryParams,
|
||||||
token: string,
|
token: string,
|
||||||
options: WriteOptions = {}
|
options: WriteOptions = {}
|
||||||
): Promise<string> => {
|
): Promise<string> => {
|
||||||
@@ -32,8 +47,14 @@ export const createStorageRecord = async (
|
|||||||
owner: github.context.repo.owner,
|
owner: github.context.repo.owner,
|
||||||
repo: github.context.repo.repo,
|
repo: github.context.repo.repo,
|
||||||
headers: options.headers,
|
headers: options.headers,
|
||||||
artifact_name: artifactName,
|
artifact_name: artifactParams.name,
|
||||||
artifact_digest: artifactDigest,
|
artifact_digest: artifactParams.digest,
|
||||||
|
artifact_version: artifactParams.version,
|
||||||
|
artifact_status: artifactParams.status,
|
||||||
|
registry_url: packageRegistryParams.registryUrl,
|
||||||
|
artifact_url: packageRegistryParams.artifactUrl,
|
||||||
|
registry_repo: packageRegistryParams.registryRepo,
|
||||||
|
path: packageRegistryParams.path
|
||||||
})
|
})
|
||||||
|
|
||||||
const data =
|
const data =
|
||||||
|
|||||||
Reference in New Issue
Block a user