public DeploymentConfig RemoveApplication(AppIdentity appIdentity, string deploymentId) { string appId = appIdentity.Id; string version = appIdentity.Version.ToString(); var apps = GetAppsCopy(); if (!apps.ContainsKey(appId)) { throw new InvalidOperationException($"Cannot remove deployment because app {appId} was not found"); } AppDeploymentConfig appDeploymentConfig = apps[appId]; if (!appDeploymentConfig.Versions.ContainsKey(version)) { throw new InvalidOperationException( $"Cannot remove deployment because app {appId}, version {version} was not found"); } VersionDeploymentConfig versionDeploymentConfig = appDeploymentConfig.Versions[version]; if (!versionDeploymentConfig.DeploymentIds.Contains(deploymentId)) { throw new InvalidOperationException( $"Cannot remove deployment {deploymentId} from app {appId}, version {version} because it was not found"); } versionDeploymentConfig = versionDeploymentConfig.RemoveDeployment(deploymentId); appDeploymentConfig = appDeploymentConfig.SetVersionConfig(versionDeploymentConfig); apps[appId] = appDeploymentConfig; DeploymentConfig dc = new DeploymentConfig(apps); if (!dc._apps[appId].Versions[version].DeploymentIds.Any()) { dc = dc.RemoveApplication(appIdentity); } return(dc); }
public string Serialize(DeploymentConfig deploymentConfig) { var applicationsList = new List<ApplicationData>(); foreach (AppDeploymentConfig appDeploymentConfig in deploymentConfig) { applicationsList.Add(new ApplicationData(appDeploymentConfig.AppIdentity.Id, appDeploymentConfig.AppIdentity.Version.ToString(), appDeploymentConfig.TargetClusters.ToArray(), appDeploymentConfig.Properties.ToDictionary(kvp => kvp.Key, kvp => kvp.Value))); } ApplicationsData applicationsData = new ApplicationsData(applicationsList.ToArray()); return _jsonSerializer.Serialize(applicationsData); }
public string Serialize(DeploymentConfig deploymentConfig) { var applicationsList = new List <ApplicationData>(); foreach (AppDeploymentConfig appDeploymentConfig in deploymentConfig) { applicationsList.Add(new ApplicationData(appDeploymentConfig.AppIdentity.Id, appDeploymentConfig.AppIdentity.Version.ToString(), appDeploymentConfig.TargetClusters.ToArray(), appDeploymentConfig.Properties.ToDictionary(kvp => kvp.Key, kvp => kvp.Value))); } ApplicationsData applicationsData = new ApplicationsData(applicationsList.ToArray()); return(_jsonSerializer.Serialize(applicationsData)); }
public DeploymentConfig AddApplication(AppIdentity appIdentity, string clusterId) { AppDeploymentConfig appDeploymentConfig; DeploymentConfig deploymentConfig = this; if (deploymentConfig.HasApplication(appIdentity)) { appDeploymentConfig = deploymentConfig.GetApplicationConfig(appIdentity); appDeploymentConfig = appDeploymentConfig.AddClusterId(clusterId); deploymentConfig = RemoveApplication(appIdentity); } else { appDeploymentConfig = new AppDeploymentConfig(appIdentity, new [] { clusterId }); } return(deploymentConfig.SetApplicationConfig(appDeploymentConfig)); }
public DeploymentConfig Deserialize(string data) { DeploymentConfig deploymentConfig = new DeploymentConfig(); Dictionary<string, AppDeploymentConfig> apps = new Dictionary<string, AppDeploymentConfig>(); if (string.IsNullOrEmpty(data)) { return deploymentConfig; } var appDeploymentConfigs = new List<AppDeploymentConfig>(); ApplicationsData appsData = _jsonSerializer.Deserialize<ApplicationsData>(data); foreach (ApplicationData appData in appsData.Applications) { AppIdentity appIdentity = new AppIdentity(appData.Id, appData.Version); AppDeploymentConfig appDeploymentConfig = new AppDeploymentConfig(appIdentity, appData.TargetClusters, appData.Properties); appDeploymentConfigs.Add(appDeploymentConfig); } return new DeploymentConfig(appDeploymentConfigs); }
public DeploymentConfig Deserialize(string data) { DeploymentConfig deploymentConfig = new DeploymentConfig(); Dictionary <string, AppDeploymentConfig> apps = new Dictionary <string, AppDeploymentConfig>(); if (string.IsNullOrEmpty(data)) { return(deploymentConfig); } var appDeploymentConfigs = new List <AppDeploymentConfig>(); ApplicationsData appsData = _jsonSerializer.Deserialize <ApplicationsData>(data); foreach (ApplicationData appData in appsData.Applications) { AppIdentity appIdentity = new AppIdentity(appData.Id, appData.Version); AppDeploymentConfig appDeploymentConfig = new AppDeploymentConfig(appIdentity, appData.TargetClusters, appData.Properties); appDeploymentConfigs.Add(appDeploymentConfig); } return(new DeploymentConfig(appDeploymentConfigs)); }
private async Task HandleConnectionSelection() { StorageAccountConnectionInfo connectionInfo = GetCurrentConnection(); IEnumerable<string> appIds = new List<string>(); try { _deploymentConfig = await FetchDeploymentConfig(connectionInfo); appIds = _deploymentConfig.ListApplications(); } catch (StorageException ex) { Debug.WriteLine("Failed to fetch the DeploymentConfig file from account " + connectionInfo.AccountName + " Exception: " + ex); } AppsListView.ItemsSource = appIds; RefreshView(appIds); }
private void OnRemoveDeployment(object sender, RoutedEventArgs e) { StorageAccountConnectionInfo connectionInfo = GetCurrentConnection(); DeploymentInfo deploymendInfo = deploymentIdsListView.SelectedItem as DeploymentInfo; if (deploymendInfo == null) { return; } _deploymentConfig = _deploymentConfig.RemoveApplication(deploymendInfo.AppIdentity, deploymendInfo.DeploymentId); SaveLocalDeploymentConfig(connectionInfo); }
private void OnRemoveVersion(object sender, RoutedEventArgs e) { StorageAccountConnectionInfo connectionInfo = GetCurrentConnection(); string appId = GetSelectedAppId(); if (appId == null) { return; } string version = GetSelectedVersion(); if (version == null) { return; } _deploymentConfig = _deploymentConfig.RemoveApplication(new AppIdentity(appId, version)); SaveLocalDeploymentConfig(connectionInfo); }
private async void OnUpdateVersion(object sender, RoutedEventArgs e) { StorageAccountConnectionInfo connectionInfo = GetCurrentConnection(); string appId = GetSelectedAppId(); string version = GetSelectedVersion(); AppIdentity appIdentity = new AppIdentity(appId, version); IEnumerable<string> availableDeploymentIds = _deploymentConfig.ListClusters(appIdentity); UpdateVersionDialog dialog = new UpdateVersionDialog(appId, version, availableDeploymentIds); if (dialog.ShowDialog() == true) { string newVersion = dialog.NewVersion; AppIdentity newAppIdentity = new AppIdentity(appIdentity.Id, newVersion); IEnumerable<string> selectedDeploymentIds = dialog.SelectedDeploymentIds; foreach (string deploymentId in selectedDeploymentIds) { await AddApplication(newAppIdentity, deploymentId, dialog.BinariesPath); _deploymentConfig = _deploymentConfig.RemoveApplication(appIdentity, deploymentId); } SaveLocalDeploymentConfig(connectionInfo); } }
private void OnVersionAddDeployment(object sender, RoutedEventArgs e) { StorageAccountConnectionInfo connectionInfo = GetCurrentConnection(); string appId = GetSelectedAppId(); string version = GetSelectedVersion(); AddNewDeploymentDialog dialog = new AddNewDeploymentDialog(appId, version); if (dialog.ShowDialog() == true) { AppIdentity appIdentity = new AppIdentity(appId, SemVersion.Parse(version)); _deploymentConfig = _deploymentConfig.AddApplication(appIdentity, dialog.DeploymentId); SaveLocalDeploymentConfig(connectionInfo); } }
private async void OnRemoveApplication(object sender, RoutedEventArgs e) { StorageAccountConnectionInfo connectionInfo = GetCurrentConnection(); string appId = GetSelectedAppId(); _deploymentConfig = _deploymentConfig.RemoveApplication(appId); SaveLocalDeploymentConfig(connectionInfo); await HandleConnectionSelection(); }
private async Task AddApplication(AppIdentity appIdentity, string deploymentId, string binariesPath) { StorageAccountConnectionInfo connectionInfo = GetCurrentConnection(); IDeploymentRepository repository = _deploymentRepositoryManager.GetRepository(connectionInfo); BusyWindow busyWindow = new BusyWindow{Message = "Please wait..\n\n" + "The binaries are being uploaded to blob storage"}; busyWindow.Show(); await repository.UploadApplicationBinaries(appIdentity, binariesPath, ConflictResolutionMode.DoNothingIfBinariesExist); busyWindow.Close(); _deploymentConfig = _deploymentConfig.AddApplication(appIdentity, deploymentId); SaveLocalDeploymentConfig(connectionInfo); }
protected bool Equals(DeploymentConfig other) { return(Equals(_apps, other._apps)); }
public Task PublishDeploymentConfig(DeploymentConfig deploymentConfig) { CloudBlockBlob blob = _blobContainer.GetBlockBlobReference(Constants.DeploymentConfigFileName); return blob.UploadTextAsync(deploymentConfig.RawData()); }
public Task PublishDeploymentConfig(DeploymentConfig deploymentConfig) { File.WriteAllText(_deploymentConfigPath, deploymentConfig.RawData()); return Task.CompletedTask; }
public Task PublishDeploymentConfig(DeploymentConfig deploymentConfig) { File.WriteAllText(_deploymentConfigPath, _serializer.Serialize(deploymentConfig)); return Task.CompletedTask; }
public DeploymentConfig RemoveApplication(AppIdentity appIdentity, string deploymentId) { string appId = appIdentity.Id; string version = appIdentity.Version.ToString(); var apps = GetAppsCopy(); if (!apps.ContainsKey(appId)) { throw new InvalidOperationException($"Cannot remove deployment because app {appId} was not found"); } AppDeploymentConfig appDeploymentConfig = apps[appId]; if (!appDeploymentConfig.Versions.ContainsKey(version)) { throw new InvalidOperationException( $"Cannot remove deployment because app {appId}, version {version} was not found"); } VersionDeploymentConfig versionDeploymentConfig = appDeploymentConfig.Versions[version]; if (!versionDeploymentConfig.DeploymentIds.Contains(deploymentId)) { throw new InvalidOperationException( $"Cannot remove deployment {deploymentId} from app {appId}, version {version} because it was not found"); } versionDeploymentConfig = versionDeploymentConfig.RemoveDeployment(deploymentId); appDeploymentConfig = appDeploymentConfig.SetVersionConfig(versionDeploymentConfig); apps[appId] = appDeploymentConfig; DeploymentConfig dc = new DeploymentConfig(apps); if (!dc._apps[appId].Versions[version].DeploymentIds.Any()) { dc = dc.RemoveApplication(appIdentity); } return dc; }