blob: d55b3da9aba2833805ca3c68411f2c36f9ddf1be (
plain) (
blame)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
// Copyright Epic Games, Inc. All Rights Reserved.
#include <zennomad/nomadconfig.h>
namespace zen::nomad {
bool
NomadConfig::Validate() const
{
if (ServerUrl.empty())
{
return false;
}
if (BinDistribution == BinaryDistribution::PreDeployed && BinaryPath.empty())
{
return false;
}
if (BinDistribution == BinaryDistribution::Artifact && ArtifactSource.empty())
{
return false;
}
if (TaskDriver == Driver::Docker && DockerImage.empty())
{
return false;
}
return true;
}
const char*
ToString(Driver D)
{
switch (D)
{
case Driver::RawExec:
return "raw_exec";
case Driver::Docker:
return "docker";
}
return "raw_exec";
}
const char*
ToString(BinaryDistribution Dist)
{
switch (Dist)
{
case BinaryDistribution::PreDeployed:
return "predeployed";
case BinaryDistribution::Artifact:
return "artifact";
}
return "predeployed";
}
bool
FromString(Driver& OutDriver, std::string_view Str)
{
if (Str == "raw_exec")
{
OutDriver = Driver::RawExec;
return true;
}
if (Str == "docker")
{
OutDriver = Driver::Docker;
return true;
}
return false;
}
bool
FromString(BinaryDistribution& OutDist, std::string_view Str)
{
if (Str == "predeployed")
{
OutDist = BinaryDistribution::PreDeployed;
return true;
}
if (Str == "artifact")
{
OutDist = BinaryDistribution::Artifact;
return true;
}
return false;
}
} // namespace zen::nomad
|