Skip to content

Commit 4d561fd

Browse files
Making ExitCode not nullable, plus renaming command context parameter (#1061)
1 parent d6ac40d commit 4d561fd

File tree

7 files changed

+19
-19
lines changed

7 files changed

+19
-19
lines changed

source/Octopus.Tentacle.Client/ScriptExecutor.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,28 +52,28 @@ public async Task<ScriptOperationExecutionResult> StartScript(ExecuteScriptComma
5252
return await scriptExecutor.StartScript(executeScriptCommand, startScriptIsBeingReAttempted, cancellationToken);
5353
}
5454

55-
public async Task<ScriptOperationExecutionResult> GetStatus(CommandContext ticketForNextNextStatus, CancellationToken cancellationToken)
55+
public async Task<ScriptOperationExecutionResult> GetStatus(CommandContext commandContext, CancellationToken cancellationToken)
5656
{
5757
var scriptExecutorFactory = CreateScriptExecutorFactory();
58-
var scriptExecutor = scriptExecutorFactory.CreateScriptExecutor(ticketForNextNextStatus.ScripServiceVersionUsed);
58+
var scriptExecutor = scriptExecutorFactory.CreateScriptExecutor(commandContext.ScripServiceVersionUsed);
5959

60-
return await scriptExecutor.GetStatus(ticketForNextNextStatus, cancellationToken);
60+
return await scriptExecutor.GetStatus(commandContext, cancellationToken);
6161
}
6262

63-
public async Task<ScriptOperationExecutionResult> CancelScript(CommandContext ticketForNextNextStatus)
63+
public async Task<ScriptOperationExecutionResult> CancelScript(CommandContext commandContext)
6464
{
6565
var scriptExecutorFactory = CreateScriptExecutorFactory();
66-
var scriptExecutor = scriptExecutorFactory.CreateScriptExecutor(ticketForNextNextStatus.ScripServiceVersionUsed);
66+
var scriptExecutor = scriptExecutorFactory.CreateScriptExecutor(commandContext.ScripServiceVersionUsed);
6767

68-
return await scriptExecutor.CancelScript(ticketForNextNextStatus);
68+
return await scriptExecutor.CancelScript(commandContext);
6969
}
7070

71-
public async Task<ScriptStatus?> CompleteScript(CommandContext ticketForNextNextStatus, CancellationToken cancellationToken)
71+
public async Task<ScriptStatus?> CompleteScript(CommandContext commandContext, CancellationToken cancellationToken)
7272
{
7373
var scriptExecutorFactory = CreateScriptExecutorFactory();
74-
var scriptExecutor = scriptExecutorFactory.CreateScriptExecutor(ticketForNextNextStatus.ScripServiceVersionUsed);
74+
var scriptExecutor = scriptExecutorFactory.CreateScriptExecutor(commandContext.ScripServiceVersionUsed);
7575

76-
return await scriptExecutor.CompleteScript(ticketForNextNextStatus, cancellationToken);
76+
return await scriptExecutor.CompleteScript(commandContext, cancellationToken);
7777
}
7878

7979
ScriptExecutorFactory CreateScriptExecutorFactory()

source/Octopus.Tentacle.Client/Scripts/KubernetesScriptServiceV1Executor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,11 @@ async Task<KubernetesScriptStatusResponseV1> GetStatusAction(CancellationToken c
153153
return Map(kubernetesScriptStatusResponseV1);
154154
}
155155

156-
public async Task<ScriptOperationExecutionResult> CancelScript(CommandContext lastStatusResponse)
156+
public async Task<ScriptOperationExecutionResult> CancelScript(CommandContext commandContext)
157157
{
158158
async Task<KubernetesScriptStatusResponseV1> CancelScriptAction(CancellationToken ct)
159159
{
160-
var request = new CancelKubernetesScriptCommandV1(lastStatusResponse.ScriptTicket, lastStatusResponse.NextLogSequence);
160+
var request = new CancelKubernetesScriptCommandV1(commandContext.ScriptTicket, commandContext.NextLogSequence);
161161
var result = await clientKubernetesScriptServiceV1.CancelScriptAsync(request, new HalibutProxyRequestOptions(ct));
162162

163163
return result;

source/Octopus.Tentacle.Client/Scripts/ObservingScriptOrchestrator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public async Task<ScriptExecutionResult> ExecuteScript(ExecuteScriptCommand comm
3939
throw new OperationCanceledException("Script execution was cancelled");
4040
}
4141

42-
return new ScriptExecutionResult(scriptStatus.State, scriptStatus.ExitCode!.Value);
42+
return new ScriptExecutionResult(scriptStatus.State, scriptStatus.ExitCode);
4343
}
4444

4545
async Task<ScriptStatus> ObserveUntilCompleteThenFinish(

source/Octopus.Tentacle.Client/Scripts/ScriptOperationExecutionResult.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public ScriptOperationExecutionResult(ScriptStatus scriptStatus, CommandContext
2121
/// </summary>
2222
internal static ScriptOperationExecutionResult CreateScriptStartedResult(ScriptTicket scriptTicket, ScriptServiceVersion scripServiceVersionUsed)
2323
{
24-
var scriptStatus = new ScriptStatus(ProcessState.Pending, null, new List<ProcessOutput>());
24+
var scriptStatus = new ScriptStatus(ProcessState.Pending, 0, new List<ProcessOutput>());
2525
var contextForNextCommand = new CommandContext(scriptTicket, 0, scripServiceVersionUsed);
2626
return new(scriptStatus, contextForNextCommand);
2727
}

source/Octopus.Tentacle.Client/Scripts/ScriptServiceV1Executor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ public async Task<ScriptOperationExecutionResult> GetStatus(CommandContext comma
106106
return Map(scriptStatusResponseV1);
107107
}
108108

109-
public async Task<ScriptOperationExecutionResult> CancelScript(CommandContext lastStatusResponse)
109+
public async Task<ScriptOperationExecutionResult> CancelScript(CommandContext commandContext)
110110
{
111111
var response = await rpcCallExecutor.ExecuteWithNoRetries(
112112
RpcCall.Create<IScriptService>(nameof(IScriptService.CancelScript)),
113113
async ct =>
114114
{
115-
var request = new CancelScriptCommand(lastStatusResponse.ScriptTicket, lastStatusResponse.NextLogSequence);
115+
var request = new CancelScriptCommand(commandContext.ScriptTicket, commandContext.NextLogSequence);
116116
var result = await clientScriptServiceV1.CancelScriptAsync(request, new HalibutProxyRequestOptions(ct));
117117

118118
return result;

source/Octopus.Tentacle.Client/Scripts/ScriptServiceV2Executor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,11 @@ async Task<ScriptStatusResponseV2> GetStatusAction(CancellationToken ct)
146146
return Map(scriptStatusResponseV2);
147147
}
148148

149-
public async Task<ScriptOperationExecutionResult> CancelScript(CommandContext lastStatusResponse)
149+
public async Task<ScriptOperationExecutionResult> CancelScript(CommandContext commandContext)
150150
{
151151
async Task<ScriptStatusResponseV2> CancelScriptAction(CancellationToken ct)
152152
{
153-
var request = new CancelScriptCommandV2(lastStatusResponse.ScriptTicket, lastStatusResponse.NextLogSequence);
153+
var request = new CancelScriptCommandV2(commandContext.ScriptTicket, commandContext.NextLogSequence);
154154
var result = await clientScriptServiceV2.CancelScriptAsync(request, new HalibutProxyRequestOptions(ct));
155155

156156
return result;

source/Octopus.Tentacle.Contracts/ScriptStatus.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ namespace Octopus.Tentacle.Contracts
55
public class ScriptStatus
66
{
77
public ProcessState State { get; }
8-
public int? ExitCode { get; }
8+
public int ExitCode { get; }
99
public List<ProcessOutput> Logs { get; }
1010

11-
public ScriptStatus(ProcessState state, int? exitCode, List<ProcessOutput> logs)
11+
public ScriptStatus(ProcessState state, int exitCode, List<ProcessOutput> logs)
1212
{
1313
State = state;
1414
ExitCode = exitCode;

0 commit comments

Comments
 (0)