35 lines
1.2 KiB
Go
35 lines
1.2 KiB
Go
package runtime
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"net/url"
|
|
|
|
"browser.local/run/protocol"
|
|
)
|
|
|
|
func ExecuteRemoteAccessJob(ctx context.Context, assignment protocol.RunJobAssignment) LifecycleExecutionResult {
|
|
if err := protocol.ValidateRunJobAssignment(assignment); err != nil {
|
|
return lifecycleFailure("unsafe_remote_access_job", err.Error())
|
|
}
|
|
if !isSupportedRemoteCapability(assignment.Capability) {
|
|
return lifecycleFailure("unsupported_remote_access_capability", "unsupported remote access capability")
|
|
}
|
|
select {
|
|
case <-ctx.Done():
|
|
return LifecycleExecutionResult{
|
|
State: lifecycleResultStateCancelled,
|
|
Progress: protocol.RunJobProgressReport{Percent: 100, Message: "remote access action cancelled"},
|
|
Message: "remote access action cancelled",
|
|
ErrorCode: "remote_access_cancelled",
|
|
}
|
|
default:
|
|
}
|
|
return LifecycleExecutionResult{
|
|
State: lifecycleResultStateSucceeded,
|
|
Progress: protocol.RunJobProgressReport{Percent: 100, Message: "remote access job accepted"},
|
|
ResultRef: fmt.Sprintf("artifact://jobs/%s/remote-access-result", url.PathEscape(assignment.JobID)),
|
|
Message: fmt.Sprintf("%s completed through bounded remote access envelope", assignment.Capability),
|
|
}
|
|
}
|