Ejemplo n.º 1
0
        public Solution(string solutionPath)
        {
            DirectoryInfo info = new DirectoryInfo(solutionPath);

            SolutionFile = info.Name;
            Name         = SolutionFile.Replace(".sln", "");
            SolutionPath = info.Parent.FullName;
            CollectProjectsFromSolution();
            CollectFolders();
            CheckProjectFolders();
        }
Ejemplo n.º 2
0
        public override void WriteYaml(StreamWriter writer, AssetManager assetManager, ILoggerFactory loggerFactory, int indent = 0)
        {
            var spaces = "".PadLeft(indent);

            writer.Write($"{spaces}- name: {Name}\n");
            spaces = "".PadLeft(indent + 2);
            writer.Write($"{spaces}type: {ServiceType}\n");
            writer.Write($"{spaces}image:\n");
            spaces = "".PadLeft(indent + 4);
            writer.Write($"{spaces}name: {Image?.Name ?? Name}\n");
            writer.Write($"{spaces}tag: {Image?.Tag ?? "{{.Values.buildNumber}}"}\n");
            spaces = "".PadLeft(indent + 2);
            if (!string.IsNullOrEmpty(SolutionFile))
            {
                writer.Write($"{spaces}solutionFile: {SolutionFile.Replace("\\", "/")}\n");
            }

            if (string.IsNullOrEmpty(ProjectFile) && !string.IsNullOrEmpty(SolutionFile))
            {
                var projName = Name.GetProjectName();
                ProjectFile = Path.Combine(Path.GetDirectoryName(SolutionFile), projName, $"{projName}.csproj");
                if (string.IsNullOrEmpty(AssemblyName))
                {
                    AssemblyName = projName;
                }
            }
            if (!string.IsNullOrEmpty(ProjectFile))
            {
                writer.Write($"{spaces}projectFile: {ProjectFile.Replace("\\", "/")}\n");
            }

            if (!string.IsNullOrEmpty(AssemblyName))
            {
                writer.Write($"{spaces}assemblyName: {AssemblyName}\n");
            }

            if (!string.IsNullOrEmpty(PrivateNugetFeed))
            {
                writer.Write($"{spaces}privateNugetFeed: {PrivateNugetFeed}\n");
            }

            if (ServiceType == "web" || ServiceType == "api")
            {
                writer.Write($"{spaces}containerPort: {ContainerPort}\n");
                writer.Write($"{spaces}sshPort: {SshPort}\n");
                if (string.IsNullOrEmpty(SslCert))
                {
                    var dns = assetManager.Get(AssetType.Dns) as Dns;
                    SslCert = dns?.SslCert;
                }
                if (!string.IsNullOrEmpty(SslCert))
                {
                    writer.Write($"{spaces}sslCert: {SslCert}\n");
                }
                writer.Write($"{spaces}isFrontEnd: {IsFrontend}\n");

                if (!string.IsNullOrEmpty(LivenessCheck))
                {
                    writer.Write($"{spaces}livenessCheck: {LivenessCheck}\n");
                }
                if (!string.IsNullOrEmpty(ReadinessCheck))
                {
                    writer.Write($"{spaces}readinessCheck: {ReadinessCheck}\n");
                }
            }

            if (ServiceType == "job")
            {
                writer.Write($"{spaces}schedule: {Schedule ?? "*/1 * * * *"}\n");
                writer.Write($"{spaces}restartPolicy: {RestartPolicy ?? "Never"}\n");
                writer.Write($"{spaces}concurrencyPolicy: {ConcurrencyPolicy ?? "Forbid"}\n");
            }

            if (Volumes?.Any() == true)
            {
                writer.Write($"{spaces}volumes:\n");
                spaces = "".PadLeft(indent + 4);
                foreach (var volume in Volumes)
                {
                    writer.Write($"{spaces}- name: {volume}\n");
                }
            }
            spaces = "".PadLeft(indent + 4);

            if (EnvironmentVariables?.Any() == true)
            {
                writer.Write($"{spaces}env:\n");
                spaces = "".PadLeft(indent + 4);
                foreach (var envVar in EnvironmentVariables)
                {
                    writer.Write($"{spaces}- name: {envVar.Name}\n");
                    writer.Write($"{spaces}  value: {envVar.Value}\n");
                }
            }
        }