-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reporter api #137
reporter api #137
Conversation
c5244cc
to
267d3d5
Compare
3364acd
to
df53e97
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice start on the api we need to refine a bit but looks good already
|
||
```plantuml | ||
@startjson | ||
[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just return a list of all executions not only the id's, we could use the /reporter/meta to return the execution-id and playbook-id.
##### Step execution data | ||
|field |content |type | description | | ||
| ----------------- | --------------------- | ----------------- | ----------- | | ||
|execution_id |UUID |string |The id of the execution of the playbook where the step resides |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this is redundant in combination with the execution_id of the response. Internally it's included during reporting so it can be matched with the correct execution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took me forever but now it's done
internal/controller/controller.go
Outdated
@@ -47,6 +49,8 @@ type Controller struct { | |||
|
|||
var mainController = Controller{} | |||
|
|||
var mainCache = cache.New(&timeUtil.Time{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to discuss mutex for coroutines
Cache map[string]report.ExecutionEntry // Cached up to max | ||
fifoRegister []string // Used for O(1) FIFO cache management | ||
Cache map[string]cache_report.ExecutionEntry // Cached up to max | ||
fifoRegister []string // Used for O(1) FIFO cache management | ||
} | ||
|
||
func New(timeUtil itime.ITime) *Cache { | ||
maxExecutions, _ := strconv.Atoi(utils.GetEnv("MAX_EXECUTIONS", strconv.Itoa(MaxExecutions))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this and intject it
type Status uint8 | ||
|
||
const ( | ||
SuccessfullyExecuted = "successfully_executed" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe include a link to the execution status repo in a comment
func (reporter *Mock_Downstream_Reporter) GetExecutionsIds() []string { | ||
args := reporter.Called() | ||
return args.Get(0).([]string) | ||
} | ||
|
||
func (reporter *Mock_Downstream_Reporter) GetExecutionReport(executionKey uuid.UUID) (cache_report.ExecutionEntry, error) { | ||
args := reporter.Called(executionKey) | ||
return args.Get(0).(cache_report.ExecutionEntry), args.Error(1) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be in a separate mock as they are not in the cache interface
@@ -4,7 +4,7 @@ import ( | |||
"errors" | |||
"soarca/internal/reporter/downstream_reporter/cache" | |||
"soarca/models/cacao" | |||
"soarca/models/report" | |||
report "soarca/models/cache" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a mismatch between models and naming
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Place this in the unittest folder as it's an unittest
|
||
##### Step execution data | ||
|field |content |type | description | | ||
| ----------------- | --------------------- | ----------------- | ----------- | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Automated execution field is missing here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also see what other fields would make sense to include
| successfully_executed | The workflow step was executed successfully (completed). | | ||
|failed| The workflow step failed. | | ||
|ongoing| The workflow step is in progress. | | ||
|server_side_error| A server-side error occurred. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've sugested await_user_input cyentific-rni/workflow-status#3 if that goes true we need to add that here
df53e97
to
6121451
Compare
|
||
##### Step execution data | ||
|field |content |type | description | | ||
| ----------------- | --------------------- | ----------------- | ----------- | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also see what other fields would make sense to include
acc6ba6
to
9990771
Compare
models/api/reporter.go
Outdated
ExecutionId string | ||
StepId string | ||
Started string | ||
Ended string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type time
Ended: expectedEnded, | ||
StepResults: map[string]cache_model.StepResult{}, | ||
Error: nil, | ||
Status: 2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Status 2 is an enum right?
Defines the initial API endpoints and route logic for reporting