The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as binaryauthorization from "@distilled.cloud/gcp/binaryauthorization_v1"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Layer from "effect/Layer"; |
| 4 | import * as GCPBindings from "../GCPBindings.ts"; |
| 5 | import { EvaluateGkePolicy, type EvaluateGkePolicyRequest } from "./EvaluateGkePolicy.ts"; |
| 6 | import type { PlatformsPolicy } from "./PlatformsPolicy.ts"; |
| 7 | |
| 8 | /** |
| 9 | * HTTP implementation of {@link EvaluateGkePolicy}. |
| 10 | * |
| 11 | * @layer |
| 12 | * @provides GCP.BinaryAuthorization.EvaluateGkePolicy |
| 13 | */ |
| 14 | export const EvaluateGkePolicyHttp = Layer.effect( |
| 15 | EvaluateGkePolicy, |
| 16 | Effect.gen(function* () { |
| 17 | const bind = yield* GCPBindings.Bind; |
| 18 | const evaluate = yield* GCPBindings.withCredentials( |
| 19 | binaryauthorization.evaluateProjectsPlatformsGkePolicies, |
| 20 | ); |
| 21 | return Effect.fn(function* (policy: PlatformsPolicy) { |
| 22 | if (!globalThis.__ALCHEMY_RUNTIME__) { |
| 23 | yield* bind`GCP.BinaryAuthorization.EvaluateGkePolicy(${policy})`({ |
| 24 | // Platform policies have no resource-level IAM. |
| 25 | iam: [{ role: "roles/binaryauthorization.policyEvaluator" }], |
| 26 | }); |
| 27 | } |
| 28 | const name = yield* policy.name; |
| 29 | return Effect.fn(`GCP.BinaryAuthorization.EvaluateGkePolicy(${policy.LogicalId})`)(function* ( |
| 30 | request: EvaluateGkePolicyRequest, |
| 31 | ) { |
| 32 | return yield* evaluate({ |
| 33 | name: yield* name, |
| 34 | body: request, |
| 35 | }); |
| 36 | }); |
| 37 | }); |
| 38 | }), |
| 39 | ); |