Skip to content

fix: reuse PLUGIN_REGISTRY for IMAGE_REPO construction#240

Merged
johnlanni merged 1 commit into
mainfrom
fix/reuse-plugin-registry-in-image-repo
Feb 2, 2026
Merged

fix: reuse PLUGIN_REGISTRY for IMAGE_REPO construction#240
johnlanni merged 1 commit into
mainfrom
fix/reuse-plugin-registry-in-image-repo

Conversation

@johnlanni
Copy link
Copy Markdown
Contributor

Problem

After #239, IMAGE_REPO and PLUGIN_REGISTRY are set independently, which means:

  • Duplicate registry domain logic
  • Potential inconsistency (could use different registries)
  • Violates DRY principle

Solution

Reuse PLUGIN_REGISTRY when constructing IMAGE_REPO:

# Before (in resetEnv):
IMAGE_REPO="${IMAGE_REPO:-$DEFAULT_IMAGE_REPO}"
detectPluginRegistry
PLUGIN_REGISTRY="${PLUGIN_REGISTRY:-$DEFAULT_PLUGIN_REGISTRY}"

# After:
detectPluginRegistry
PLUGIN_REGISTRY="${PLUGIN_REGISTRY:-$DEFAULT_PLUGIN_REGISTRY}"

if [ -z "$IMAGE_REPO" ]; then
  IMAGE_REPO="${PLUGIN_REGISTRY}/higress/all-in-one"
fi

Changes

  1. Reorder in resetEnv():

    • Detect PLUGIN_REGISTRY first
    • Then construct IMAGE_REPO from it
  2. Conditional IMAGE_REPO construction:

    • If IMAGE_REPO explicitly set → use it (backward compatible)
    • If not set → build from PLUGIN_REGISTRY

Benefits

Single source of truth - Registry domain only detected once
Guaranteed consistency - Container image and plugins always use same registry
DRY principle - No duplicate timezone → registry mapping logic
Backward compatible - Users can still override IMAGE_REPO explicitly

Example Behavior

Auto-detection (typical):

./get-ai-gateway.sh start --non-interactive --dashscope-key sk-xxx
# Output:
# Auto-detected timezone: Asia/Singapore
# Selected plugin registry: higress-registry.ap-southeast-7.cr.aliyuncs.com
#
# Both will use: higress-registry.ap-southeast-7.cr.aliyuncs.com
# - IMAGE_REPO: higress-registry.ap-southeast-7.cr.aliyuncs.com/higress/all-in-one
# - PLUGIN_REGISTRY: higress-registry.ap-southeast-7.cr.aliyuncs.com

Explicit override (advanced):

IMAGE_REPO="custom-registry.example.com/my-higress:latest" \
  ./get-ai-gateway.sh start --non-interactive --dashscope-key sk-xxx
# IMAGE_REPO: custom-registry.example.com/my-higress:latest (user override)
# PLUGIN_REGISTRY: higress-registry.cn-hangzhou.cr.aliyuncs.com (auto-detected)

Partial override (typical):

PLUGIN_REGISTRY="higress-registry.us-west-1.cr.aliyuncs.com" \
  ./get-ai-gateway.sh start --non-interactive --dashscope-key sk-xxx
# IMAGE_REPO: higress-registry.us-west-1.cr.aliyuncs.com/higress/all-in-one (derived)
# PLUGIN_REGISTRY: higress-registry.us-west-1.cr.aliyuncs.com (user override)

Testing

  • Script syntax validation (bash -n)
  • IMAGE_REPO derived from PLUGIN_REGISTRY when not set
  • Explicit IMAGE_REPO override still works
  • Both variables use same registry domain in default case

Related

Ensure IMAGE_REPO and PLUGIN_REGISTRY use the same registry domain
by constructing IMAGE_REPO from PLUGIN_REGISTRY when not explicitly set.

Before:
- IMAGE_REPO and PLUGIN_REGISTRY were set independently
- Could potentially use different registries
- Duplicated registry domain logic

After:
- PLUGIN_REGISTRY is detected first (via detectPluginRegistry)
- IMAGE_REPO is built from PLUGIN_REGISTRY: ${PLUGIN_REGISTRY}/higress/all-in-one
- Ensures both use the same geographically optimal registry

Behavior:
1. User sets IMAGE_REPO explicitly → use user's value (backward compatible)
2. User doesn't set IMAGE_REPO → construct from PLUGIN_REGISTRY (DRY)

Benefits:
- Single source of truth for registry domain (PLUGIN_REGISTRY)
- No duplicate registry selection logic
- Container image and plugins always use same registry
- Maintains backward compatibility with explicit IMAGE_REPO
@johnlanni johnlanni requested a review from CH3CHO as a code owner February 2, 2026 03:32
@lingma-agents
Copy link
Copy Markdown

lingma-agents Bot commented Feb 2, 2026

🔍 代码审查进行中

⏳ 正在审查

⏰️ 剩余时间:约需数分钟

🔄 分支流向: fix/reuse-plugin-registry-in-image-repomain

📦 提交: 审查当前PR从123aa03ec22c83的提交。


📒 文件清单 (1 个文件)
📝 变更: 1 个文件

📝 变更文件:

  • all-in-one/get-ai-gateway.sh

johnlanni added a commit to higress-group/higress that referenced this pull request Feb 2, 2026
Simplify environment variables documentation to only expose
PLUGIN_REGISTRY, which now controls both container images and plugins.

Changes:
- Remove IMAGE_REPO from Environment Variables table
- Update description: PLUGIN_REGISTRY controls both images and plugins
- Simplify auto-selection logic explanation
- Update manual override example to only use PLUGIN_REGISTRY

Rationale:
- After higress-group/higress-standalone#240, IMAGE_REPO is derived
  from PLUGIN_REGISTRY automatically
- Users only need to set PLUGIN_REGISTRY to control registry selection
- Simpler interface, single source of truth

Related: higress-group/higress-standalone#240
@johnlanni johnlanni merged commit 73bab41 into main Feb 2, 2026
3 of 4 checks passed
@lingma-agents
Copy link
Copy Markdown

lingma-agents Bot commented Feb 2, 2026

CodeReview流程已终止

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