Skip to content

Conversation

@wwcchh0123
Copy link
Contributor

No description provided.

@gemini-code-assist
Copy link

Summary of Changes

Hello @wwcchh0123, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求旨在扩展CodeAgent Standard的功能,使其能够支持CNB平台。通过引入新的Terraform变量和更新设置脚本,用户现在可以轻松地在部署CodeAgent实例时配置CNB平台的连接参数,从而实现与CNB平台的集成。

Highlights

  • 新增CNB平台支持: 此拉取请求为CodeAgent Standard引入了对CNB平台的支持,包括在设置脚本中添加相关环境变量,并通过Terraform变量进行配置。
  • 引入yq工具: 为了更可靠地处理YAML配置文件,codeagent_setup.sh脚本现在会在配置过程中检查并安装yq工具。
  • 配置方式优化: 将codeagent_setup.sh中对codeagent.yaml的GitLab配置更新方式从sed命令切换为使用yq,提高了配置的健壮性和可读性。
  • 更新默认镜像ID: variables.tf中更新了CodeAgent预配置镜像的默认ID。

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

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

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 introduces support for configuring a new "CNB" platform within the CodeAgent setup, alongside the existing GitLab integration. The changes involve adding new Terraform variables for CNB's base URL, API URL, webhook secret, and token, and updating the codeagent_setup.sh script to process these variables. The setup script now utilizes yq for YAML configuration updates, replacing previous sed commands for GitLab and adding new logic for CNB. Review comments indicate that the yq installation method in the script needs to be revised to ensure the correct Go version is installed, as the apt package provides an incompatible Python version. Additionally, the review suggests that the CNB webhook secret and token updates should be conditional to prevent inadvertently clearing existing values and that multiple yq calls for CNB configuration should be merged for better performance.

Comment on lines +49 to +51
echo "yq not found, installing via apt..."
apt-get update -qq
apt-get install -y yq

Choose a reason for hiding this comment

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

critical

apt-get install -y yq 安装的 yq (通常是 Python 包装器) 与脚本中使用的 yq 命令语法 (Go 版本 v4+) 不兼容,这将导致脚本执行失败。

脚本中使用的语法 (例如 .path.key = "value") 是 Mike Farah 开发的 Go 版本 yq 的语法。而 Debian/Ubuntu 的 apt 源中的 yq 包是另一个基于 Python 的工具,其语法不同。

为了确保安装正确的版本,建议直接从 GitHub release 下载二进制文件。

Suggested change
echo "yq not found, installing via apt..."
apt-get update -qq
apt-get install -y yq
echo "yq not found, installing correct version from GitHub..."
# The yq syntax used requires the Go version, apt provides an incompatible python version.
wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq
chmod +x /usr/bin/yq

Comment on lines +113 to +116
yq -i -y ".platforms.cnb.instances.cool.base_url = \"$CNB_BASE_URL\"" "$CODEAGENT_CONF"
yq -i -y ".platforms.cnb.instances.cool.api_url = \"$CNB_API_URL\"" "$CODEAGENT_CONF"
yq -i -y ".platforms.cnb.instances.cool.webhook_secret = \"$CNB_WEBHOOK_SECRET\"" "$CODEAGENT_CONF"
yq -i -y ".platforms.cnb.instances.cool.token = \"$CNB_TOKEN\"" "$CODEAGENT_CONF"

Choose a reason for hiding this comment

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

high

这部分配置更新存在两个问题:

  1. (高危) CNB_WEBHOOK_SECRETCNB_TOKEN 是可选的,但这里是无条件更新。如果这两个变量为空,会把配置文件中已有的值清空。
  2. (优化) 多次调用 yq 会有性能开销,可以合并为一次调用。

建议修改为只在变量存在时才更新,并且可以考虑将多个更新操作合并。

