diff --git a/application/src/main/java/run/halo/app/core/extension/reconciler/PluginReconciler.java b/application/src/main/java/run/halo/app/core/extension/reconciler/PluginReconciler.java index 2e2f8161e8..92d0750bf7 100644 --- a/application/src/main/java/run/halo/app/core/extension/reconciler/PluginReconciler.java +++ b/application/src/main/java/run/halo/app/core/extension/reconciler/PluginReconciler.java @@ -142,7 +142,7 @@ boolean readinessDetection(String name) { if (waitForSettingCreation(plugin)) { return true; } - createInitialReverseProxyIfNotPresent(plugin); + recreateDefaultReverseProxy(plugin); updateStatus(name, status -> { String logoUrl = generateAccessibleLogoUrl(plugin); @@ -764,7 +764,7 @@ Path determinePluginLocation(Plugin plugin) { return Paths.get(pluginLocation); } - void createInitialReverseProxyIfNotPresent(Plugin plugin) { + void recreateDefaultReverseProxy(Plugin plugin) { String pluginName = plugin.getMetadata().getName(); String reverseProxyName = initialReverseProxyName(pluginName); ReverseProxy reverseProxy = new ReverseProxy(); @@ -785,11 +785,9 @@ void createInitialReverseProxyIfNotPresent(Plugin plugin) { client.fetch(ReverseProxy.class, reverseProxyName) .ifPresentOrElse(persisted -> { - if (isDevelopmentMode(pluginName)) { - reverseProxy.getMetadata() - .setVersion(persisted.getMetadata().getVersion()); - client.update(reverseProxy); - } + reverseProxy.getMetadata() + .setVersion(persisted.getMetadata().getVersion()); + client.update(reverseProxy); }, () -> client.create(reverseProxy)); } diff --git a/application/src/test/java/run/halo/app/core/extension/reconciler/PluginReconcilerTest.java b/application/src/test/java/run/halo/app/core/extension/reconciler/PluginReconcilerTest.java index 00228014f1..811e2c9271 100644 --- a/application/src/test/java/run/halo/app/core/extension/reconciler/PluginReconcilerTest.java +++ b/application/src/test/java/run/halo/app/core/extension/reconciler/PluginReconcilerTest.java @@ -40,7 +40,6 @@ import org.pf4j.PluginDescriptor; import org.pf4j.PluginState; import org.pf4j.PluginWrapper; -import org.pf4j.RuntimeMode; import org.skyscreamer.jsonassert.JSONAssert; import org.springframework.context.ApplicationEventPublisher; import run.halo.app.core.extension.Plugin; @@ -233,14 +232,14 @@ void shouldReconcileStopWhenEnabledIsFalseAndPhaseIsStartedButStopFailed() { } @Test - void createInitialReverseProxyWhenNotExistAndLogoIsPath() throws JSONException { + void recreateDefaultReverseProxyWhenNotExistAndLogoIsPath() throws JSONException { Plugin plugin = need2ReconcileForStopState(); String reverseProxyName = initialReverseProxyName(plugin.getMetadata().getName()); when(extensionClient.fetch(eq(ReverseProxy.class), eq(reverseProxyName))) .thenReturn(Optional.empty()); plugin.getSpec().setLogo("/logo.png"); - pluginReconciler.createInitialReverseProxyIfNotPresent(plugin); + pluginReconciler.recreateDefaultReverseProxy(plugin); ArgumentCaptor captor = ArgumentCaptor.forClass(ReverseProxy.class); verify(extensionClient, times(1)).create(captor.capture()); ReverseProxy value = captor.getValue(); @@ -269,14 +268,14 @@ void createInitialReverseProxyWhenNotExistAndLogoIsPath() throws JSONException { } @Test - void createInitialReverseProxyWhenNotExistAndLogoIsAbsolute() { + void recreateDefaultReverseProxyWhenNotExistAndLogoIsAbsolute() { Plugin plugin = need2ReconcileForStopState(); String reverseProxyName = initialReverseProxyName(plugin.getMetadata().getName()); when(extensionClient.fetch(eq(ReverseProxy.class), eq(reverseProxyName))) .thenReturn(Optional.empty()); plugin.getSpec().setLogo("http://example.com/logo"); - pluginReconciler.createInitialReverseProxyIfNotPresent(plugin); + pluginReconciler.recreateDefaultReverseProxy(plugin); ArgumentCaptor captor = ArgumentCaptor.forClass(ReverseProxy.class); verify(extensionClient, times(1)).create(captor.capture()); ReverseProxy value = captor.getValue(); @@ -284,7 +283,7 @@ void createInitialReverseProxyWhenNotExistAndLogoIsAbsolute() { } @Test - void createInitialReverseProxyWhenExist() { + void recreateDefaultReverseProxyWhenExist() { Plugin plugin = need2ReconcileForStopState(); plugin.getSpec().setLogo("/logo.png"); @@ -296,14 +295,9 @@ void createInitialReverseProxyWhenExist() { when(extensionClient.fetch(eq(ReverseProxy.class), eq(reverseProxyName))) .thenReturn(Optional.of(reverseProxy)); - when(pluginWrapper.getRuntimeMode()).thenReturn(RuntimeMode.DEPLOYMENT); - pluginReconciler.createInitialReverseProxyIfNotPresent(plugin); - verify(extensionClient, times(0)).update(any()); - - when(pluginWrapper.getRuntimeMode()).thenReturn(RuntimeMode.DEVELOPMENT); - pluginReconciler.createInitialReverseProxyIfNotPresent(plugin); - verify(extensionClient, times(1)).update(any()); + pluginReconciler.recreateDefaultReverseProxy(plugin); + verify(extensionClient).update(any()); } @Nested