-
Notifications
You must be signed in to change notification settings - Fork 1
/
LocalAppDeploymentConfig.cs
54 lines (44 loc) · 1.9 KB
/
LocalAppDeploymentConfig.cs
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
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.Collections.Generic;
using System.IO;
using Etg.Yams.Application;
using Etg.Yams.Json;
using Etg.Yams.Storage.Config;
using Newtonsoft.Json.Serialization;
namespace Wivuu.Yams.Local
{
public class LocalAppDeploymentConfig : AppDeploymentConfig
{
public string ExeRoot { get; }
public DateTimeOffset? EntryPointCreatedDate { get; }
public LocalAppDeploymentConfig(string exeRoot, AppIdentity appIdentity) : base(appIdentity)
{
ExeRoot = exeRoot;
EntryPointCreatedDate = GetWatchFileModified(exeRoot, appIdentity);
}
public LocalAppDeploymentConfig(string exeRoot, AppIdentity appIdentity, IEnumerable<string> targetClusters, IReadOnlyDictionary<string, string> properties) : base(appIdentity, targetClusters, properties)
{
ExeRoot = exeRoot;
EntryPointCreatedDate = GetWatchFileModified(exeRoot, appIdentity);
}
static DateTimeOffset? GetWatchFileModified(string exeRoot, AppIdentity identity)
{
var configPath = Path.Combine(exeRoot, "AppConfig.json");
if (File.Exists(configPath))
{
var parser = new ApplicationConfigParser(
new ApplicationConfigSymbolResolver(null, null),
new JsonSerializer(new DiagnosticsTraceWriter()));
// Parse config file and return ExeName
var appConfig = parser.ParseFile(
Path.Combine(exeRoot, "AppConfig.json"),
new Etg.Yams.Install.AppInstallConfig(identity)).Result;
var watchPath = Path.Combine(exeRoot, appConfig.ExeName);
if (File.Exists(watchPath))
return File.GetLastWriteTime(watchPath);
}
// Config file does not exist
return null;
}
}
}