public void Test_UseNaming_SingleOverride() { var mockName = new Mock <IName <DevOpsComponent> >(); FlexDataConfiguration.NamingMap.Clear(); FlexDataConfiguration.UseNaming(mockName.Object); Assert.AreEqual(FlexDataConfiguration.GetNaming <DevOpsComponent>(), mockName.Object); }
public async Task Test_AzureServiceBusNamespace_ProvisionAll_End2End() { FlexDataConfiguration.Branch = "Main"; FlexDataConfiguration.Configuration = "MO"; FlexDataConfiguration.UseNaming(new LegacyFctSbNaming()); using (var client = ManagementClient.CreateServiceBusClient()) using (var context = new DevOpsFlexDbContext()) { await context.Components.OfType <AzureServiceBusNamespace>().ProvisionAllAsync(client); } }
/// <summary> /// Checks for the existence of a specific Azure Web Site, if it doesn't exist it will create it. /// </summary> /// <param name="client">The <see cref="ServiceBusManagementClient"/> that is performing the operation.</param> /// <param name="model">The DevOpsFlex rich model object that contains everything there is to know about this service bus spec.</param> /// <returns>The async <see cref="Task"/> wrapper.</returns> public static async Task CreateNamespaceIfNotExistsAsync(this ServiceBusManagementClient client, AzureServiceBusNamespace model) { Contract.Requires(client != null); Contract.Requires(model != null); await client.CreateNamespaceIfNotExistsAsync( FlexDataConfiguration.GetNaming <AzureServiceBusNamespace>() .GetSlotName( model, FlexDataConfiguration.Branch, FlexDataConfiguration.Configuration), model.Region.GetEnumDescription()); }
/// <summary> /// Checks for the existence of a specific Azure Reserved IP, if it doesn't exist it will create it. /// </summary> /// <param name="client">The <see cref="NetworkManagementClient"/> that is performing the operation.</param> /// <param name="model">The DevOpsFlex rich model object that contains everything there is to know about this cloud service spec.</param> /// <returns>The async <see cref="Task"/> wrapper.</returns> public static async Task ReserveIpIfNotReservedAsync(this NetworkManagementClient client, AzureCloudService model) { Contract.Requires(client != null); Contract.Requires(model != null); Contract.Requires(model.System != null); var ipName = FlexDataConfiguration.GetNaming <AzureCloudService>() .GetSlotName( model, FlexDataConfiguration.Branch, FlexDataConfiguration.Configuration) + "-rip"; await client.ReserveIpIfNotReservedAsync(ipName, model.System.Location.GetEnumDescription()); }
/// <summary> /// Checks for the existence of a specific Azure Web Site, if it doesn't exist it will create it. /// </summary> /// <param name="client">The <see cref="WebSiteManagementClient"/> that is performing the operation.</param> /// <param name="model">The DevOpsFlex rich model object that contains everything there is to know about this web site spec.</param> /// <returns>The async <see cref="Task"/> wrapper.</returns> public static async Task CreateWebSiteIfNotExistsAsync(this WebSiteManagementClient client, AzureWebSite model) { Contract.Requires(client != null); Contract.Requires(model != null); var webSpace = model.System.WebSpace.GetEnumDescription(); string webPlan; lock (HostingPlanGate) { FlexStreams.BuildEventsObserver.OnNext(new CheckForParentResourceEvent(AzureResource.HostingPlan, AzureResource.WebSite, model.Name)); webPlan = FlexConfiguration.WebPlanChooser.Choose(client, webSpace).Result; if (webPlan == null) { var response = client.WebHostingPlans.Create(webSpace, new WebHostingPlanCreateParameters { Name = model.System.LogicalName + "-" + webSpace, NumberOfWorkers = 1, SKU = SkuOptions.Standard, WorkerSize = WorkerSizeOptions.Medium }); webPlan = response.WebHostingPlan.Name; FlexStreams.BuildEventsObserver.OnNext(new ProvisionEvent(AzureResource.HostingPlan, webPlan)); } else { FlexStreams.BuildEventsObserver.OnNext(new FoundExistingEvent(AzureResource.HostingPlan, webPlan)); } } await CreateWebSiteIfNotExistsAsync( client, webSpace, new WebSiteCreateParameters { Name = FlexDataConfiguration.GetNaming <AzureWebSite>().GetSlotName(model, FlexDataConfiguration.Branch, FlexDataConfiguration.Configuration), ServerFarm = webPlan }); }
/// <summary> /// Get the naming object for a specific <see cref="DevOpsComponent"/>. /// </summary> /// <typeparam name="T">The type of the <see cref="DevOpsComponent"/>.</typeparam> /// <returns>The naming object.</returns> public static IName <T> GetNaming <T>() where T : DevOpsComponent { return(FlexDataConfiguration.GetNaming <T>()); }
/// <summary> /// Overrides the <see cref="DefaultNaming{T}"/> for a specific <see cref="DevOpsComponent"/>. /// </summary> /// <typeparam name="T">The type of the <see cref="DevOpsComponent"/> we want to override.</typeparam> /// <param name="naming">The <see cref="IName{T}"/> object that will name the overrides.</param> public static void UseNaming <T>(IName <T> naming) where T : DevOpsComponent { FlexDataConfiguration.UseNaming(naming); }
public void Test_GetNaming_ReturnsDefaultOnBlankMapping() { FlexDataConfiguration.NamingMap.Clear(); Assert.AreEqual(FlexDataConfiguration.GetNaming <DevOpsComponent>().GetType(), typeof(DefaultNaming <DevOpsComponent>)); }