Пример #1
0
 public Task <DeploymentManifestInfo> GetDeploymentManifestInfo(DeploymentManifest manifest)
 {
     return(manifest switch
     {
         HelmDeploymentManifest helmDeploymentManifest => GetDeploymentManifestInfo(helmDeploymentManifest),
         RawDeploymentManifest rawDeploymentManifest => GetDeploymentManifestInfo(rawDeploymentManifest),
         _ => throw new ArgumentOutOfRangeException(nameof(manifest))
     });
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         DeploymentManifest = Program.ValidateUpdateUri(null, textBox1.Text);
         DialogResult = DialogResult.OK;
     }
     catch
     {
         MessageBox.Show("A valid deployment manifest could not be found at the location provided, or you did not have access to the manifest.");
     }
 }
Пример #3
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         DeploymentManifest = Program.ValidateUpdateUri(null, textBox1.Text);
         DialogResult       = DialogResult.OK;
     }
     catch
     {
         MessageBox.Show("A valid deployment manifest could not be found at the location provided, or you did not have access to the manifest.");
     }
 }
Пример #4
0
        private void tsmiFileOpenDepManFromURL_Click(object sender, EventArgs e)
        {
            LoadFromURIForm loadFromURI = new LoadFromURIForm();

            if (loadFromURI.ShowDialog() == DialogResult.OK)
            {
                DeploymentManifest = loadFromURI.DeploymentManifest;
                AddToRecentManifests(DeploymentManifest.Uri.AbsoluteUri);

                LoadRecentManifestList();
            }
        }
        public IScript[] Get(DeploymentManifest deploymentManifest)
        {
            List <IScript> scripts = new List <IScript>();

            if (deploymentManifest != null &&
                deploymentManifest.Deployment != null &&
                deploymentManifest.Deployment.DeploymentProvider != null &&
                deploymentManifest.AssemblyIdentity != null)
            {
                // Remove the filename from the deployment provider codebase
                Uri           uri      = new Uri(deploymentManifest.Deployment.DeploymentProvider.CodeBase);
                List <string> segments = new List <string>(uri.Segments);
                segments.RemoveAt(segments.Count - 1);

                // Add the version folder
                string path = Path.Combine(
                    string.Join("", segments.ToArray()),
                    VersionFolder);

                // Determine what the version folder will be named
                string folderName = Path.GetFileNameWithoutExtension(deploymentManifest.AssemblyIdentity.Name);
                folderName += "_" + deploymentManifest.AssemblyIdentity.Version.ToString().Replace('.', '_');

                // Combine the path with the version
                path = Path.Combine(path, folderName);

                // Add the script manifest filename to the path
                path = Path.Combine(path, ScriptManifestFilename);

                // Build a new Uri with the path
                UriBuilder uriBuilder = new UriBuilder(
                    uri.Scheme,
                    uri.Host,
                    uri.Port,
                    path);

                // FIXME: load the scripts from the script manifest
                // FIXME: should we even bother with a script manifest?
                // We could load the scripts straight out of the deployment.
                // This could be a problem, however, if we wanted to run
                // scripts *before* the new version was downloaded.
                GC.KeepAlive(uriBuilder);
            }

            return(scripts.ToArray());
        }
        public IScript[] Get(DeploymentManifest deploymentManifest)
        {
            List<IScript> scripts = new List<IScript>();

            if (deploymentManifest != null &&
                deploymentManifest.Deployment != null &&
                deploymentManifest.Deployment.DeploymentProvider != null &&
                deploymentManifest.AssemblyIdentity != null)
            {
                // Remove the filename from the deployment provider codebase
                Uri uri = new Uri(deploymentManifest.Deployment.DeploymentProvider.CodeBase);
                List<string> segments = new List<string>(uri.Segments);
                segments.RemoveAt(segments.Count - 1);
                
                // Add the version folder
                string path = Path.Combine(
                    string.Join("", segments.ToArray()),
                    VersionFolder);
                
                // Determine what the version folder will be named
                string folderName = Path.GetFileNameWithoutExtension(deploymentManifest.AssemblyIdentity.Name);
                folderName += "_" + deploymentManifest.AssemblyIdentity.Version.ToString().Replace('.', '_');

                // Combine the path with the version
                path = Path.Combine(path, folderName);

                // Add the script manifest filename to the path
                path = Path.Combine(path, ScriptManifestFilename);

                // Build a new Uri with the path
                UriBuilder uriBuilder = new UriBuilder(
                    uri.Scheme,
                    uri.Host,
                    uri.Port,
                    path);

                // FIXME: load the scripts from the script manifest
                // FIXME: should we even bother with a script manifest?
                // We could load the scripts straight out of the deployment.
                // This could be a problem, however, if we wanted to run
                // scripts *before* the new version was downloaded.
                GC.KeepAlive(uriBuilder);
            }

            return scripts.ToArray();
        }
