Skip to content
This repository was archived by the owner on May 16, 2025. It is now read-only.

Commit 564cd16

Browse files
authored
Fixes missing gcloud checks. (#819)
* Add proper check for gcloud. * Check for gcloud.
1 parent 0cd69c1 commit 564cd16

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

GoogleCloudExtension/GoogleCloudExtension.Deployment/WindowsVmDeployment.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,17 @@ private static async Task<bool> CreateAppBundleAsync(
138138
139139
outputAction($"msbuild.exe {arguments}");
140140
bool result = await ProcessUtils.RunCommandAsync(toolsPathProvider.GetMsbuildPath(), arguments, (o, e) => outputAction(e.Line));
141-
await GCloudWrapper.GenerateSourceContext(project.DirectoryPath, stageDirectory);
141+
142+
// We perform this check here because it is not required to have gcloud installed in order to deploy
143+
// ASP.NET 4.x apps to GCE VMs. Therefore nothing would have checked for the presence of gcloud before
144+
// getting here.
145+
var gcloudValidation = await GCloudWrapper.ValidateGCloudAsync();
146+
Debug.WriteLineIf(!gcloudValidation.IsValid, "Skipping creating context, gcloud is not installed.");
147+
if (gcloudValidation.IsValid)
148+
{
149+
await GCloudWrapper.GenerateSourceContext(project.DirectoryPath, stageDirectory);
150+
}
151+
142152
return result;
143153
}
144154
}

GoogleCloudExtension/GoogleCloudExtension.GCloud/GCloudWrapper.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,6 @@ public static class GCloudWrapper
4848
[ GCloudComponent.Kubectl ] = "kubectl",
4949
};
5050

51-
/// <summary>
52-
/// Finds the location of gcloud.cmd by following all of the directories in the PATH environment
53-
/// variable until it finds it. With this we assume that in order to run the extension gcloud.cmd is
54-
/// in the PATH.
55-
/// </summary>
56-
public static string GetGCloudPath() => PathUtils.GetCommandPathFromPATH("gcloud.cmd");
57-
5851
/// <summary>
5952
/// Resets, or creates, the password for the given <paramref name="userName"/> in the given instance.
6053
/// </summary>
@@ -219,7 +212,7 @@ private static async Task<IList<string>> GetInstalledComponentsAsync()
219212
private static bool IsGCloudCliInstalled()
220213
{
221214
Debug.WriteLine("Validating GCloud installation.");
222-
var gcloudPath = GetGCloudPath();
215+
var gcloudPath = PathUtils.GetCommandPathFromPATH("gcloud.cmd");
223216
Debug.WriteLineIf(gcloudPath == null, "Cannot find gcloud.cmd in the system.");
224217
Debug.WriteLineIf(gcloudPath != null, $"Found gcloud.cmd at {gcloudPath}");
225218
return gcloudPath != null;

GoogleCloudExtension/GoogleCloudExtension/ManageWindowsCredentials/ManageWindowsCredentialsViewModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,11 @@ private async Task<WindowsInstanceCredentials> CreateOrResetCredentials(string u
191191
}
192192

193193
Debug.WriteLine($"Resetting the password for the user {user}");
194+
if (!await GCloudWrapperUtils.VerifyGCloudDependencies())
195+
{
196+
Debug.WriteLine("Gcloud dependencies not met, aborting change of password.");
197+
return null;
198+
}
194199

195200
var context = new GCloudContext
196201
{

0 commit comments

Comments
 (0)