Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ internal static void AddLifeCycleCommands(this IResource resource)
},
updateState: context =>
{
if (IsStarting(context.ResourceSnapshot.State?.Text) || IsWaiting(context.ResourceSnapshot.State?.Text))
var state = context.ResourceSnapshot.State?.Text;
if (IsStarting(state) || IsRuntimeUnhealthy(state))
{
return ResourceCommandState.Disabled;
}
else if (IsStopped(context.ResourceSnapshot.State?.Text))
else if (IsStopped(state) || IsWaiting(state))
{
return ResourceCommandState.Enabled;
}
Expand Down Expand Up @@ -63,11 +64,12 @@ internal static void AddLifeCycleCommands(this IResource resource)
},
updateState: context =>
{
if (IsStopping(context.ResourceSnapshot.State?.Text))
var state = context.ResourceSnapshot.State?.Text;
if (IsStopping(state))
{
return ResourceCommandState.Disabled;
}
else if (!IsStopped(context.ResourceSnapshot.State?.Text) && !IsStarting(context.ResourceSnapshot.State?.Text) && !IsWaiting(context.ResourceSnapshot.State?.Text) && context.ResourceSnapshot.State is not null)
else if (!IsStopped(state) && !IsStarting(state) && !IsWaiting(state) && !IsRuntimeUnhealthy(state) && context.ResourceSnapshot.State is not null)
{
return ResourceCommandState.Enabled;
}
Expand Down Expand Up @@ -96,7 +98,8 @@ internal static void AddLifeCycleCommands(this IResource resource)
},
updateState: context =>
{
if (IsWaiting(context.ResourceSnapshot.State?.Text) || IsStarting(context.ResourceSnapshot.State?.Text) || IsStopping(context.ResourceSnapshot.State?.Text) || IsStopped(context.ResourceSnapshot.State?.Text) || context.ResourceSnapshot.State is null)
var state = context.ResourceSnapshot.State?.Text;
if (IsStarting(state) || IsStopping(state) || IsStopped(state) || IsWaiting(state) || IsRuntimeUnhealthy(state) || context.ResourceSnapshot.State is null)
{
return ResourceCommandState.Disabled;
}
Expand All @@ -115,6 +118,7 @@ internal static void AddLifeCycleCommands(this IResource resource)
static bool IsStopped(string? state) => state is "Exited" or "Finished" or "FailedToStart";
static bool IsStopping(string? state) => state is "Stopping";
static bool IsStarting(string? state) => state is "Starting";
static bool IsWaiting(string? state) => state is "Waiting" or "RuntimeUnhealthy";
static bool IsWaiting(string? state) => state is "Waiting";
static bool IsRuntimeUnhealthy(string? state) => state is "RuntimeUnhealthy";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class ResourceCommandAnnotationTests
[InlineData(CommandsConfigurationExtensions.StartCommandName, "Exited", ResourceCommandState.Enabled)]
[InlineData(CommandsConfigurationExtensions.StartCommandName, "Finished", ResourceCommandState.Enabled)]
[InlineData(CommandsConfigurationExtensions.StartCommandName, "FailedToStart", ResourceCommandState.Enabled)]
[InlineData(CommandsConfigurationExtensions.StartCommandName, "Waiting", ResourceCommandState.Disabled)]
[InlineData(CommandsConfigurationExtensions.StartCommandName, "Waiting", ResourceCommandState.Enabled)]
[InlineData(CommandsConfigurationExtensions.StartCommandName, "RuntimeUnhealthy", ResourceCommandState.Disabled)]
[InlineData(CommandsConfigurationExtensions.StopCommandName, "Starting", ResourceCommandState.Hidden)]
[InlineData(CommandsConfigurationExtensions.StopCommandName, "Stopping", ResourceCommandState.Disabled)]
Expand Down