Ejemplo n.º 1
0
        private static async Task ExecuteAsync(OutputContext output, FileInfo projectFile, List <string> outputs, bool force)
        {
            output.WriteBanner();

            var application = await ApplicationFactory.CreateApplicationAsync(output, projectFile);

            var steps = new List <ServiceExecutor.Step>();

            if (outputs.Count == 0 || outputs.Contains("container"))
            {
                steps.Add(new GenerateDockerfileStep()
                {
                    Force = force,
                });
            }

            if (outputs.Count == 0 || outputs.Contains("chart"))
            {
                steps.Add(new GenerateHelmChartStep());
            }

            var executor = new ServiceExecutor(output, application, steps);

            foreach (var service in application.Services)
            {
                if (service.IsMatchForProject(application, projectFile))
                {
                    await executor.ExecuteAsync(service);
                }
            }
        }
Ejemplo n.º 2
0
        private static async Task ExecuteAsync(OutputContext output, FileInfo projectFile, string environment)
        {
            output.WriteBanner();

            var application = await ApplicationFactory.CreateApplicationAsync(output, projectFile);

            if (application.Globals.Registry?.Hostname == null)
            {
                throw new CommandException("A registry is required for push operations. run 'dotnet-opulence init'.");
            }

            var steps = new ServiceExecutor.Step[]
            {
                new CombineStep()
                {
                    Environment = environment,
                },
                new BuildDockerImageStep()
                {
                    Environment = environment,
                },
                new PushDockerImageStep()
                {
                    Environment = environment,
                },
            };

            var executor = new ServiceExecutor(output, application, steps);

            foreach (var service in application.Services)
            {
                if (service.IsMatchForProject(application, projectFile))
                {
                    await executor.ExecuteAsync(service);
                }
            }
        }
Ejemplo n.º 3
0
        private static async Task ExecuteAsync(OutputContext output, FileInfo projectFile, DirectoryInfo outputDirectory, string environment, bool force)
        {
            output.WriteBanner();

            var application = await ApplicationFactory.CreateApplicationAsync(output, projectFile);

            var steps = new List <ServiceExecutor.Step>
            {
                new CombineStep()
                {
                    Environment = environment,
                },
                new BuildDockerImageStep()
                {
                    Environment = environment,
                },
            };

            if (application.Globals.DeploymentKind == DeploymentKind.None)
            {
                // No extra steps
            }
            else if (application.Globals.DeploymentKind == DeploymentKind.Kubernetes)
            {
                steps.Add(new GenerateKubernetesManifestStep()
                {
                    Environment = environment,
                });
            }
            else if (application.Globals.DeploymentKind == DeploymentKind.Oam)
            {
                steps.Add(new GenerateOamComponentStep()
                {
                    Environment = environment,
                });
            }
            else
            {
                throw new InvalidOperationException($"Unknown DeploymentKind: " + application.Globals.DeploymentKind);
            }

            // If this is command is for a project, then write out the component manifest
            // for just the project. We won't run the "application package" part.
            if (!string.Equals(".sln", projectFile.Extension, StringComparison.Ordinal))
            {
                steps.Add(new WriteServiceYamlStep()
                {
                    OutputDirectory = outputDirectory, Force = force,
                });
            }

            var executor = new ServiceExecutor(output, application, steps);

            foreach (var service in application.Services)
            {
                if (service.IsMatchForProject(application, projectFile))
                {
                    await executor.ExecuteAsync(service);
                }
            }

            if (string.Equals(".sln", projectFile.Extension, StringComparison.Ordinal))
            {
                await PackageApplicationAsync(output, application, outputDirectory, Path.GetFileNameWithoutExtension(projectFile.Name), environment);
            }
        }
Ejemplo n.º 4
0
        private static async Task ExecuteAsync(OutputContext output, FileInfo projectFile, string environment)
        {
            output.WriteBanner();

            var application = await ApplicationFactory.CreateApplicationAsync(output, projectFile);

            if (application.Globals.Registry?.Hostname == null)
            {
                throw new CommandException("A registry is required for deploy operations. run 'dotnet-opulence init'.");
            }

            var steps = new List <ServiceExecutor.Step>()
            {
                new CombineStep()
                {
                    Environment = environment,
                },
                new BuildDockerImageStep()
                {
                    Environment = environment,
                },
                new PushDockerImageStep()
                {
                    Environment = environment,
                },
            };

            if (application.Globals.DeploymentKind == DeploymentKind.None)
            {
                // No extra steps
            }
            else if (application.Globals.DeploymentKind == DeploymentKind.Kubernetes)
            {
                steps.Add(new GenerateKubernetesManifestStep()
                {
                    Environment = environment,
                });
            }
            else if (application.Globals.DeploymentKind == DeploymentKind.Oam)
            {
                steps.Add(new GenerateOamComponentStep()
                {
                    Environment = environment,
                });
            }
            else
            {
                throw new InvalidOperationException($"Unknown DeploymentKind: " + application.Globals.DeploymentKind);
            }

            // If this is command is for a project, then deploy the component manifest
            // for just the project. We won't run the "application deploy" part.
            if (!string.Equals(".sln", projectFile.Extension, StringComparison.Ordinal))
            {
                steps.Add(new DeployServiceYamlStep()
                {
                    Environment = environment,
                });
            }

            var executor = new ServiceExecutor(output, application, steps);

            foreach (var service in application.Services)
            {
                if (service.IsMatchForProject(application, projectFile))
                {
                    await executor.ExecuteAsync(service);
                }
            }

            if (string.Equals(".sln", projectFile.Extension, StringComparison.Ordinal))
            {
                await PackageApplicationAsync(output, application, Path.GetFileNameWithoutExtension(projectFile.Name), environment);
            }
        }