Пример #7
0
        void tsmiRecentItem_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem tsmi = sender as ToolStripMenuItem;

            if (tsmi != null)
            {
                try
                {
                    DeploymentManifest = Program.ValidateUpdateUri(null, tsmi.Text);
                    DialogResult       = DialogResult.OK;
                }
                catch
                {
                    MessageBox.Show("A valid deployment manifest could not be found at the location provided, or you did not have access to the manifest.");
                }
            }
        }
Пример #8
0
        public void TestDeploymentManifestFromUrl()
        {
            DeploymentManifest dm1 = new DeploymentManifest();

            dm1.LoadFromFile(DeploymentManifestFilePath);

            DeploymentManifest dm2 = new DeploymentManifest();

            dm2.LoadFromUrl(DeploymentManifestURL);

            // Validate
            for (int i = 0; i < dm1.Files.Count; i++)
            {
                //Assert.AreEqual(dm1.Files[i].FileName, dm2.Files[i].FileName);
                //Assert.AreEqual(dm1.Files[i].HashValue, dm2.Files[i].HashValue);
                //Assert.AreEqual(dm1.Files[i].Version, dm2.Files[i].Version);
            }
            // Didn't fix this, but not working because manifest now contains remote file location information
        }
Пример #9
0
        public void TestBuildDeploymentManifest()
        {
            DeploymentManifest dm1 = new DeploymentManifest();

            // Add files here
            dm1.Files.Add(DeploymentFile.CreateFromFile(@"D:\TS\C-DentalClaimTracker\bin\Release\DentalClaimTracker.exe",
                                                        @"D:\TS\C-DentalClaimTracker\bin\Release Deployment\DentalClaimTracker.exe"));

            dm1.Save(DeploymentManifestFilePath);

            DeploymentManifest dm2 = new DeploymentManifest();

            dm2.LoadFromFile(DeploymentManifestFilePath);

            // Validate
            for (int i = 0; i < dm1.Files.Count; i++)
            {
                Assert.AreEqual(dm1.Files[i].FileName, dm2.Files[i].FileName);
                Assert.AreEqual(dm1.Files[i].HashValue, dm2.Files[i].HashValue);
                Assert.AreEqual(dm1.Files[i].Version, dm2.Files[i].Version);
            }
        }
Пример #10
0
        /// <summary>
        /// Gets the absolute path to the deployment configuration under the deployment root
        /// </summary>
        public static AbsolutePath GetDeploymentConfigurationPath(AbsolutePath deploymentRoot, DeploymentManifest manifest)
        {
            var configDropLayout = manifest.Drops[ConfigDropUri.OriginalString];
            var configFileSpec   = configDropLayout[DeploymentConfigurationFileName];

            return(deploymentRoot / GetContentRelativePath(new ContentHash(configFileSpec.Hash)));
        }
Пример #11
0
        internal static ApplicationDto ConvertApplicationToDto(Application application, DeploymentManifest applicationSource)
        {
            var applicationImages = application.Images
                                    .Select(
                image => ConvertApplicationImageToApplicationServiceDto(image)
                )
                                    .ToList();

            var dto = new ApplicationDto()
            {
                Name = application.Name,
                DeploymentManifestSource = applicationSource != null
                    ? new GetRepositorySourceDto()
                {
                    Path = applicationSource.Path,
                    Ref  = applicationSource.Repository.Ref,
                    Uri  = applicationSource.Repository.Uri.ToString()
                }
                    : new GetRepositorySourceDto(),
                Services = applicationImages,
            };

            return(dto);
        }
Пример #12
0
 static public DeploymentManifest ValidateUpdateUri(DeploymentManifest dp, string updateUri)
 {
     return ValidateUpdateUri(dp, updateUri, null, null, null);
 }
