コード例 #1
0
        public PhaseResource Clear()
        {
            AutomaticDeploymentTargets.Clear();
            OptionalDeploymentTargets.Clear();
            MinimumEnvironmentsBeforePromotion = 0;
            ReleaseRetentionPolicy = null;
            TentacleRetentionPolicy = null;

            return this;
        }
コード例 #2
0
        public void CreateAndRemoveLifecycle()
        {
            #region LifecycleCreate

            var releaseRetention  = new RetentionPeriod(1, RetentionUnit.Items);
            var tentacleRetention = new RetentionPeriod(1, RetentionUnit.Items);

            var resource = new LifecycleResource()
            {
                Name                    = TestResourceName,
                Description             = String.Format("Lifecycle {0}", TestResourceName),
                ReleaseRetentionPolicy  = releaseRetention,
                TentacleRetentionPolicy = tentacleRetention
            };

            var createParameters = new List <CmdletParameter>
            {
                new CmdletParameter()
                {
                    Name     = "Resource",
                    Resource = resource
                }
            };

            var createPowershell = new CmdletRunspace().CreatePowershellcmdlet(CreateCmdletName, CreateCmdletType, createParameters);

            //The fact that the line below doesn't throw is enough to prove that the cmdlet returns the expected object type really. Couldn't figure out a way to make the assert around the Powershell.invoke call
            var createResult = createPowershell.Invoke <LifecycleResource>().FirstOrDefault();

            if (createResult != null)
            {
                Assert.AreEqual(createResult.Name, TestResourceName);
                Console.WriteLine("Created resource [{0}] of type [{1}]", createResult.Name, createResult.GetType());
            }
            #endregion

            #region LifecycleDelete
            var removeParameters = new List <CmdletParameter>
            {
                new CmdletParameter()
                {
                    Name     = "Resource",
                    Resource = createResult
                }
            };

            var removePowershell = new CmdletRunspace().CreatePowershellcmdlet(RemoveCmdletName, RemoveCmdletType);

            var removeResult = removePowershell.Invoke <bool>(removeParameters).FirstOrDefault();

            Assert.IsTrue(removeResult);
            Console.WriteLine("Deleted resource [{0}] of type [{1}]", createResult.Name, createResult.GetType());
            #endregion
        }
        public void HasRetentionPeriod(int number, RetentionPeriod retentionPeriod)
        {
            if (number <= 0)
            {
                throw new ArgumentException(nameof(number));
            }

            if (Enum.IsDefined(typeof(RetentionPeriod), retentionPeriod) == false)
            {
                throw new ArgumentException("Invalid RetentionPeriod value");
            }

            _Retention       = number;
            _RetentionPeriod = retentionPeriod;
        }
コード例 #4
0
        public VariableCollection GetVariableManifest(NancyContext context, string releaseId, string environmentId, string tenantId)
        {
            using (var transaction = _store.BeginTransaction())
            {
                var release     = transaction.LoadRequired <Release>(releaseId);
                var environment = transaction.LoadRequired <DeploymentEnvironment>(environmentId);
                var tenant      = string.IsNullOrEmpty(tenantId) ? null : transaction.LoadRequired <Tenant>(tenantId);

                var project           = transaction.LoadRequired <Project>(release.ProjectId);
                var deploymentProcess = transaction.LoadRequired <DeploymentProcess>(release.ProjectDeploymentProcessSnapshotId);
                GetPreviousDeployment(transaction, project.Id, environmentId, tenantId, out var previousSuccessfulEnvironmentDeployment, out var currentReleaseForEnvironment);

                return(_deploymentManifestFactory.CreateManifestVariables(
                           _webPortalConfigurationStore.GetListenPrefixes(),
                           new Deployment(),
                           project,
                           deploymentProcess,
                           environment,
                           release,
                           GetChannel(transaction, release.ChannelId),
                           GetServerTask(project, release, environment, tenant),
                           GetEnvironmentMachines(transaction, environmentId, deploymentProcess, release.ChannelId, tenant),
                           GetEnvironmentAccounts(transaction, environmentId),
                           GetMachinePolicies(transaction),
                           RetentionPeriod.KeepForever(),
                           GetProjectGroup(transaction, project),
                           GetUser(context, transaction),
                           GetProjectVariables(transaction, release, project),
                           GetLibraryVariables(transaction, release, project),
                           GetPreviousRelease(transaction, releaseId, release.ProjectId),
                           GetPreviousReleaseForEnvironment(transaction, release.ProjectId, environmentId, releaseId),
                           previousSuccessfulEnvironmentDeployment,
                           currentReleaseForEnvironment,
                           tenant,
                           GetTagNameMapper(transaction),
                           GetTenantVariables(transaction, tenantId, release.ProjectId, environmentId)));
            }
        }
コード例 #5
0
 public PhaseResource WithTentacleRetentionPolicy(RetentionPeriod period)
 {
     TentacleRetentionPolicy = period;
     return this;
 }
コード例 #6
0
 public PhaseResource WithReleaseRetentionPolicy(RetentionPeriod period)
 {
     ReleaseRetentionPolicy = period;
     return this;
 }
コード例 #7
0
 public static RetentionPolicy ToModel(this RetentionPeriod period)
 {
     return(new RetentionPolicy(
                period.QuantityToKeep,
                (RetentionPolicy.RetentionUnit)period.Unit));
 }
コード例 #8
0
        public static String RetentionPeriodToString(RetentionPeriod retentionPeriod)
        {
            string enumName = Enum.GetName(typeof(RetentionPeriod), retentionPeriod);

            return(string.Concat(enumName.Select((x, i) => i > 0 && char.IsUpper(x) ? "_" + x.ToString() : x.ToString())).ToLower());
        }
 public void HasInfiniteRetentionPeriod()
 {
     _Retention       = -1;
     _RetentionPeriod = 0;
 }