Skip to content

Commit 3edd6c5

Browse files
authored
Merge pull request #542 from serverlessworkflow/feat-file-based-operator-host-config
Added the ability to configure an Operator's Docker host using a YAML file
2 parents a5c9b99 + f684707 commit 3edd6c5

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/core/Synapse.Core/Resources/DockerRuntimeConfiguration.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public DockerRuntimeConfiguration()
8484
/// Gets/sets the configuration of the host to use when running runner containers
8585
/// </summary>
8686
[DataMember(Order = 5, Name = "hostConfig"), JsonPropertyOrder(5), JsonPropertyName("hostConfig"), YamlMember(Order = 5, Alias = "hostConfig")]
87-
public virtual HostConfig? HostConfig { get; set; }
87+
public virtual HostConfig? HostConfig { get; set; } = LoadHostConfig();
8888

8989
/// <summary>
9090
/// Gets/sets the path to the directory that contains the secrets to mount in runner containers on a per workflow configuration basis
@@ -110,4 +110,16 @@ public static Config LoadContainerTemplate()
110110
return YamlSerializer.Default.Deserialize<Config>(yaml)!;
111111
}
112112

113+
/// <summary>
114+
/// Loads the host configuration to use when running runner containers
115+
/// </summary>
116+
/// <returns>The host configuration to use when running runner containers, or <c>null</c> if no host configuration is defined</returns>
117+
public static HostConfig? LoadHostConfig()
118+
{
119+
var hostConfigFilePath = Environment.GetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Runtime.Docker.Host);
120+
if (string.IsNullOrWhiteSpace(hostConfigFilePath) || !File.Exists(hostConfigFilePath)) return null;
121+
var yaml = File.ReadAllText(hostConfigFilePath);
122+
return YamlSerializer.Default.Deserialize<HostConfig>(yaml);
123+
}
124+
113125
}

src/core/Synapse.Core/SynapseDefaults.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,10 @@ public static class Docker
730730
/// </summary>
731731
public const string Container = Prefix + "CONTAINER";
732732
/// <summary>
733+
/// Gets the environment variable used to specify the YAML file used to configure the Docker runner host
734+
/// </summary>
735+
public const string Host = Prefix + "HOST";
736+
/// <summary>
733737
/// Gets the environment variable used to configure the network runner containers should be connected to
734738
/// </summary>
735739
public const string Network = Prefix + "NETWORK";

0 commit comments

Comments
 (0)