| 1 | import type * as binaryauthorization from "@distilled.cloud/gcp/binaryauthorization_v1"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { RuntimeContext } from "../../RuntimeContext.ts"; |
| 5 | import type { PlatformsPolicy } from "./PlatformsPolicy.ts"; |
| 6 | |
| 7 | export interface EvaluateGkePolicyRequest extends Omit< |
| 8 | binaryauthorization.EvaluateGkePolicyRequest, |
| 9 | never |
| 10 | > {} |
| 11 | |
| 12 | /** |
| 13 | * Runtime binding for Binary Authorization |
| 14 | * `platforms.gke.policies.evaluate`. |
| 15 | * |
| 16 | * Bind this operation to a {@link PlatformsPolicy} in a Function/Action |
| 17 | * init phase. Provide {@link EvaluateGkePolicyHttp}. |
| 18 | * |
| 19 | * ### Evaluating a GKE Policy |
| 20 | * **Example:** Evaluate a Pod against the bound policy |
| 21 | * ```typescript |
| 22 | * const evaluate = yield* GCP.BinaryAuthorization.EvaluateGkePolicy(policy); |
| 23 | * const result = yield* evaluate({ |
| 24 | * resource: { |
| 25 | * apiVersion: "v1", |
| 26 | * kind: "Pod", |
| 27 | * metadata: { name: "web", namespace: "default" }, |
| 28 | * spec: { containers: [{ name: "nginx", image: "nginx" }] }, |
| 29 | * }, |
| 30 | * }); |
| 31 | * ``` |
| 32 | * |
| 33 | * @binding |
| 34 | * @category BinaryAuthorization |
| 35 | */ |
| 36 | export interface EvaluateGkePolicy extends Binding.Service< |
| 37 | EvaluateGkePolicy, |
| 38 | "GCP.BinaryAuthorization.EvaluateGkePolicy", |
| 39 | ( |
| 40 | policy: PlatformsPolicy, |
| 41 | ) => Effect.Effect< |
| 42 | ( |
| 43 | request: EvaluateGkePolicyRequest, |
| 44 | ) => Effect.Effect< |
| 45 | binaryauthorization.EvaluateGkePolicyResponse, |
| 46 | binaryauthorization.EvaluateProjectsPlatformsGkePoliciesError, |
| 47 | RuntimeContext |
| 48 | > |
| 49 | > |
| 50 | > {} |
| 51 | |
| 52 | export const EvaluateGkePolicy = Binding.Service<EvaluateGkePolicy>( |
| 53 | "GCP.BinaryAuthorization.EvaluateGkePolicy", |
| 54 | ); |