Skip to content

Commit

Permalink
Refactor ListAsync method to return IEnumerable<string> instead of st…
Browse files Browse the repository at this point in the history
…ring[] (#16)
  • Loading branch information
devantler authored Oct 15, 2024
1 parent e79f0b8 commit cfe0fb7
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public interface IKubernetesClusterProvisioner
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<string[]> ListAsync(CancellationToken cancellationToken);
Task<IEnumerable<string>> ListAsync(CancellationToken cancellationToken);

/// <summary>
/// Checks if a Kubernetes cluster exists.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public async Task AllMethods_WithValidParameters_Succeeds()

// Act
var createClusterException = await Record.ExceptionAsync(async () => await _k3dProvisioner.ProvisionAsync(clusterName, configPath, CancellationToken.None).ConfigureAwait(false));
string[] clusters = await _k3dProvisioner.ListAsync(CancellationToken.None);
var clusters = await _k3dProvisioner.ListAsync(CancellationToken.None);
var stopClusterException = await Record.ExceptionAsync(async () => await _k3dProvisioner.StopAsync(clusterName, CancellationToken.None).ConfigureAwait(false));
var startClusterException = await Record.ExceptionAsync(async () => await _k3dProvisioner.StartAsync(clusterName, CancellationToken.None).ConfigureAwait(false));
bool clusterExists = await _k3dProvisioner.ExistsAsync(clusterName, CancellationToken.None);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public async Task<bool> ExistsAsync(string clusterName, CancellationToken cancel
await K3dCLI.K3d.GetClusterAsync(clusterName, cancellationToken).ConfigureAwait(false);

/// <inheritdoc />
public async Task<string[]> ListAsync(CancellationToken cancellationToken) =>
public async Task<IEnumerable<string>> ListAsync(CancellationToken cancellationToken) =>
await K3dCLI.K3d.ListClustersAsync(cancellationToken).ConfigureAwait(false);

/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public async Task AllMethods_WithValidParameters_Succeeds()

// Act
var createClusterException = await Record.ExceptionAsync(async () => await _kindProvisioner.ProvisionAsync(clusterName, configPath, CancellationToken.None).ConfigureAwait(false));
string[] clusters = await _kindProvisioner.ListAsync(CancellationToken.None);
var clusters = await _kindProvisioner.ListAsync(CancellationToken.None);
var stopClusterException = await Record.ExceptionAsync(async () => await _kindProvisioner.StopAsync(clusterName, CancellationToken.None).ConfigureAwait(false));
var startClusterException = await Record.ExceptionAsync(async () => await _kindProvisioner.StartAsync(clusterName, CancellationToken.None).ConfigureAwait(false));
bool clusterExists = await _kindProvisioner.ExistsAsync(clusterName, CancellationToken.None);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ public async Task DeprovisionAsync(string clusterName, CancellationToken cancell
/// <inheritdoc />
public async Task<bool> ExistsAsync(string clusterName, CancellationToken cancellationToken)
{
string[] clusterNames = await ListAsync(cancellationToken).ConfigureAwait(false);
var clusterNames = await ListAsync(cancellationToken).ConfigureAwait(false);
return clusterNames.Contains(clusterName);
}

/// <inheritdoc />
public async Task<string[]> ListAsync(CancellationToken cancellationToken) =>
public async Task<IEnumerable<string>> ListAsync(CancellationToken cancellationToken) =>
await KindCLI.Kind.GetClustersAsync(cancellationToken).ConfigureAwait(false);

/// <inheritdoc />
Expand Down

0 comments on commit cfe0fb7

Please sign in to comment.