Exemplo n.º 1
0
        private static List <IPlatform> GetPlatforms(XmlDocument xmlDoc, XmlNode defaultsNode)
        {
            var platforms = new List <IPlatform>();

            try
            {
                XmlNode node = xmlDoc.FirstChild;

                while (node != null)
                {
                    if (node.NodeType == XmlNodeType.Element)
                    {
                        XmlNode   platformNode = xmlDoc.FirstChild.SelectSingleNode("platform");
                        IPlatform platform     = PlatformFactory.CreatePlatform(platformNode, defaultsNode);
                        platforms.Add(platform);
                    }

                    node = node.NextSibling;
                }
            }
            catch (Exception e)
            {
                Log.WriteError("\n{0}\n", e.Message);
                throw;
            }

            return(platforms);
        }
 private void PlatformCombo_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     _vm.SelectedPlatform           = ((ComboBox)sender).SelectedIndex;
     Helpers.Globals.ActivePlatform = PlatformFactory.CreatePlatform((PlatformTypes)_vm.SelectedPlatform);
     if (_vm.ActivePicture != null)
     {
         _vm.ReloadActivePicture();
         _vm.UpdatePaletteCommand.Execute(_vm.ActivePaletteString);
     }
 }
        public override async Task RunAsync()
        {
            if (!string.IsNullOrEmpty(FolderName))
            {
                var folderPath = Path.Combine(Environment.CurrentDirectory, FolderName);
                FileSystemHelpers.EnsureDirectory(folderPath);
                Environment.CurrentDirectory = folderPath;
            }

            if (!Platforms.Contains(Platform))
            {
                ColoredConsole.Error.WriteLine(ErrorColor($"platform {Platform} is not supported. Valid options are: {String.Join(",", Platforms)}"));
                return;
            }

            if (!CommandChecker.CommandExists("kubectl"))
            {
                ColoredConsole.Error.WriteLine(ErrorColor($"kubectl is required for deploying to kubernetes. Please make sure to install kubectl and try again."));
                return;
            }

            var dockerFilePath = Path.Combine(Environment.CurrentDirectory, "Dockerfile");

            if (!FileSystemHelpers.FileExists(dockerFilePath))
            {
                ColoredConsole.Error.WriteLine(ErrorColor($"Dockerfile not found in directory {Environment.CurrentDirectory}"));
                return;
            }

            var image = $"{Registry}/{Name.SanitizeImageName()}";

            ColoredConsole.WriteLine("Building Docker image...");
            await DockerHelpers.DockerBuild(image, Environment.CurrentDirectory);

            ColoredConsole.WriteLine("Pushing function image to registry...");
            await DockerHelpers.DockerPush(image);

            var platform = PlatformFactory.CreatePlatform(Platform, ConfigPath);

            if (platform == null)
            {
                ColoredConsole.Error.WriteLine(ErrorColor($"Platform {Platform} is not supported"));
                return;
            }

            await platform.DeployContainerizedFunction(Name, image, MinInstances, MaxInstances);
        }