Пример #13
0
        static public DeploymentManifest ValidateUpdateUri(
            DeploymentManifest dp,
            string updateUri,
            string username,
            string password,
            string domain)
        {
            DeploymentManifest deploymentManifest = null;

            try
            {
                deploymentManifest = new DeploymentManifest(new Uri(updateUri), username, password, domain);
                if (deploymentManifest == null)
                {
                    throw new Exception("A deployment manifest could not be found at the URI provided.");
                }
            }
            catch (WebException ex)
            {
                if (string.IsNullOrEmpty(username) &&
                    string.IsNullOrEmpty(password))
                {
                    // No username/password were provided,
                    // let's see if this was an "Unauthorized" message.
                    HttpWebResponse response = ex.Response as HttpWebResponse;
                    if (response != null &&
                        response.StatusCode == HttpStatusCode.Unauthorized)
                    {
                        // Gather credentials and try again.
                        CredentialsForm cf = new CredentialsForm();
                        if (cf.ShowDialog() == DialogResult.OK)
                        {
                            deploymentManifest = ValidateUpdateUri(dp, updateUri, cf.Username, cf.Password, cf.Domain);
                        }
                    }
                }
                else
                {
                    throw ex;
                }
            }
            catch (Exception ex)
            {
                if (dp != null)
                {
                    // Append the deployment manifest name to the end of the
                    // update uri, if it isn't already provided
                    if (!updateUri.Trim().EndsWith(dp.AssemblyIdentity.Name, true, CultureInfo.CurrentCulture))
                    {
                        UriBuilder uriBuilder = new UriBuilder(updateUri);
                        uriBuilder.Path    = Path.Combine(uriBuilder.Path, dp.AssemblyIdentity.Name);
                        deploymentManifest = ValidateUpdateUri(dp, uriBuilder.Uri.AbsoluteUri, username, password, domain);

                        if (deploymentManifest == null)
                        {
                            throw ex;
                        }
                    }
                }
                else
                {
                    throw ex;
                }
            }

            if (deploymentManifest != null)
            {
                // Load the application manifest
                deploymentManifest.LoadApplicationManifest();
            }

            return(deploymentManifest);
        }
Пример #14
0
 static public DeploymentManifest ValidateUpdateUri(DeploymentManifest dp, string updateUri)
 {
     return(ValidateUpdateUri(dp, updateUri, null, null, null));
 }
Пример #15
0
        /// <summary>
        /// Gets the file spec for the deployment configuration file
        /// </summary>
        public static FileSpec GetDeploymentConfigurationSpec(this DeploymentManifest manifest)
        {
            var configDropLayout = manifest.Drops[ConfigDropUri.OriginalString];

            return(configDropLayout[DeploymentConfigurationFileName]);
        }
