/** * Policy Parsing Utilities * * Reusable parsing functions for semantic validation in OPA Rego policies. * These utilities handle common format conversions (CPU, memory, etc.) to * enable semantic analysis beyond simple pattern matching. */ import { type Result } from '../types/index.js'; /** * Parse CPU resource string to millicores. * * Supports formats: * - "1000m" -> 1000 * - "1.5" -> 1500 * - "1" -> 1000 * - "0.5" -> 500 * * @param cpu - CPU string in Kubernetes format * @returns Millicores as a number * * @example * parseCPU("1000m") // 1000 * parseCPU("1.5") // 1500 * parseCPU("2") // 2000 */ export declare function parseCPU(cpu: string): Result; /** * Parse memory resource string to bytes. * * Supports formats: * - "512Mi" -> 536870912 * - "2Gi" -> 2147483648 * - "1G" -> 1000000000 * - "512M" -> 512000000 * - "1024" -> 1024 (bytes) * * @param memory - Memory string in Kubernetes format * @returns Bytes as a number * * @example * parseMemory("512Mi") // 536870912 * parseMemory("2Gi") // 2147483648 * parseMemory("1G") // 1000000000 */ export declare function parseMemory(memory: string): Result; /** * Extract image name from Dockerfile content. * * Looks for the final stage's FROM instruction or the last FROM in single-stage builds. * Does NOT include the image name defined by build output (that's in build metadata). * * @param dockerfile - Dockerfile content as string * @returns Base image name * * @example * extractImageName("FROM node:18-alpine\nRUN npm install") * // "node:18-alpine" */ export declare function extractImageName(dockerfile: string): Result; /** * Extract EXPOSE ports from Dockerfile content. * * Returns all exposed ports as numbers. * * @param dockerfile - Dockerfile content as string * @returns Array of port numbers * * @example * extractPorts("FROM node:18\nEXPOSE 3000\nEXPOSE 8080") * // [3000, 8080] */ export declare function extractPorts(dockerfile: string): Result; /** * Calculate resource efficiency ratio (limit/request). * * Higher ratios indicate potential over-provisioning. * Ratios > 4x typically suggest wasteful allocation. * * @param limit - Resource limit value * @param request - Resource request value * @returns Ratio as a number * * @example * calculateResourceRatio(4000, 500) // 8.0 (over-provisioned!) * calculateResourceRatio(2000, 1000) // 2.0 (reasonable) */ export declare function calculateResourceRatio(limit: number, request: number): Result; /** * Extract container image from Kubernetes manifest. * * Looks for the image field in container specs. * * @param manifest - Kubernetes manifest as object * @returns Array of container images * * @example * extractManifestImages({ spec: { containers: [{ image: "myapp:v1" }] } }) * // ["myapp:v1"] */ export declare function extractManifestImages(manifest: unknown): Result; /** * Extract target ports from Kubernetes Service manifest. * * @param service - Kubernetes Service manifest * @returns Array of target port numbers * * @example * extractServicePorts({ spec: { ports: [{ targetPort: 3000 }] } }) * // [3000] */ export declare function extractServicePorts(service: unknown): Result; //# sourceMappingURL=policy-parsers.d.ts.map