The best way to control Claude Code, Codex and more from any computer or phone

main
ts 47 lines 1.53 KB
Raw
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 * as GCPBindings from "../GCPBindings.ts";
5 import { grantFor } from "../HttpBinding.ts";
6 import { ListDockerImages, type ListDockerImagesRequest } from "./ListDockerImages.ts";
7 import type { Repository } from "./Repository.ts";
8
9 /**
10 * HTTP implementation of {@link ListDockerImages}.
11 *
12 * @layer
13 * @provides GCP.ArtifactRegistry.ListDockerImages
14 */
15 export const ListDockerImagesHttp = Layer.effect(
16 ListDockerImages,
17 Effect.gen(function* () {
18 const bind = yield* GCPBindings.Bind;
19 const listDockerImages = yield* GCPBindings.withCredentials(
20 artifactregistry.listProjectsLocationsRepositoriesDockerImages,
21 );
22 return Effect.fn(function* (repository: Repository) {
23 if (!globalThis.__ALCHEMY_RUNTIME__) {
24 yield* bind`GCP.ArtifactRegistry.ListDockerImages(${repository})`({
25 iam: [
26 grantFor(
27 {
28 role: "roles/artifactregistry.reader",
29 on: "artifactregistry.repository",
30 },
31 repository.name,
32 ),
33 ],
34 });
35 }
36 const name = yield* repository.name;
37 return Effect.fn(`GCP.ArtifactRegistry.ListDockerImages(${repository.LogicalId})`)(function* (
38 request?: ListDockerImagesRequest,
39 ) {
40 return yield* listDockerImages({
41 ...request,
42 parent: yield* name,
43 });
44 });
45 });
46 }),
47 );