bootstrapper: ignore "journald" not in $PATH in constructor

In unit tests, NewCollector may be called on systems that do not have
"journalctl" in $PATH.
We can defer checking if the command can work by not checking cmd.Err in
the constructor.
This commit is contained in:
Malte Poll 2023-11-09 11:16:31 +01:00
parent 22d82a59ed
commit bf06a014a4

View File

@ -30,9 +30,6 @@ type Collector struct {
// NewCollector creates a new Collector for journald logs.
func NewCollector(ctx context.Context) (*Collector, error) {
cmd := exec.CommandContext(ctx, "journalctl")
if cmd.Err != nil {
return nil, cmd.Err
}
stdoutPipe, err := cmd.StdoutPipe()
if err != nil {
return nil, err