예제 #1
0
        private void MenuItemCallbackK8sDeploy(object sender, EventArgs e)
        {
            try
            {
                var project    = Utils.GetCurrentProject(this.ServiceProvider);
                var projectDir = System.IO.Path.GetDirectoryName(project.FullName);

                var bar = GetStatusBar();
                int frozen;
                bar.IsFrozen(out frozen);

                if (frozen != 0)
                {
                    bar.FreezeOutput(0);
                }

                //object icon = (short)Microsoft.VisualStudio.Shell.Interop.Constants.SBAI_Deploy;
                //bar.Animation(1, ref icon);
                bar.SetText("Deploying Kubernetes Helm Chart...");
                bar.FreezeOutput(1);

                draftCreateRunning = true;

                Kubernetes.DraftUp(projectDir, Process_OutputDataReceived, Process_ErrorDataReceived, (s, e2) => {
                    ThreadHelper.JoinableTaskFactory.Run(async delegate {
                        await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                        try
                        {
                            draftCreateRunning = false;

                            bar.FreezeOutput(0);
                            bar.Clear();
                            //bar.Animation(0, ref icon);
                            var p = (System.Diagnostics.Process)s;
                            if (p.ExitCode != 0)
                            {
                                var message = "draft up failed";
                                Utils.WriteToOutputWindow(this.ServiceProvider, message);
                                throw new Exception(message);
                            }
                        }
                        catch (Exception ex)
                        {
                            Utils.ShowWarningMessageBox(this.ServiceProvider, ex.Message);
                        }
                    });
                });
            }
            catch (Exception ex)
            {
                Utils.ShowWarningMessageBox(this.ServiceProvider, ex.Message);
            }
        }
예제 #2
0
        private void MenuItemCallbackK8sAddSupport(object sender, EventArgs e)
        {
            try
            {
                var project    = Utils.GetCurrentProject(this.ServiceProvider);
                var projectDir = System.IO.Path.GetDirectoryName(project.FullName);

                var    projectKindGuid = new Guid(project.Kind);
                string packName        = null;
                if (!vsProjectTypeToPackNameMap.TryGetValue(new Guid(project.Kind), out packName))
                {
                    throw new Exception("Unsupported project type. Only ASP.NET Core and Node.js projects are currently supported for now, more will be added soon!");
                }

                draftUpRunning = true;

                Kubernetes.DraftCreate(projectDir, packName, Process_OutputDataReceived, Process_ErrorDataReceived, (s, e2) => {
                    ThreadHelper.JoinableTaskFactory.Run(async delegate {
                        await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                        try
                        {
                            draftUpRunning = false;

                            var p = (System.Diagnostics.Process)s;
                            if (p.ExitCode != 0)
                            {
                                var message = "draft create failed";
                                Utils.WriteToOutputWindow(this.ServiceProvider, message);
                                throw new Exception(message);
                            }
                            else
                            {
                                Kubernetes.DisableDraftWatch(projectDir);
                                var paths = new List <string>();
                                foreach (var name in new[] { "Dockerfile", "draft.toml", ".draftignore", "chart" })
                                {
                                    paths.Add(System.IO.Path.Combine(projectDir, name));
                                }
                                Utils.AddItemsToProject(project.ProjectItems, paths);
                            }
                        }
                        catch (Exception ex)
                        {
                            Utils.ShowWarningMessageBox(this.ServiceProvider, ex.Message);
                        }
                    });
                });
            }
            catch (Exception ex)
            {
                Utils.ShowWarningMessageBox(this.ServiceProvider, ex.Message);
            }
        }
예제 #3
0
        private void MenuItemCallbackK8sMinikubeDeploy(object sender, EventArgs e)
        {
            var bar = GetStatusBar();
            int frozen;

            bar.IsFrozen(out frozen);

            if (frozen != 0)
            {
                bar.FreezeOutput(0);
            }
            bar.SetText("Deploying Minikube...");
            bar.FreezeOutput(1);

            minikubeDeploymentRunning = true;

            Kubernetes.DeployMinikube(Process_OutputDataReceived, Process_ErrorDataReceived, (s, e2) => {
                ThreadHelper.JoinableTaskFactory.Run(async delegate {
                    await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                    try
                    {
                        minikubeDeploymentRunning = false;

                        bar.FreezeOutput(0);
                        bar.Clear();

                        var p = (System.Diagnostics.Process)s;
                        if (p.ExitCode != 0)
                        {
                            throw new Exception("Minikube deployment failed");
                        }
                    }
                    catch (Exception ex)
                    {
                        Utils.ShowWarningMessageBox(this.ServiceProvider, ex.Message);
                    }
                });
            });
        }