Пример #16
0
        private void btnCreateBootstrap_Click(object sender, EventArgs e)
        {            
            if (cbUpdateNotifier.SelectedIndex < 0)
            {
                MessageBox.Show("Please select an Update Notifier.", "Choose an Update Notifier");
            }
            else if (string.IsNullOrEmpty(txtUpdateURI.Text))
            {
                MessageBox.Show("Please select an Update URI", "Choose an Update URI");
            }
            else if (
                string.IsNullOrEmpty(txtDestinationFolder.Text) ||
                !Directory.Exists(txtDestinationFolder.Text))
            {
                MessageBox.Show("Please choose a valid destination folder", "Choose a destination folder");
            }
            else
            {
                try
                {
                    Program.ValidateUpdateUri(DeploymentManifest, txtUpdateURI.Text);
                }
                catch
                {
                    if (MessageBox.Show("The Update URI does not successfully validate; are you sure you want to create a bootstrap?", "Are you sure?", MessageBoxButtons.YesNo) != DialogResult.Yes)
                        return;
                }

                if (rbManualConfig.Checked &&
                (
                    string.IsNullOrEmpty(txtMainExec.Text) ||
                    !File.Exists(txtMainExec.Text)
                ))
                {
                    if (MessageBox.Show(@"You have not provided a main executable for your application.
It is recommended that you provide a main executable for the
bootstrap to mimic, so the bootstrap looks as much like your
application as possible.

Are you sure you want to continue?", "Are you sure?", MessageBoxButtons.YesNo) != DialogResult.Yes)
                        return;
                }

                // Ensure we have a deployment manifest
                if (DeploymentManifest != null)
                {
                    // Make sure the application manifest is loaded
                    DeploymentManifest.LoadApplicationManifest();

                    if (DeploymentManifest.ApplicationManifest != null)
                    {
                        // Get the assembly identity for the application manifest
                        string targetFilename = DeploymentManifest.ApplicationManifest.AssemblyIdentity.Name;

                        // Copy the bootstrap assembly to the target filename
                        CopyAssemblies(targetFilename, txtDestinationFolder.Text);

                        string targetPath = Path.Combine(
                            txtDestinationFolder.Text,
                            targetFilename);

                        // Write the configuration values to the application config file
                        WriteConfigurationValues(targetPath);

                        MessageBox.Show("Bootstrap successfully written!", "Success");

                        // Open the folder after success
                        Process openFolder = new Process();
                        openFolder.StartInfo = new ProcessStartInfo(txtDestinationFolder.Text);
                        openFolder.Start();

                        DeploymentManifest = null;
                        return;
                    }
                }

                MessageBox.Show("An error occurred while creating the bootstrap.", "Failure");
            }            
        }
Пример #17
0
 void tsmiRecentItem_Click(object sender, EventArgs e)
 {
     ToolStripMenuItem tsmi = sender as ToolStripMenuItem;
     if (tsmi != null)
     {
         try
         {
             DeploymentManifest = Program.ValidateUpdateUri(null, tsmi.Text);
             DialogResult = DialogResult.OK;
         }                
         catch
         {
             MessageBox.Show("A valid deployment manifest could not be found at the location provided, or you did not have access to the manifest.");
         }
     }
 }
Пример #18
0
        private void tsmiFileOpenDepManFromURL_Click(object sender, EventArgs e)
        {
            LoadFromURIForm loadFromURI = new LoadFromURIForm();
            if (loadFromURI.ShowDialog() == DialogResult.OK)
            {
                DeploymentManifest = loadFromURI.DeploymentManifest;
                AddToRecentManifests(DeploymentManifest.Uri.AbsoluteUri);

                LoadRecentManifestList();
            }
        }
        public ConfirmDoUpdateForm(DeploymentManifest manifest)
        {
            InitializeComponent();

            DeploymentManifest = manifest;            
        }
Пример #20
0
        static public DeploymentManifest ValidateUpdateUri(
            DeploymentManifest dp,
            string updateUri,
            string username,
            string password,
            string domain)
        {
            DeploymentManifest deploymentManifest = null;

            try
            {
                deploymentManifest = new DeploymentManifest(new Uri(updateUri), username, password, domain);
                if (deploymentManifest == null)
                    throw new Exception("A deployment manifest could not be found at the URI provided.");
            }
            catch (WebException ex)
            {
                if (string.IsNullOrEmpty(username) &&
                    string.IsNullOrEmpty(password))
                {
                    // No username/password were provided,
                    // let's see if this was an "Unauthorized" message.
                    HttpWebResponse response = ex.Response as HttpWebResponse;
                    if (response != null &&
                        response.StatusCode == HttpStatusCode.Unauthorized)
                    {
                        // Gather credentials and try again.
                        CredentialsForm cf = new CredentialsForm();
                        if (cf.ShowDialog() == DialogResult.OK)
                            deploymentManifest = ValidateUpdateUri(dp, updateUri, cf.Username, cf.Password, cf.Domain);
                    }
                }
                else throw ex;
            }
            catch (Exception ex)
            {
                if (dp != null)
                {
                    // Append the deployment manifest name to the end of the
                    // update uri, if it isn't already provided
                    if (!updateUri.Trim().EndsWith(dp.AssemblyIdentity.Name, true, CultureInfo.CurrentCulture))
                    {
                        UriBuilder uriBuilder = new UriBuilder(updateUri);
                        uriBuilder.Path = Path.Combine(uriBuilder.Path, dp.AssemblyIdentity.Name);
                        deploymentManifest = ValidateUpdateUri(dp, uriBuilder.Uri.AbsoluteUri, username, password, domain);                        

                        if (deploymentManifest == null)
                            throw ex;
                    }
                }
                else throw ex;
            }

            if (deploymentManifest != null)
            {
                // Load the application manifest
                deploymentManifest.LoadApplicationManifest();
            }

            return deploymentManifest;
        }
Пример #21
0
 public DeploymentManifestSourceTrackingContext(string applicationName, DeploymentManifest deploymentManifest)
 {
     ApplicationName    = applicationName;
     DeploymentManifest = deploymentManifest;
     GitSyncJobId       = $"{ApplicationName}-gitsync-job";
 }
 public void BeginUpdate(DeploymentManifest manifest)
 {
     DeploymentManifest = manifest;
 }
Пример #23
0
        private void btnCreateBootstrap_Click(object sender, EventArgs e)
        {
            if (cbUpdateNotifier.SelectedIndex < 0)
            {
                MessageBox.Show("Please select an Update Notifier.", "Choose an Update Notifier");
            }
            else if (string.IsNullOrEmpty(txtUpdateURI.Text))
            {
                MessageBox.Show("Please select an Update URI", "Choose an Update URI");
            }
            else if (
                string.IsNullOrEmpty(txtDestinationFolder.Text) ||
                !Directory.Exists(txtDestinationFolder.Text))
            {
                MessageBox.Show("Please choose a valid destination folder", "Choose a destination folder");
            }
            else
            {
                try
                {
                    Program.ValidateUpdateUri(DeploymentManifest, txtUpdateURI.Text);
                }
                catch
                {
                    if (MessageBox.Show("The Update URI does not successfully validate; are you sure you want to create a bootstrap?", "Are you sure?", MessageBoxButtons.YesNo) != DialogResult.Yes)
                    {
                        return;
                    }
                }

                if (rbManualConfig.Checked &&
                    (
                        string.IsNullOrEmpty(txtMainExec.Text) ||
                        !File.Exists(txtMainExec.Text)
                    ))
                {
                    if (MessageBox.Show(@"You have not provided a main executable for your application.
It is recommended that you provide a main executable for the
bootstrap to mimic, so the bootstrap looks as much like your
application as possible.

Are you sure you want to continue?", "Are you sure?", MessageBoxButtons.YesNo) != DialogResult.Yes)
                    {
                        return;
                    }
                }

                // Ensure we have a deployment manifest
                if (DeploymentManifest != null)
                {
                    // Make sure the application manifest is loaded
                    DeploymentManifest.LoadApplicationManifest();

                    if (DeploymentManifest.ApplicationManifest != null)
                    {
                        // Get the assembly identity for the application manifest
                        string targetFilename = DeploymentManifest.ApplicationManifest.AssemblyIdentity.Name;

                        // Copy the bootstrap assembly to the target filename
                        CopyAssemblies(targetFilename, txtDestinationFolder.Text);

                        string targetPath = Path.Combine(
                            txtDestinationFolder.Text,
                            targetFilename);

                        // Write the configuration values to the application config file
                        WriteConfigurationValues(targetPath);

                        MessageBox.Show("Bootstrap successfully written!", "Success");

                        // Open the folder after success
                        Process openFolder = new Process();
                        openFolder.StartInfo = new ProcessStartInfo(txtDestinationFolder.Text);
                        openFolder.Start();

                        DeploymentManifest = null;
                        return;
                    }
                }

                MessageBox.Show("An error occurred while creating the bootstrap.", "Failure");
            }
        }
Пример #24
0
        /// <summary>
        /// Gets the absolute path to the deployment configuration under the deployment root
        /// </summary>
        public static AbsolutePath GetDeploymentConfigurationPath(AbsolutePath deploymentRoot, DeploymentManifest manifest)
        {
            var configFileSpec = manifest.GetDeploymentConfigurationSpec();

            return(deploymentRoot / GetContentRelativePath(new ContentHash(configFileSpec.Hash)));
        }
        public ConfirmDoUpdateWindow(DeploymentManifest deploymentManifest)
        {
            DeploymentManifest = deploymentManifest;

            this.InitializeComponent();
        }
Пример #26
0
 public void BeginUpdate(DeploymentManifest manifest)
 {
     DeploymentManifest = manifest;
 }
Пример #27
0
        public ConfirmDoUpdateForm(DeploymentManifest manifest)
        {
            InitializeComponent();

            DeploymentManifest = manifest;
        }