/// <summary> /// Creates a new container and lists it to output. /// </summary> protected override async Task ProcessRecordAsync() { foreach (var id in ParameterResolvers.GetImageIds(Image, ImageIdOrName)) { var createResult = await ContainerOperations.CreateContainer( id, this.MemberwiseClone() as CreateContainerCmdlet, DkrClient); if (createResult.Warnings != null) { foreach (var w in createResult.Warnings) { if (!String.IsNullOrEmpty(w)) { WriteWarning(w); } } } if (!String.IsNullOrEmpty(createResult.ID)) { WriteObject((await ContainerOperations.GetContainersById(createResult.ID, DkrClient)).Single()); } } }
/// <summary> /// Creates a new container and lists it to output. /// </summary> protected override void ProcessRecord() { base.ProcessRecord(); foreach (var id in ParameterResolvers.GetImageIds(Image, Id)) { var createResult = ContainerOperations.CreateContainer( id, this.MemberwiseClone() as CreateContainerCmdlet, DkrClient); if (createResult.Warnings != null) { foreach (var w in createResult.Warnings) { if (!String.IsNullOrEmpty(w)) { WriteWarning(w); } } } if (!String.IsNullOrEmpty(createResult.ID)) { WriteObject(ContainerOperations.GetContainerById(createResult.ID, DkrClient)); } } }
/// <summary> /// Creates a new container and lists it to output. /// </summary> protected override async Task ProcessRecordAsync() { foreach (var id in ParameterResolvers.GetImageIds(Image, ImageIdOrName)) { var createResult = await ContainerOperations.CreateContainer( id, this.MemberwiseClone() as CreateContainerCmdlet, DkrClient); if (createResult.Warnings != null) { foreach (var w in createResult.Warnings) { if (!String.IsNullOrEmpty(w)) { WriteWarning(w); } } } if (!String.IsNullOrEmpty(createResult.ID)) { ContainerAttachParameters attachParams = null; if (!Detach) { attachParams = new ContainerAttachParameters { Stdin = Input, Stdout = true, Stderr = true, Stream = true }; } await ContainerOperations.StartContainerAsync( this.DkrClient, createResult.ID, attachParams, this.Terminal, null, this.CmdletCancellationToken); if (RemoveAutomatically && !Detach) { await DkrClient.Containers.RemoveContainerAsync(createResult.ID, new ContainerRemoveParameters()); } else if (PassThru) { WriteObject((await ContainerOperations.GetContainersById(createResult.ID, DkrClient)).Single()); } } } }
protected override async Task ProcessRecordAsync() { foreach (var id in ParameterResolvers.GetImageIds(Image, Id)) { await DkrClient.Images.DeleteImageAsync(id, new ImageDeleteParameters() { Force = Force.ToBool() } ); } }
protected override async Task ProcessRecordAsync() { var filePath = System.IO.Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, DestinationFilePath); var names = new List <string>(ParameterResolvers.GetImageIds(Image, Id)); using (var fs = File.Create(filePath)) using (var stream = await DkrClient.Miscellaneous.GetImagesAsTarballAsync(names.ToArray(), CmdletCancellationToken)) using (CmdletCancellationToken.Register(() => stream.Dispose())) { await stream.CopyToAsync(fs); } }
protected override void ProcessRecord() { base.ProcessRecord(); foreach (var id in ParameterResolvers.GetImageIds(Image, Id)) { DkrClient.Images.DeleteImageAsync(id, new ImageDeleteParameters() { Force = Force.ToBool() } ).WaitUnwrap(); } }
/// <summary> /// Creates a new container and lists it to output. /// </summary> protected override void ProcessRecord() { base.ProcessRecord(); foreach (var id in ParameterResolvers.GetImageIds(Image, Id)) { var createResult = ContainerOperations.CreateContainer( id, this.MemberwiseClone() as CreateContainerCmdlet, DkrClient); if (createResult.Warnings != null) { foreach (var w in createResult.Warnings) { if (!String.IsNullOrEmpty(w)) { WriteWarning(w); } } } if (!String.IsNullOrEmpty(createResult.ID)) { if (!DkrClient.Containers.StartContainerAsync( createResult.ID, HostConfiguration).AwaitResult()) { throw new ApplicationFailedException("The container has already started."); } var waitResponse = DkrClient.Containers.WaitContainerAsync( createResult.ID, CancelSignal.Token).AwaitResult(); WriteVerbose("Status Code: " + waitResponse.StatusCode.ToString()); ContainerOperations.ThrowOnProcessExitCode(waitResponse.StatusCode); if (RemoveAutomatically.ToBool()) { DkrClient.Containers.RemoveContainerAsync(createResult.ID, new ContainerRemoveParameters()).WaitUnwrap(); } else if (PassThru.ToBool()) { WriteObject(ContainerOperations.GetContainerById(createResult.ID, DkrClient)); } } } }
protected override async Task ProcessRecordAsync() { foreach (var id in ParameterResolvers.GetImageIds(Image, Id)) { var tagParams = new ImageTagParameters() { RepositoryName = Repository }; if (!string.IsNullOrEmpty(Tag)) { tagParams.Tag = Tag; } if (Force) { tagParams.Force = true; } await DkrClient.Images.TagImageAsync(id, tagParams); } }
/// <summary> /// Creates a new container and lists it to output. /// </summary> protected override async Task ProcessRecordAsync() { foreach (var id in ParameterResolvers.GetImageIds(Image, Id)) { var createResult = await ContainerOperations.CreateContainer( id, this.MemberwiseClone() as CreateContainerCmdlet, DkrClient); if (createResult.Warnings != null) { foreach (var w in createResult.Warnings) { if (!String.IsNullOrEmpty(w)) { WriteWarning(w); } } } if (!String.IsNullOrEmpty(createResult.ID)) { MultiplexedStream stream = null; Task streamTask = null; try { if (!Detach) { var parameters = new ContainerAttachParameters { Stdin = Input, Stdout = true, Stderr = true, Stream = true }; stream = await DkrClient.Containers.AttachContainerAsync(createResult.ID, Terminal, parameters, CmdletCancellationToken); streamTask = stream.CopyToConsoleAsync(Terminal, Input, CmdletCancellationToken); } if (!await DkrClient.Containers.StartContainerAsync(createResult.ID, new ContainerStartParameters())) { throw new ApplicationFailedException("The container has already started."); } if (!Detach) { await streamTask; } } finally { stream?.Dispose(); } if (RemoveAutomatically && !Detach) { await DkrClient.Containers.RemoveContainerAsync(createResult.ID, new ContainerRemoveParameters()); } else if (PassThru) { WriteObject((await ContainerOperations.GetContainersById(createResult.ID, DkrClient)).Single()); } } } }