47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
"os"
|
|
|
|
ck "gitea.maximumdirect.net/eric/ConfigKit"
|
|
)
|
|
|
|
func main() {
|
|
// Only the synthetic offline demonstration sets this value. Consumers resolve
|
|
// their configured credential references through ConfigKit.
|
|
if err := os.Setenv("AUDITA_PROTOTYPE_KEY", "synthetic-offline-key"); err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
os.Exit(1)
|
|
}
|
|
loaded, err := loadConfig(ck.File("config.yaml"))
|
|
if err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
os.Exit(1)
|
|
}
|
|
runtime, err := newRuntime(loaded.Config, ".", demonstrationClient())
|
|
if err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
os.Exit(1)
|
|
}
|
|
recorder := &Recorder{}
|
|
result, err := runtime.workflow(context.Background(), recorder.observer)
|
|
if err != nil {
|
|
fmt.Fprintln(os.Stderr, "offline workflow failed")
|
|
os.Exit(1)
|
|
}
|
|
attempts, retries, repairs := recorder.totals()
|
|
output := struct {
|
|
Result WorkflowResult `json:"result"`
|
|
Attempts uint64 `json:"attempts"`
|
|
Retries uint64 `json:"transient_retries"`
|
|
Repairs uint64 `json:"structural_repairs"`
|
|
}{result, attempts, retries, repairs}
|
|
if err := json.NewEncoder(os.Stdout).Encode(output); err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
os.Exit(1)
|
|
}
|
|
}
|