зеркало из https://github.com/dotnet/tye.git
Refactore seq extensions (#815)
* refactored foreach * use of switch insted of ifs
This commit is contained in:
Родитель
3c7befca6c
Коммит
0b043fcb35
|
@ -2,6 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
@ -47,39 +48,48 @@ namespace Microsoft.Tye.Extensions.Seq
|
|||
seq.Volumes.Add(new VolumeBuilder(logPath, "seq-data", "/data"));
|
||||
}
|
||||
|
||||
foreach (var s in context.Application.Services)
|
||||
foreach (var serviceBuilder in context.Application.Services)
|
||||
{
|
||||
if (object.ReferenceEquals(s, seq))
|
||||
if (ReferenceEquals(serviceBuilder, seq))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// make seq available as a dependency of everything.
|
||||
if (!s.Dependencies.Contains(seq.Name))
|
||||
if (!serviceBuilder.Dependencies.Contains(seq.Name))
|
||||
{
|
||||
s.Dependencies.Add(seq.Name);
|
||||
serviceBuilder.Dependencies.Add(seq.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (context.Operation == ExtensionContext.OperationKind.LocalRun)
|
||||
switch (context.Operation)
|
||||
{
|
||||
if (context.Options!.LoggingProvider is null)
|
||||
{
|
||||
// For local development we hardcode the port and hostname
|
||||
context.Options.LoggingProvider = "seq=http://localhost:5341";
|
||||
}
|
||||
}
|
||||
else if (context.Operation == ExtensionContext.OperationKind.Deploy)
|
||||
{
|
||||
foreach (var project in context.Application.Services.OfType<DotnetProjectServiceBuilder>())
|
||||
{
|
||||
var sidecar = DiagnosticAgent.GetOrAddSidecar(project);
|
||||
case ExtensionContext.OperationKind.LocalRun:
|
||||
{
|
||||
if (context.Options!.LoggingProvider is null)
|
||||
{
|
||||
// For local development we hardcode the port and hostname
|
||||
context.Options.LoggingProvider = "seq=http://localhost:5341";
|
||||
}
|
||||
|
||||
// Use service discovery to find seq
|
||||
sidecar.Args.Add("--provider:seq=service:seq");
|
||||
sidecar.Dependencies.Add("seq");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ExtensionContext.OperationKind.Deploy:
|
||||
{
|
||||
foreach (var project in context.Application.Services.OfType<DotnetProjectServiceBuilder>())
|
||||
{
|
||||
var sidecar = DiagnosticAgent.GetOrAddSidecar(project);
|
||||
|
||||
// Use service discovery to find seq
|
||||
sidecar.Args.Add("--provider:seq=service:seq");
|
||||
sidecar.Dependencies.Add("seq");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
|
|
Загрузка…
Ссылка в новой задаче