Browse Source

Fix #91 - Added elapsed time for Init, Deploy & Undeploy commands (#505)

jkotalik/fixAzureFunctions
Nilesh Gule 6 years ago
committed by GitHub
parent
commit
d1353b19a8
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      src/tye/Program.DeployCommand.cs
  2. 9
      src/tye/Program.InitCommand.cs
  3. 12
      src/tye/UndeployHost.cs

8
src/tye/Program.DeployCommand.cs

@ -59,6 +59,8 @@ namespace Microsoft.Tye
private static async Task ExecuteDeployAsync(OutputContext output, ApplicationBuilder application, string environment, bool interactive, bool force) private static async Task ExecuteDeployAsync(OutputContext output, ApplicationBuilder application, string environment, bool interactive, bool force)
{ {
var watch = System.Diagnostics.Stopwatch.StartNew();
if (!await KubectlDetector.Instance.IsKubectlInstalled.Value) if (!await KubectlDetector.Instance.IsKubectlInstalled.Value)
{ {
throw new CommandException($"Cannot apply manifests because kubectl is not installed."); throw new CommandException($"Cannot apply manifests because kubectl is not installed.");
@ -98,6 +100,12 @@ namespace Microsoft.Tye
}; };
await executor.ExecuteAsync(application); await executor.ExecuteAsync(application);
watch.Stop();
TimeSpan elapsedTime = watch.Elapsed;
output.WriteAlwaysLine($"Time Elapsed: {elapsedTime.Hours:00}:{elapsedTime.Minutes:00}:{elapsedTime.Seconds:00}:{elapsedTime.Milliseconds / 10:00}");
} }
internal static void ApplyRegistry(OutputContext output, ApplicationBuilder application, bool interactive, bool requireRegistry) internal static void ApplyRegistry(OutputContext output, ApplicationBuilder application, bool interactive, bool requireRegistry)

9
src/tye/Program.InitCommand.cs

@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license. // The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System;
using System.CommandLine; using System.CommandLine;
using System.CommandLine.Invocation; using System.CommandLine.Invocation;
using System.CommandLine.IO; using System.CommandLine.IO;
@ -29,8 +30,16 @@ namespace Microsoft.Tye
command.Handler = CommandHandler.Create<IConsole, FileInfo?, bool>((console, path, force) => command.Handler = CommandHandler.Create<IConsole, FileInfo?, bool>((console, path, force) =>
{ {
var watch = System.Diagnostics.Stopwatch.StartNew();
var outputFilePath = InitHost.CreateTyeFile(path, force); var outputFilePath = InitHost.CreateTyeFile(path, force);
console.Out.WriteLine($"Created '{outputFilePath}'."); console.Out.WriteLine($"Created '{outputFilePath}'.");
watch.Stop();
TimeSpan elapsedTime = watch.Elapsed;
console.Out.WriteLine($"Time Elapsed: {elapsedTime.Hours:00}:{elapsedTime.Minutes:00}:{elapsedTime.Seconds:00}:{elapsedTime.Milliseconds / 10:00}");
}); });
return command; return command;

12
src/tye/UndeployHost.cs

@ -19,6 +19,8 @@ namespace Microsoft.Tye
{ {
public static async Task UndeployAsync(IConsole console, FileInfo path, Verbosity verbosity, string @namespace, bool interactive, bool whatIf) public static async Task UndeployAsync(IConsole console, FileInfo path, Verbosity verbosity, string @namespace, bool interactive, bool whatIf)
{ {
var watch = System.Diagnostics.Stopwatch.StartNew();
var output = new OutputContext(console, verbosity); var output = new OutputContext(console, verbosity);
output.WriteInfoLine("Loading Application Details..."); output.WriteInfoLine("Loading Application Details...");
@ -31,6 +33,12 @@ namespace Microsoft.Tye
} }
await ExecuteUndeployAsync(output, application, @namespace, interactive, whatIf); await ExecuteUndeployAsync(output, application, @namespace, interactive, whatIf);
watch.Stop();
TimeSpan elapsedTime = watch.Elapsed;
output.WriteAlwaysLine($"Time Elapsed: {elapsedTime.Hours:00}:{elapsedTime.Minutes:00}:{elapsedTime.Seconds:00}:{elapsedTime.Milliseconds / 10:00}");
} }
public static async Task ExecuteUndeployAsync(OutputContext output, ConfigApplication application, string @namespace, bool interactive, bool whatIf) public static async Task ExecuteUndeployAsync(OutputContext output, ConfigApplication application, string @namespace, bool interactive, bool whatIf)
@ -52,10 +60,10 @@ namespace Microsoft.Tye
// - kubectl api-resources --all (and similar) are implemented client-side (n+1 problem) // - kubectl api-resources --all (and similar) are implemented client-side (n+1 problem)
// - the C# k8s SDK doesn't have an untyped api for operations on arbitrary resources, the // - the C# k8s SDK doesn't have an untyped api for operations on arbitrary resources, the
// closest thing is the custom resource APIs // closest thing is the custom resource APIs
// - Legacy resources without an api group don't follow the same URL scheme as more modern // - Legacy resources without an api group don't follow the same URL scheme as more modern
// ones, and thus cannot be addressed using the custom resource APIs. // ones, and thus cannot be addressed using the custom resource APIs.
// //
// So solving 'undeploy' generically would involve doing a bunch of work to query things // So solving 'undeploy' generically would involve doing a bunch of work to query things
// generically, including going outside of what's provided by the SDK. // generically, including going outside of what's provided by the SDK.
// //
// - querying api-resources // - querying api-resources

Loading…
Cancel
Save