/// <inheritdoc />
        public async Task <string> CreateDeploymentAsync(DeploymentEntity deployment)
        {
            // Handle the potential case of a null value being passed as deployment
            if (deployment == null)
            {
                throw new ArgumentNullException(nameof(deployment), "Parameter deployment must not be null.");
            }

            // Expand potential port ranges in the deployment entity
            var expandedPorts = DeploymentUtils.ExpandPortRanges(deployment.Ports);

            deployment.Ports = expandedPorts;

            // Create a unique identifier for the deployment
            var id                   = Guid.NewGuid().ToString();
            var deploymentPath       = Path.Combine(_storage, $"{id}.yaml");
            var serializedDeployment = _yamlSerializer.Serialize(deployment);

            // Check if the deployment is already existent; should not happen!
            if (File.Exists(deploymentPath))
            {
                return(null);
            }

            // Write out the serialized deployment to a YAML file
            await using (var streamWriter = File.CreateText(deploymentPath))
            {
                await streamWriter.WriteLineAsync(serializedDeployment);
            }

            _logger.LogInformation("Successfully created deployment with id '{Id}'.", id);
            return(id);
        }
Ejemplo n.º 2
0
 private void Setup_Click(object sender, EventArgs e)
 {
     createDesktopShortcuts();
     Setup.Visible = false;
     if (selectedCount == 0)
     {
         try
         {
             DeploymentUtils.UninstallMe(x => { logsBox.Visible = true; logsBox.Text += x + "\r\n"; return(true); });
             label2.Text = "The uninstall is now finished.";
             label1.Text = "Bye.";
         }
         catch (Exception ee)
         {
             label2.Text = "The uninstall failed.";
             label1.Text = ee.Message;
         }
     }
     else
     {
         label2.Text = "The setup is now finished.";
         label1.Text = "Use the shortcuts on your desktop to run the tools.";
     }
     label1.Visible = true;
 }
        /// <inheritdoc />
        public async Task <bool> UpdateDeploymentAsync(DeploymentEntity deployment)
        {
            // Handle the potential case of a null value being passed as deployment
            if (deployment == null)
            {
                throw new ArgumentNullException(nameof(deployment), "Parameter deployment must not be null.");
            }

            // Expand potential port ranges in the deployment entity
            var expandedPorts = DeploymentUtils.ExpandPortRanges(deployment.Ports);

            deployment.Ports = expandedPorts;

            // Arrange information about the specific deployment
            var id = deployment.Id;

            deployment.Id = null;

            var deploymentPath       = Path.Combine(_storage, $"{id}.yaml");
            var serializedDeployment = _yamlSerializer.Serialize(deployment);

            // Check if the specified deployment is found
            if (!File.Exists(deploymentPath))
            {
                _logger.LogWarning("Could not update deployment with id '{Id}'.", id);
                return(false);
            }

            await using (var streamWriter = File.CreateText(deploymentPath))
            {
                await streamWriter.WriteAsync(serializedDeployment);
            }

            _logger.LogInformation("Successfully updated deployment with id '{Id}'.", id);
            return(true);
        }
Ejemplo n.º 4
0
        public void TestGetDeploymentRelativePath()
        {
            AppIdentity appIdentity = new AppIdentity("id", new Version("1.0.0"));

            Assert.AreEqual("id\\1.0.0", DeploymentUtils.GetDeploymentRelativePath(appIdentity));
        }