Skip to content

feat: add support for setting Cloud Run execution environment#195

Draft
Lyokone wants to merge 1 commit into
mainfrom
feat/execution-environment
Draft

feat: add support for setting Cloud Run execution environment#195
Lyokone wants to merge 1 commit into
mainfrom
feat/execution-environment

Conversation

@Lyokone

@Lyokone Lyokone commented May 28, 2026

Copy link
Copy Markdown
Contributor

closes #192

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for configuring the Cloud Run execution environment (gen1 or gen2) from function options, updating the builder, manifest generation, documentation, and tests. One important piece of feedback is that the _extractExecutionEnvironment method in spec.dart should be updated to handle parameterized, expression, and reset constructors (e.g., ExecutionEnvironment.param()) to ensure consistency with how other options are parsed.

Comment thread lib/src/builder/spec.dart
Comment on lines +338 to +357
Object? _extractExecutionEnvironment(Expression expression) {
final args = _extractCallArguments(expression);
final value = args?.firstOrNull;
final enumName = _extractEnumValueName(value);
if (enumName != null) {
return switch (enumName) {
'gen1' => 'gen1',
'gen2' => 'gen2',
_ => null,
};
}
if (value is StringLiteral) {
return switch (value.stringValue) {
'gen1' || 'gen2' => value.stringValue,
_ => null,
};
}

return null;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The _extractExecutionEnvironment method does not handle ExecutionEnvironment.param(), ExecutionEnvironment.expression(), or ExecutionEnvironment.reset() constructors. This means that if a user attempts to use a parameterized execution environment (e.g., ExecutionEnvironment.param(myParam)), the builder will fail to extract the parameter reference and return null.\n\nTo ensure consistency with other options like Memory and Cpu, we should check for these constructor names first and extract the parameter reference or CEL expression accordingly.

  Object? _extractExecutionEnvironment(Expression expression) {\n    if (expression is InstanceCreationExpression) {\n      final constructorName = expression.constructorName.name?.name;\n      if (constructorName == 'param') {\n        return _extractParamReference(expression);\n      }\n      if (constructorName == 'expression') {\n        return _extractCelExpression(\n          expression.argumentList.arguments.firstOrNull,\n        );\n      }\n      if (constructorName == 'reset') {\n        return null;\n      }\n    }\n\n    final args = _extractCallArguments(expression);\n    final value = args?.firstOrNull;\n    final enumName = _extractEnumValueName(value);\n    if (enumName != null) {\n      return switch (enumName) {\n        'gen1' => 'gen1',\n        'gen2' => 'gen2',\n        _ => null,\n      };\n    }\n    if (value is StringLiteral) {\n      return switch (value.stringValue) {\n        'gen1' || 'gen2' => value.stringValue,\n        _ => null,\n      };\n    }\n\n    return null;\n  }

@Lyokone Lyokone marked this pull request as draft June 1, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set the execution environment via CallableOptions

1 participant