55
66package com .microsoft .azure .toolkit .intellij .function .runner .deploy ;
77
8+ import com .intellij .execution .process .ProcessOutputTypes ;
89import com .intellij .openapi .project .Project ;
910import com .intellij .psi .PsiMethod ;
11+ import com .microsoft .azure .toolkit .intellij .common .messager .IntellijAzureMessager ;
12+ import com .microsoft .azure .toolkit .lib .common .messager .AzureMessager ;
1013import com .microsoft .azure .toolkit .lib .legacy .function .configurations .FunctionConfiguration ;
1114import com .microsoft .azure .management .appservice .AppServicePlan ;
1215import com .microsoft .azure .management .appservice .FunctionApp ;
2730import com .microsoft .azuretools .utils .AzureUIRefreshCore ;
2831import com .microsoft .azuretools .utils .AzureUIRefreshEvent ;
2932import com .microsoft .intellij .RunProcessHandler ;
33+ import lombok .RequiredArgsConstructor ;
3034import org .apache .commons .lang .StringUtils ;
3135import org .jetbrains .annotations .NotNull ;
3236import org .jetbrains .annotations .Nullable ;
3337
38+ import javax .annotation .Nonnull ;
3439import java .io .File ;
3540import java .io .IOException ;
3641import java .nio .file .Path ;
@@ -57,6 +62,8 @@ public FunctionDeploymentState(Project project, FunctionDeployConfiguration func
5762 @ Override
5863 @ AzureOperation (name = "function.deploy.state" , type = AzureOperation .Type .ACTION )
5964 public WebAppBase executeSteps (@ NotNull RunProcessHandler processHandler , @ NotNull Operation operation ) throws Exception {
65+ final FunctionDeploymentMessenger messenger = new FunctionDeploymentMessenger (processHandler );
66+ AzureMessager .getContext ().setMessager (messenger );
6067 // Update run time information by function app
6168 final FunctionApp functionApp ;
6269 if (deployModel .isNewResource ()) {
@@ -73,11 +80,7 @@ public WebAppBase executeSteps(@NotNull RunProcessHandler processHandler, @NotNu
7380 stagingFolder = FunctionUtils .getTempStagingFolder ();
7481 deployModel .setDeploymentStagingDirectoryPath (stagingFolder .getPath ());
7582 prepareStagingFolder (stagingFolder , processHandler , operation );
76- final DeployFunctionHandler deployFunctionHandler = new DeployFunctionHandler (deployModel , message -> {
77- if (processHandler .isProcessRunning ()) {
78- processHandler .setText (message );
79- }
80- }, operation );
83+ final DeployFunctionHandler deployFunctionHandler = new DeployFunctionHandler (deployModel , operation );
8184 return deployFunctionHandler .execute ();
8285 }
8386
@@ -151,4 +154,32 @@ protected void onFail(@NotNull Throwable error, @NotNull RunProcessHandler proce
151154 protected Map <String , String > getTelemetryMap () {
152155 return functionDeployConfiguration .getModel ().getTelemetryProperties ();
153156 }
157+
158+ // todo: create shared run state messenger for all run states
159+ @ RequiredArgsConstructor
160+ private static class FunctionDeploymentMessenger extends IntellijAzureMessager {
161+ private final RunProcessHandler processHandler ;
162+
163+ @ Override
164+ public void info (@ Nonnull String message , String title ) {
165+ processHandler .setText (message );
166+ }
167+
168+ @ Override
169+ public void success (@ Nonnull String message , String title ) {
170+ processHandler .println (message , ProcessOutputTypes .SYSTEM );
171+ super .success (message , title );
172+ }
173+
174+ @ Override
175+ public void error (@ Nonnull String message , String title ) {
176+ processHandler .println (message , ProcessOutputTypes .STDERR );
177+ super .error (message , title );
178+ }
179+
180+ @ Override
181+ public void warning (@ Nonnull String message , String title ) {
182+ processHandler .setText (message );
183+ }
184+ }
154185}
0 commit comments