mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-11 01:31:38 +00:00
implement not-implemented: GetInputContainerQueues (#2380)
* implement not-implemented: GetInputContainerQueues * named tuple Co-authored-by: stas <statis@microsoft.com>
This commit is contained in:
parent
44f74f622a
commit
ce1fc773a9
@ -85,7 +85,8 @@ public class NotificationOperations : Orm<Notification>, INotificationOperations
|
|||||||
// Nullability mismatch: We filter tuples where the containers are null
|
// Nullability mismatch: We filter tuples where the containers are null
|
||||||
return _context.TaskOperations.SearchStates(states: TaskStateHelper.AvailableStates)
|
return _context.TaskOperations.SearchStates(states: TaskStateHelper.AvailableStates)
|
||||||
.Select(task => (task, _context.TaskOperations.GetInputContainerQueues(task.Config)))
|
.Select(task => (task, _context.TaskOperations.GetInputContainerQueues(task.Config)))
|
||||||
.Where(taskTuple => taskTuple.Item2 != null)!;
|
.Where(taskTuple => taskTuple.Item2.IsOk && taskTuple.Item2.OkV != null)
|
||||||
|
.Select(x => (Task: x.Item1, Containers: x.Item2.OkV))!;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Async.Task<OneFuzzResult<Notification>> Create(Container container, NotificationTemplate config, bool replaceExisting) {
|
public async Async.Task<OneFuzzResult<Notification>> Create(Container container, NotificationTemplate config, bool replaceExisting) {
|
||||||
|
@ -15,7 +15,7 @@ public interface ITaskOperations : IStatefulOrm<Task, TaskState> {
|
|||||||
|
|
||||||
IAsyncEnumerable<Task> SearchStates(Guid? jobId = null, IEnumerable<TaskState>? states = null);
|
IAsyncEnumerable<Task> SearchStates(Guid? jobId = null, IEnumerable<TaskState>? states = null);
|
||||||
|
|
||||||
IEnumerable<Container>? GetInputContainerQueues(TaskConfig config);
|
Result<IEnumerable<Container>?, TaskConfigError> GetInputContainerQueues(TaskConfig config);
|
||||||
|
|
||||||
IAsyncEnumerable<Task> SearchExpired();
|
IAsyncEnumerable<Task> SearchExpired();
|
||||||
Async.Task MarkStopping(Task task);
|
Async.Task MarkStopping(Task task);
|
||||||
@ -75,8 +75,17 @@ public class TaskOperations : StatefulOrm<Task, TaskState, TaskOperations>, ITas
|
|||||||
return QueryAsync(filter: queryString);
|
return QueryAsync(filter: queryString);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Container>? GetInputContainerQueues(TaskConfig config) {
|
public Result<IEnumerable<Container>?, TaskConfigError> GetInputContainerQueues(TaskConfig config) {
|
||||||
throw new NotImplementedException();
|
|
||||||
|
if (!Defs.TASK_DEFINITIONS.ContainsKey(config.Task.Type)) {
|
||||||
|
return Result<IEnumerable<Container>?, TaskConfigError>.Error(new TaskConfigError($"unsupported task type: {config.Task.Type}"));
|
||||||
|
}
|
||||||
|
|
||||||
|
var containerType = Defs.TASK_DEFINITIONS[config.Task.Type].MonitorQueue;
|
||||||
|
if (containerType is not null && config.Containers is not null)
|
||||||
|
return Result<IEnumerable<Container>?, TaskConfigError>.Ok(config.Containers.Where(x => x.Type == containerType).Select(x => x.Name));
|
||||||
|
else
|
||||||
|
return Result<IEnumerable<Container>?, TaskConfigError>.Ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IAsyncEnumerable<Task> SearchExpired() {
|
public IAsyncEnumerable<Task> SearchExpired() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user