Suggested change
yq -i -y ".platforms.cnb.instances.cool.base_url = \"$CNB_BASE_URL\"" "$CODEAGENT_CONF"
yq -i -y ".platforms.cnb.instances.cool.api_url = \"$CNB_API_URL\"" "$CODEAGENT_CONF"
yq -i -y ".platforms.cnb.instances.cool.webhook_secret = \"$CNB_WEBHOOK_SECRET\"" "$CODEAGENT_CONF"
yq -i -y ".platforms.cnb.instances.cool.token = \"$CNB_TOKEN\"" "$CODEAGENT_CONF"
yq -i -y ".platforms.cnb.instances.cool.base_url = \"$CNB_BASE_URL\" | .platforms.cnb.instances.cool.api_url = \"$CNB_API_URL\"" "$CODEAGENT_CONF"
if [ -n "$CNB_WEBHOOK_SECRET" ]; then
yq -i -y ".platforms.cnb.instances.cool.webhook_secret = \"$CNB_WEBHOOK_SECRET\"" "$CODEAGENT_CONF"
fi
if [ -n "$CNB_TOKEN" ]; then
yq -i -y ".platforms.cnb.instances.cool.token = \"$CNB_TOKEN\"" "$CODEAGENT_CONF"
fi

Comment on lines +120 to +121
echo " - Base URL: $CNB_BASE_URL"
echo " - API URL: $CNB_API_URL"
Copy link
Contributor

Choose a reason for hiding this comment

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

Security: Sensitive URL logging

Logging CNB URLs exposes internal infrastructure details to /var/log/codeagent_setup.log. Consider redacting these like the secrets:

Suggested change
echo " - Base URL: $CNB_BASE_URL"
echo " - API URL: $CNB_API_URL"
echo "✓ CNB platform configuration completed"
echo " - Base URL: [CONFIGURED]"
echo " - API URL: [CONFIGURED]"

Comment on lines +115 to +116
yq -i -y ".platforms.cnb.instances.cool.webhook_secret = \"$CNB_WEBHOOK_SECRET\"" "$CODEAGENT_CONF"
yq -i -y ".platforms.cnb.instances.cool.token = \"$CNB_TOKEN\"" "$CODEAGENT_CONF"
Copy link
Contributor

Choose a reason for hiding this comment

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

Code Quality: Missing conditional checks

Unlike GitLab config (lines 82-91), CNB unconditionally overwrites webhook_secret and token even if empty. This could clear existing values. Add conditional checks:

Suggested change
yq -i -y ".platforms.cnb.instances.cool.webhook_secret = \"$CNB_WEBHOOK_SECRET\"" "$CODEAGENT_CONF"
yq -i -y ".platforms.cnb.instances.cool.token = \"$CNB_TOKEN\"" "$CODEAGENT_CONF"
if [ -n "$CNB_WEBHOOK_SECRET" ]; then
yq -i -y ".platforms.cnb.instances.cool.webhook_secret = \"$CNB_WEBHOOK_SECRET\"" "$CODEAGENT_CONF"
fi
if [ -n "$CNB_TOKEN" ]; then
yq -i -y ".platforms.cnb.instances.cool.token = \"$CNB_TOKEN\"" "$CODEAGENT_CONF"
fi

Comment on lines +107 to +110
# Backup if not already backed up
if [ ! -f "$CODEAGENT_CONF.bak.cnb" ]; then
cp "$CODEAGENT_CONF" "$CODEAGENT_CONF.bak.cnb"
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

Performance: Redundant backup

GitLab section already creates .bak at line 75. This creates unnecessary duplicate backups and extra I/O. Consider removing this CNB-specific backup.

@xgopilot
Copy link
Contributor

xgopilot bot commented Dec 19, 2025

Great work adding CNB platform support! The implementation follows the GitLab pattern well and properly marks sensitive variables.

Critical issue: Documentation is missing - README and terraform.tfvars.example don't document the 4 new CNB variables, making this feature undiscoverable.

See inline comments for security and code quality improvements.

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.

1 participant