| 1 | import * as artifactregistry from "@distilled.cloud/gcp/artifactregistry_v1"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Layer from "effect/Layer"; |
| 4 | import { |
| 5 | ListDockerImages, |
| 6 | type ListDockerImagesRequest, |
| 7 | } from "./ListDockerImages.ts"; |
| 8 | import type { Repository } from "./Repository.ts"; |
| 9 | import { bindGcpHost } from "../Host.ts"; |
| 10 | import { grantFor } from "../HttpBinding.ts"; |
| 11 | |
| 12 | /** |
| 13 | * HTTP implementation of {@link ListDockerImages}. |
| 14 | * |
| 15 | * @layer |
| 16 | * @provides GCP.ArtifactRegistry.ListDockerImages |
| 17 | */ |
| 18 | export const ListDockerImagesHttp = Layer.effect( |
| 19 | ListDockerImages, |
| 20 | Effect.gen(function* () { |
| 21 | const listDockerImages = |
| 22 | yield* artifactregistry.listProjectsLocationsRepositoriesDockerImages; |
| 23 | return Effect.fn(function* (repository: Repository) { |
| 24 | yield* bindGcpHost({ |
| 25 | tag: "GCP.ArtifactRegistry.ListDockerImages", |
| 26 | resource: repository, |
| 27 | iam: [ |
| 28 | grantFor( |
| 29 | { |
| 30 | role: "roles/artifactregistry.reader", |
| 31 | on: "artifactregistry.repository", |
| 32 | }, |
| 33 | repository.name, |
| 34 | ), |
| 35 | ], |
| 36 | }); |
| 37 | const name = yield* repository.name; |
| 38 | return Effect.fn( |
| 39 | `GCP.ArtifactRegistry.ListDockerImages(${repository.LogicalId})`, |
| 40 | )(function* (request?: ListDockerImagesRequest) { |
| 41 | return yield* listDockerImages({ |
| 42 | ...request, |
| 43 | parent: yield* name, |
| 44 | }); |
| 45 | }); |
| 46 | }); |
| 47 | }), |
| 48 | ); |