Dmitrii Stepanov
e8d340287f
Resolve containedctx linter. Cancel task by listen cancel. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
37 lines
588 B
Go
37 lines
588 B
Go
package auditor
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
)
|
|
|
|
// Execute audits container data.
|
|
func (c *Context) Execute(ctx context.Context, onCompleted func()) {
|
|
defer onCompleted()
|
|
c.init()
|
|
|
|
checks := []struct {
|
|
name string
|
|
exec func(context.Context)
|
|
}{
|
|
{name: "PoR", exec: c.executePoR},
|
|
{name: "PoP", exec: c.executePoP},
|
|
{name: "PDP", exec: c.executePDP},
|
|
}
|
|
|
|
for i := range checks {
|
|
c.log.Debug(fmt.Sprintf("executing %s check...", checks[i].name))
|
|
|
|
if c.expired(ctx) {
|
|
break
|
|
}
|
|
|
|
checks[i].exec(ctx)
|
|
|
|
if i == len(checks)-1 {
|
|
c.complete()
|
|
}
|
|
}
|
|
|
|
c.writeReport()
|
|
}
|