2020-12-22 00:26:10 +00:00
|
|
|
package auditor
|
|
|
|
|
|
|
|
import (
|
2023-04-06 08:36:25 +00:00
|
|
|
"context"
|
2020-12-22 00:26:10 +00:00
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Execute audits container data.
|
2023-04-06 08:36:25 +00:00
|
|
|
func (c *Context) Execute(ctx context.Context, onCompleted func()) {
|
|
|
|
defer onCompleted()
|
2020-12-22 00:26:10 +00:00
|
|
|
c.init()
|
|
|
|
|
2020-12-22 08:08:31 +00:00
|
|
|
checks := []struct {
|
2020-12-22 00:26:10 +00:00
|
|
|
name string
|
2023-04-06 08:36:25 +00:00
|
|
|
exec func(context.Context)
|
2020-12-22 00:26:10 +00:00
|
|
|
}{
|
|
|
|
{name: "PoR", exec: c.executePoR},
|
|
|
|
{name: "PoP", exec: c.executePoP},
|
|
|
|
{name: "PDP", exec: c.executePDP},
|
2020-12-22 08:08:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for i := range checks {
|
|
|
|
c.log.Debug(fmt.Sprintf("executing %s check...", checks[i].name))
|
2020-12-22 00:26:10 +00:00
|
|
|
|
2023-04-06 08:36:25 +00:00
|
|
|
if c.expired(ctx) {
|
2020-12-22 00:26:10 +00:00
|
|
|
break
|
|
|
|
}
|
|
|
|
|
2023-04-06 08:36:25 +00:00
|
|
|
checks[i].exec(ctx)
|
2020-12-22 08:08:31 +00:00
|
|
|
|
|
|
|
if i == len(checks)-1 {
|
|
|
|
c.complete()
|
|
|
|
}
|
2020-12-22 00:26:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
c.writeReport()
|
|
|
|
}
|