TemporaryVolume Class
A temporary volume created from a VolumeDefinition. Dispose the instance to remove the volume.
public sealed class TemporaryVolume : IAsyncDisposableRemarks
Disposing only removes the volume when this instance created it and VolumeDefinition.ReuseId is not set. A volume that already existed when TemporaryVolume.EnsureCreatedAsync ran is adopted and left behind, so pointing a definition at an existing volume never destroys it.
- Implements
Properties
| Name | Description |
|---|---|
| Definition | Gets the definition owned by this volume. It is read-only. |
| Name | Gets the volume name. |
| Runtime | Gets the container runtime in use. |
Definition
TemporaryVolume.csGets the definition owned by this volume. It is read-only.
public VolumeDefinition Definition { get; }Property value
Runtime
TemporaryVolume.csMethods
| Name | Description |
|---|---|
| DeleteAsync(CancellationToken) | Removes the volume. |
| DisposeAsync() | Removes the volume when this instance created it and VolumeDefinition.ReuseId is not set. Cleanup is best-effort, bounded in time, and never throws. |
| EnsureCreatedAsync(CancellationToken) | Creates the volume if it does not exist yet. An existing volume is adopted instead, and is not removed on dispose. |
| ExistsAsync(CancellationToken) | Determines whether the volume exists. |
DeleteAsync(CancellationToken)
TemporaryVolume.csRemoves the volume.
net10.0
public Task DeleteAsync(CancellationToken cancellationToken = default)net11.0
public Task DeleteAsync(CancellationToken cancellationToken = default)Parameters
cancellationTokenCancellationToken- A cancellation token.
Returns
Task A task that completes once the volume is removed.
Exceptions
InvalidOperationException- The volume could not be removed, for instance because a container still uses it.
DisposeAsync()
TemporaryVolume.csRemoves the volume when this instance created it and VolumeDefinition.ReuseId is not set. Cleanup is best-effort, bounded in time, and never throws.
net10.0
public ValueTask DisposeAsync()net11.0
public ValueTask DisposeAsync()Returns
ValueTask A task that completes once cleanup finishes.
EnsureCreatedAsync(CancellationToken)
TemporaryVolume.csCreates the volume if it does not exist yet. An existing volume is adopted instead, and is not removed on dispose.
net10.0
public Task EnsureCreatedAsync(CancellationToken cancellationToken = default)net11.0
public Task EnsureCreatedAsync(CancellationToken cancellationToken = default)Parameters
cancellationTokenCancellationToken- A cancellation token.
Returns
Task A task that completes once the volume exists.
ExistsAsync(CancellationToken)
TemporaryVolume.csDetermines whether the volume exists.
net10.0
public Task<bool> ExistsAsync(CancellationToken cancellationToken = default)net11.0
public Task<bool> ExistsAsync(CancellationToken cancellationToken = default)Parameters
cancellationTokenCancellationToken- A cancellation token.
Returns
Task<bool> true if the volume exists; otherwise, false.