encodeArg static method
Encode a single TfArg into a JSON-serialisable value.
TfArgLiteral<T>→ the rawTvalue (recursively walked in case the literal is a Map/List that itself containsTfArgs).TfRef<T>→ the${...}interpolation string.TfArgVariable<T>→ the${var.<name>}interpolation string.TfArgExpression<T>→ its template string, verbatim.
Implementation
static Object? encodeArg(TfArg<dynamic> arg) {
final raw = arg.toTfJson();
// Refs, variables and expressions produce final string forms (Terraform
// templates). Only literals may still hold nested `TfArg` instances
// inside Maps/Lists that need recursion.
if (arg is TfRef || arg is TfArgVariable || arg is TfArgExpression) {
return raw;
}
return _encodeLiteralValue(raw);
}