0

Delete Container Registry Repository Tag

by
Published Dec 20, 2024

To delete a container repository tag, send a DELETE request to `/v2/registry/$REGISTRY_NAME/repositories/$REPOSITORY_NAME/tags/$TAG`.

Script digitalocean Verified

The script

Submitted by hugo697 Bun
Verified 536 days ago
1
//native
2
type Digitalocean = {
3
  token: string;
4
};
5
/**
6
 * Delete Container Registry Repository Tag
7
 * To delete a container repository tag, send a DELETE request to
8
`/v2/registry/$REGISTRY_NAME/repositories/$REPOSITORY_NAME/tags/$TAG`.
9
 */
10
export async function main(
11
  auth: Digitalocean,
12
  registry_name: string,
13
  repository_name: string,
14
  repository_tag: string,
15
) {
16
  const url = new URL(
17
    `https://api.digitalocean.com/v2/registry/${registry_name}/repositories/${repository_name}/tags/${repository_tag}`,
18
  );
19

20
  const response = await fetch(url, {
21
    method: "DELETE",
22
    headers: {
23
      Authorization: "Bearer " + auth.token,
24
    },
25
    body: undefined,
26
  });
27
  if (!response.ok) {
28
    const text = await response.text();
29
    throw new Error(`${response.status} ${text}`);
30
  }
31
  return await response.json();
32
}
33