Skip to content

Commit

Permalink
add clear tag work around back for updating web app issue in sdk (#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
Summer authored Jul 25, 2018
1 parent 59077c9 commit f8a4e47
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,17 @@ public static RuntimeStack getLinuxRunTimeStack(String imageName) throws MojoExe
}
throw new MojoExecutionException(IMAGE_NOT_GIVEN);
}

/**
* Work Around:
* When a web app is created from Azure Portal, there are hidden tags associated with the app.
* It will be messed up when calling "update" API.
* An issue is logged at https://github.com/Azure/azure-sdk-for-java/issues/1755 .
* Remove all tags here to make it work.
*
* @param app
*/
public static void clearTags(final WebApp app) {
app.inner().withTags(null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public WithCreate defineAppWithRuntime() throws Exception {
@Override
public Update updateAppRuntime(final WebApp app) throws Exception {
WebAppUtils.assureWindowsWebApp(app);
WebAppUtils.clearTags(app);

final Update update = app.update();
update.withJavaVersion(mojo.getJavaVersion())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public WebApp.DefinitionStages.WithCreate defineAppWithRuntime() throws Exceptio
@Override
public Update updateAppRuntime(WebApp app) throws Exception {
WebAppUtils.assureLinuxWebApp(app);
WebAppUtils.clearTags(app);

return app.update().withBuiltInImage(getLinuxRunTimeStack(mojo.getLinuxRuntime()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.microsoft.azure.management.appservice.WebApp;
import com.microsoft.azure.management.appservice.WebApp.DefinitionStages.WithCreate;
import com.microsoft.azure.management.appservice.WebApp.Update;
import com.microsoft.azure.maven.webapp.WebAppUtils;
import org.apache.maven.plugin.MojoExecutionException;

public class NullRuntimeHandlerImpl implements RuntimeHandler {
Expand All @@ -22,6 +23,8 @@ public WithCreate defineAppWithRuntime() throws Exception {

@Override
public Update updateAppRuntime(final WebApp app) throws Exception {
WebAppUtils.clearTags(app);

return app.update();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public WithCreate defineAppWithRuntime() throws Exception {
@Override
public WebApp.Update updateAppRuntime(final WebApp app) throws Exception {
WebAppUtils.assureLinuxWebApp(app);
WebAppUtils.clearTags(app);

final ContainerSetting containerSetting = mojo.getContainerSettings();
final Server server = Utils.getServer(mojo.getSettings(), containerSetting.getServerId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public WithCreate defineAppWithRuntime() throws Exception {
@Override
public Update updateAppRuntime(final WebApp app) throws Exception {
WebAppUtils.assureLinuxWebApp(app);
WebAppUtils.clearTags(app);

final ContainerSetting containerSetting = mojo.getContainerSettings();
final Server server = Utils.getServer(mojo.getSettings(), containerSetting.getServerId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public WithCreate defineAppWithRuntime() throws Exception {
@Override
public Update updateAppRuntime(final WebApp app) throws Exception {
WebAppUtils.assureLinuxWebApp(app);
WebAppUtils.clearTags(app);

final ContainerSetting containerSetting = mojo.getContainerSettings();
return app.update().withPublicDockerHubImage(containerSetting.getImageName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public void updateAppRuntime() throws Exception {
final WebApp app = mock(WebApp.class);
final Update update = mock(Update.class);
doReturn(update).when(app).update();
final SiteInner siteInner = mock(SiteInner.class);
doReturn(siteInner).when(app).inner();

assertSame(update, handler.updateAppRuntime(app));
}
Expand Down

0 comments on commit f8a4e47

Please sign in to comment.