private static List <Secret> LoadSecrets(DotRunConfig cfg) { if (!File.Exists(cfg.SecretsFile)) { return(new List <Secret>()); } var secrets = YamlHelper.Deserialize <SecretsInfo>(File.ReadAllText(cfg.SecretsFile)); return(secrets.Secrets); }
public static DotRunConfig FromFile(string configFilePath, string configDirectory) { if (!string.IsNullOrEmpty(configFilePath)) { configFilePath = DirectoryHelper.GetAbsoluteLocalPath(configFilePath); } if (!string.IsNullOrEmpty(configDirectory)) { configDirectory = DirectoryHelper.GetAbsoluteLocalPath(configDirectory); } string content = ""; if (File.Exists(configFilePath)) { content = File.ReadAllText(configFilePath); } var cfg = YamlHelper.Deserialize <DotRunConfig>(content); if (cfg == null) { cfg = new DotRunConfig(); } cfg.ConfigDirectory = new DirectoryInfo(configDirectory).FullName; cfg.ConfigFile = configFilePath; cfg.Content = content; if (string.IsNullOrEmpty(cfg.ProjectsRootDirectory)) { cfg.ProjectsRootDirectory = cfg.ConfigDirectory; } return(cfg); }
public static Workflow FromString(Project project, string content, string workflowFilePath) { var wf = YamlHelper.Deserialize <Workflow>(content); if (wf.Kind?.ToLower() != "workflow") { return(null); } wf.Project = project; wf.WorkflowFilePath = workflowFilePath; if (string.IsNullOrEmpty(wf.Name)) { wf.Name = Path.GetFileNameWithoutExtension(workflowFilePath); } foreach (var entry in wf.JobsDict) { entry.Value.Name = entry.Key; entry.Value.Init(); } if (!wf.NodesDict.ContainsKey("local")) { wf.NodesDict.Add("local", new NodeModel { Type = NodeType.Local }); } foreach (var entry in wf.NodesDict) { entry.Value.Name = entry.Key; } return(wf); }