use cel::common::ast::CallExpr;
use ferricel_types::functions::RuntimeFunction;
use walrus::InstrSeqBuilder;
use crate::compiler::{
context::{CompilerContext, CompilerEnv},
helpers::compile_call_unary,
};
pub fn compile_k8s_url_function(
func_name: &str,
call_expr: &CallExpr,
body: &mut InstrSeqBuilder,
env: &CompilerEnv,
ctx: &CompilerContext,
module: &mut walrus::Module,
) -> Result<(), anyhow::Error> {
let runtime_fn = match func_name {
"url" => RuntimeFunction::K8sUrlParse,
"isURL" => RuntimeFunction::K8sIsUrl,
"getScheme" => RuntimeFunction::K8sUrlGetScheme,
"getHost" => RuntimeFunction::K8sUrlGetHost,
"getHostname" => RuntimeFunction::K8sUrlGetHostname,
"getPort" => RuntimeFunction::K8sUrlGetPort,
"getEscapedPath" => RuntimeFunction::K8sUrlGetEscapedPath,
"getQuery" => RuntimeFunction::K8sUrlGetQuery,
_ => anyhow::bail!("Unknown Kubernetes URL function: {}", func_name),
};
compile_call_unary(call_expr, func_name, runtime_fn, body, env, ctx, module)
}