protected override void ProcessRecord() { object baseresource = null; switch (Resource) { case "Environment": baseresource = new EnvironmentResource(); break; case "Project": baseresource = new ProjectResource(); break; case "ProjectGroup": baseresource = new ProjectGroupResource(); break; case "NugetFeed": case "ExternalFeed": baseresource = new NuGetFeedResource(); break; case "LibraryVariableSet": baseresource = new LibraryVariableSetResource(); break; case "Machine": case "Target": baseresource = new MachineResource(); break; case "Lifecycle": baseresource = new LifecycleResource(); break; case "Team": baseresource = new TeamResource(); break; case "User": baseresource = new UserResource(); break; case "Channel": baseresource = new ChannelResource(); break; case "Tenant": baseresource = new TenantResource(); break; case "TagSet": baseresource = new TagSetResource(); break; } WriteObject(baseresource); }
public static TagSetResource UpdateWith(this TagSetResource resource, TagSet model, IOctopusAsyncRepository repository) { resource.Name = model.Identifier.Name; foreach (var tag in model.Tags) { resource.AddOrUpdateTag(tag); } return(resource); }
public void CreateAndRemoveTagSet() { #region TagSetCreate var resource = new TagSetResource() { Name = TestResourceName, }; 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 <TagSetResource>().FirstOrDefault(); if (createResult != null) { Assert.AreEqual(createResult.Name, TestResourceName); Console.WriteLine("Created resource [{0}] of type [{1}]", createResult.Name, createResult.GetType()); } #endregion #region TagSetDelete 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 static TagSet ToModel(this TagSetResource resource, IOctopusAsyncRepository repository) { return(new TagSet(new ElementIdentifier(resource.Name), resource.Tags.Select(x => x.Name))); }
private async Task <TagSet> ReadTagSet(TagSetResource resource) { _logger.LogInformation($"Downloading {nameof(TagSetResource)}: {resource.Name}"); return(await Task.FromResult(resource.ToModel(_repository))); }
internal TagSet DownloadTagSet(TagSetResource resource) { Logger.Info($"Downloading {nameof(TagSetResource)}: {resource.Name}"); return(resource.ToModel(_repository)); }