Tentacle support enhancements.
This commit is contained in:
1 parent
4cf3335017
commit
24261edb3d
12 files changed
+560
-30
No files matched your search
@@ -43,6 +43,22 @@ func (runtime *tentacleRuntime) interact(ctx context.Context, command tentacleCo
|
||||
defer stopCommand()
|
||||
stop := context.AfterFunc(command.session.OutputContext(), cancel)
|
||||
defer stop()
|
||||
// Policy cancellation can interrupt setup before a lease exists, when no
|
||||
// remote.revoked event is emitted. Tell the original continuation to stop its
|
||||
// inspection/setup workers before releasing the interaction slot. Never pass
|
||||
// cancelled form values or reuse the cancelled interaction context.
|
||||
cleanupNext := ""
|
||||
var approvedEpoch uint64
|
||||
defer func() {
|
||||
if approvedEpoch != 0 {
|
||||
command.session.RevokeRemoteEpoch(approvedEpoch)
|
||||
}
|
||||
if len(command.session.RemoteGrants()) != 0 && cleanupNext != "" && command.session.OutputContext().Err() == nil {
|
||||
cleanupCtx, stopCleanup := context.WithTimeout(context.Background(), 2*time.Second)
|
||||
defer stopCleanup()
|
||||
runtime.callInteraction(cleanupCtx, command, cleanupNext, tentaclewire.Submission{Cancelled: true})
|
||||
}
|
||||
}()
|
||||
var temporaryFiles []string
|
||||
defer func() {
|
||||
for _, path := range temporaryFiles {
|
||||
@@ -60,6 +76,26 @@ func (runtime *tentacleRuntime) interact(ctx context.Context, command tentacleCo
|
||||
if runtime.output.gate.Locked() || runtime.output.gate.Suspended() {
|
||||
return
|
||||
}
|
||||
cleanupNext = value.Next
|
||||
if value.Remote != nil {
|
||||
action, approvalErr := runtime.authorize_remote_session(ctx, command.session, value.Remote.Role, value.Remote.Grants)
|
||||
submission := tentaclewire.Submission{}
|
||||
if approvalErr != nil {
|
||||
submission.Cancelled = true
|
||||
submission.Error = "Remote access was not approved."
|
||||
} else {
|
||||
approvedEpoch = action.Epoch
|
||||
submission.Remote = &action
|
||||
}
|
||||
raw, err = runtime.callInteraction(ctx, command, value.Next, submission)
|
||||
if err == nil && submission.Cancelled {
|
||||
cleanupNext = ""
|
||||
}
|
||||
if err != nil || approvalErr != nil {
|
||||
return
|
||||
}
|
||||
continue
|
||||
}
|
||||
if value.Clipboard != nil {
|
||||
copyCtx, stopCopy := context.WithTimeout(ctx, time.Second)
|
||||
err = writeClipboardText(copyCtx, *value.Clipboard)
|
||||
@@ -98,6 +134,7 @@ func (runtime *tentacleRuntime) interact(ctx context.Context, command tentacleCo
|
||||
if value.Form != nil {
|
||||
if runtime.forms == nil {
|
||||
runtime.callInteraction(ctx, command, value.Next, tentaclewire.Submission{Cancelled: true})
|
||||
cleanupNext = ""
|
||||
runtime.report("Internal UI unavailable.")
|
||||
return
|
||||
}
|
||||
@@ -106,6 +143,7 @@ func (runtime *tentacleRuntime) interact(ctx context.Context, command tentacleCo
|
||||
if openErr != nil {
|
||||
closeForm()
|
||||
runtime.callInteraction(ctx, command, value.Next, tentaclewire.Submission{Cancelled: true})
|
||||
cleanupNext = ""
|
||||
runtime.report("Internal UI unavailable.")
|
||||
return
|
||||
}
|
||||
@@ -158,6 +196,7 @@ func (runtime *tentacleRuntime) interact(ctx context.Context, command tentacleCo
|
||||
return
|
||||
}
|
||||
if submission.Cancelled {
|
||||
cleanupNext = ""
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -216,7 +255,7 @@ func (runtime *tentacleRuntime) waitTentacleForm(ctx context.Context, command te
|
||||
return internalUIResult{Cancelled: true}, nil
|
||||
}
|
||||
status, err := tentaclewire.DecodeInteraction(raw)
|
||||
if err != nil || status.Form != nil || status.Source != "" || status.Next != "" || status.Reader != nil {
|
||||
if err != nil || status.Form != nil || status.Source != "" || status.Next != "" || status.Reader != nil || status.Remote != nil {
|
||||
command.session.Disable()
|
||||
return internalUIResult{Cancelled: true}, nil
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user