private void PopulateBackgroundWorkerOnDoWork(object sender, DoWorkEventArgs doWorkEventArgs)
        {
            this.Logger().Trace("Begin Populate");


            Application.Current.Dispatcher.Invoke(() =>
            {
                IsPopulating = true;
                BuildDefinitions.Clear();
            }, DispatcherPriority.Normal);

            IBuildDefinition[] buildDefinitions;
            if (teamPilgrimServiceModelProvider.TryGetBuildDefinitionsByProjectName(out buildDefinitions, _collection, _project.Name))
            {
                foreach (var buildDefinitionModel in buildDefinitions.Select(definition => new BuildDefinitionModel(this, definition)))
                {
                    var localScopeModel = buildDefinitionModel;
                    Application.Current.Dispatcher.Invoke(() => BuildDefinitions.Add(localScopeModel));
                }
            }

            Application.Current.Dispatcher.Invoke(() => IsPopulating = false, DispatcherPriority.Normal);

            this.Logger().Trace("End Populate");
        }
Exemplo n.º 2
0
        private void ApplyBuildDefinitions(IEnumerable <IBuildDefinition> buildDefinitions)
        {
            BuildDefinitions.AddRange(buildDefinitions.Select(buildDefinition =>
            {
                var vm = new BuildDefinitionViewModel(buildDefinition);

                var definition = MonitorSettings.SelectedBuildDefinitions.SingleOrDefault(a => a.Id == vm.BuildDefinition.Id);
                if (definition != null && this.buildDefinitionEqualityComparer.Equals(definition, vm.BuildDefinition))
                {
                    vm.IsSelected = true;
                }

                return(vm);
            }));

            var obsoleteDefinitions = MonitorSettings.SelectedBuildDefinitions.Where(a => BuildDefinitions.All(x => x.BuildDefinition.Id != a.Id)).ToList();

            foreach (var obsoleteDefinition in obsoleteDefinitions)
            {
                var vm = new BuildDefinitionViewModel(obsoleteDefinition)
                {
                    IsDeleted  = true,
                    IsSelected = true
                };
                BuildDefinitions.Add(vm);
            }
        }
        private void CloneBuildDefinition(BuildDefinitionModel buildDefinitionModel)
        {
            IBuildDefinition buildDefinition;

            if (teamPilgrimServiceModelProvider.TryCloneQueryDefinition(out buildDefinition, _collection, _project, buildDefinitionModel.Definition))
            {
                BuildDefinitions.Add(new BuildDefinitionModel(this, buildDefinition));
            }
        }
Exemplo n.º 4
0
        async void GetDefinitions()
        {
            Working = true;
            await Task.Run(() =>
            {
                buildDefs = TfsShared.Instance.BuildServer.QueryBuildDefinitions(TfsShared.Instance.ProjectInfo.Name, QueryOptions.All);
            });

            foreach (var def in buildDefs)
            {
                BuildDefinitions.Add(def);
            }
            Working = false;
        }
Exemplo n.º 5
0
        /// <summary>
        /// project new state onto the current instance
        /// </summary>
        /// <param name="newState">new intended state</param>
        /// <param name="environments">list of environments to provision to</param>
        public void Update(Tenant newState, IEnumerable <DeploymentEnvironment> environments)
        {
            if (newState == null)
            {
                return;
            }

            Name       = newState.Name;
            TenantSize = newState.TenantSize;

            var newStateForks = newState.SourceRepos.Select(r => new SourceCodeRepository(r.SourceRepositoryName, Code, r.ProjectType, r.Fork)).ToList();

            //update forks and build definitions (1:1) - additions and removals
            newStateForks
            .Except(SourceRepos, ForkEqComparer)
            .ToList()
            .ForEach(f =>
            {
                f.TenantCode = Code;
                SourceRepos.Add(f);
                var bd = new VstsBuildDefinition(f, Code);
                BuildDefinitions.Add(bd);

                //for canary, no PROD env in non prod release pipeline
                var standardPipeline = new VstsReleaseDefinition(bd, Code, TenantSize, false)
                {
                    SkipEnvironments = !f.Fork ? new[] { DeploymentEnvironment.Prod } : new DeploymentEnvironment[] { }
                };
                ReleaseDefinitions.Add(standardPipeline);

                if (f.Fork)
                {
                    return;
                }

                //also initiate ring pipeline (if not fork)
                var ringPipeline = new VstsReleaseDefinition(bd, Code, TenantSize, true);
                ReleaseDefinitions.Add(ringPipeline);
            });

            SourceRepos
            .Except(newStateForks, ForkEqComparer)
            .ToList()
            .ForEach(f =>
            {
                f.State  = EntityStateEnum.ToBeDeleted;
                var bd   = BuildDefinitions.Single(b => Equals(b.SourceCode, f));
                bd.State = EntityStateEnum.ToBeDeleted;
                bd.ReleaseDefinitions.ForEach(d => d.State = EntityStateEnum.ToBeDeleted);
            });

            var environmentList = environments.ToList();

            if (!ResourceGroups.Any())
            {
                foreach (var environmentName in environmentList)
                {
                    // TODO: validate that the list of resource groups and their names
                    ResourceGroups.Add(new ResourceGroup(Code, environmentName, $"checkout-{Code}-{environmentName}"));
                }
            }

            if (!ManagedIdentities.Any())
            {
                foreach (var environmentName in environmentList)
                {
                    // TODO: validate the list of created managed identities and their names
                    ManagedIdentities.Add(new ManagedIdentity
                    {
                        TenantCode        = Code,
                        Environment       = environmentName,
                        IdentityName      = $"{Code}-{environmentName}",
                        ResourceGroupName = $"checkout-{Code}-{environmentName}",
                    });
                }
            }
        }