package heartbeat import ( "amadan.net/oficina/equipo/internal/runnerproto" "crypto/rand" ) func Request(reports []runnerproto.ConnectionReport, repositories func() ([]string, error)) (runnerproto.HeartbeatRequest, error) { raw, err := runnerproto.Marshal(reports) if err != nil { return runnerproto.HeartbeatRequest{}, err } names := []string{} if repositories != nil { names, err = repositories() // Failed discovery withdraws previous names rather than retaining stale access. if err != nil { names = []string{} } } return runnerproto.HeartbeatRequest{Version: 2, RequestID: rand.Text(), Reports: raw, Repositories: names}, nil }