-
Notifications
You must be signed in to change notification settings - Fork 472
Expand file tree
/
Copy pathLanguageWorkerHelper.cs
More file actions
41 lines (38 loc) · 1.64 KB
/
LanguageWorkerHelper.cs
File metadata and controls
41 lines (38 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
using System.Runtime.InteropServices;
namespace Azure.Functions.Cli.Helpers
{
public static class LanguageWorkerHelper
{
private static readonly Dictionary<WorkerRuntime, string> _map = new Dictionary<WorkerRuntime, string>
{
{ WorkerRuntime.Node, "languageWorkers:node:arguments" },
{ WorkerRuntime.Python, "languageWorkers:python:arguments" },
{ WorkerRuntime.Java, "languageWorkers:java:arguments" },
{ WorkerRuntime.Powershell, "languageWorkers:powershell:arguments" },
{ WorkerRuntime.Dotnet, string.Empty },
{ WorkerRuntime.Custom, string.Empty },
{ WorkerRuntime.Native, string.Empty },
{ WorkerRuntime.None, string.Empty }
}
.Select(p => RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
? p
: new KeyValuePair<WorkerRuntime, string>(p.Key, p.Value.Replace(":", "__")))
.ToDictionary(k => k.Key, v => v.Value);
public static IReadOnlyDictionary<string, string> GetWorkerConfiguration(string value)
{
if (_map.ContainsKey(GlobalCoreToolsSettings.CurrentWorkerRuntime) && !string.IsNullOrWhiteSpace(value))
{
return new Dictionary<string, string>
{
{ _map[GlobalCoreToolsSettings.CurrentWorkerRuntime], value }
};
}
else
{
return new Dictionary<string, string>();
}
}
}
}