@@ -96,6 +96,9 @@ class WasmPluginServiceImpl implements WasmPluginService {
9696
9797 private static final String NAME_PLACEHOLDER = "${name}" ;
9898 private static final String VERSION_PLACEHOLDER = "${version}" ;
99+ private static final String OCI_PROTOCOL = "oci://" ;
100+ private static final String DEFAULT_IMAGE_REGISTRY = "higress-registry.cn-hangzhou.cr.aliyuncs.com" ;
101+ private static final String DEFAULT_IMAGE_NAMESPACE = "plugins" ;
99102
100103 private volatile List <PluginCacheItem > builtInPlugins = Collections .emptyList ();
101104
@@ -125,6 +128,8 @@ public void initialize() {
125128 final List <PluginCacheItem > plugins = new ArrayList <>(properties .size ());
126129
127130 final String customImageUrlPattern = wasmPluginServiceConfig .getCustomImageUrlPattern ();
131+ final String pluginImageRegistry = wasmPluginServiceConfig .getPluginImageRegistry ();
132+ final String pluginImageNamespace = wasmPluginServiceConfig .getPluginImageNamespace ();
128133 final String imagePullSecret = wasmPluginServiceConfig .getImagePullSecret ();
129134 final String imagePullPolicy = wasmPluginServiceConfig .getImagePullPolicy ();
130135
@@ -152,8 +157,8 @@ public void initialize() {
152157 ex );
153158 }
154159
155- cacheItem .imageUrl = StringUtils . isBlank ( customImageUrlPattern ) ? imageUrl
156- : formatImageUrl ( customImageUrlPattern , cacheItem .plugin .getInfo ());
160+ cacheItem .imageUrl = buildPluginImageUrl ( imageUrl , customImageUrlPattern , pluginImageRegistry ,
161+ pluginImageNamespace , cacheItem .plugin .getInfo ());
157162 cacheItem .imagePullSecret = imagePullSecret ;
158163 cacheItem .imagePullPolicy = imagePullPolicy ;
159164
@@ -185,6 +190,46 @@ private static String formatImageUrl(String pattern, PluginInfo pluginInfo) {
185190 .replace (VERSION_PLACEHOLDER , pluginInfo .getVersion ());
186191 }
187192
193+ private static String buildPluginImageUrl (String defaultUrl , String customPattern , String registry ,
194+ String namespace , PluginInfo pluginInfo ) {
195+ // Priority: customPattern > registry/namespace > defaultUrl
196+ if (StringUtils .isNotBlank (customPattern )) {
197+ return formatImageUrl (customPattern , pluginInfo );
198+ }
199+
200+ if (StringUtils .isBlank (registry ) && StringUtils .isBlank (namespace )) {
201+ return defaultUrl ;
202+ }
203+
204+ // Replace registry and/or namespace in the default URL
205+ // URL format: oci://registry/namespace/plugin-name:version
206+ if (!defaultUrl .startsWith (OCI_PROTOCOL )) {
207+ return defaultUrl ;
208+ }
209+
210+ String urlWithoutProtocol = defaultUrl .substring (OCI_PROTOCOL .length ());
211+ String targetRegistry = StringUtils .isNotBlank (registry ) ? registry : DEFAULT_IMAGE_REGISTRY ;
212+ String targetNamespace = StringUtils .isNotBlank (namespace ) ? namespace : DEFAULT_IMAGE_NAMESPACE ;
213+
214+ // Find the first slash to locate registry end
215+ int firstSlash = urlWithoutProtocol .indexOf ('/' );
216+ if (firstSlash == -1 ) {
217+ return defaultUrl ;
218+ }
219+
220+ // Find the second slash to locate namespace end
221+ int secondSlash = urlWithoutProtocol .indexOf ('/' , firstSlash + 1 );
222+ if (secondSlash == -1 ) {
223+ return defaultUrl ;
224+ }
225+
226+ // Extract the plugin name and version part (after second slash)
227+ String pluginPath = urlWithoutProtocol .substring (secondSlash + 1 );
228+
229+ // Rebuild the URL with new registry and namespace
230+ return OCI_PROTOCOL + targetRegistry + "/" + targetNamespace + "/" + pluginPath ;
231+ }
232+
188233 private void fillPluginConfigExample (Plugin plugin , String content ) {
189234 String example ;
190235 try {
0 commit comments