master
go 33 lines 938 Bytes
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 //go:build linux
4
5 package systemdunits
6
7 import (
8 "context"
9
10 "github.com/coreos/go-systemd/v22/dbus"
11 )
12
13 type systemdClient interface {
14 connect() (systemdConnection, error)
15 }
16 type systemdConnection interface {
17 Close()
18 GetManagerProperty(string) (string, error)
19 GetUnitPropertyContext(ctx context.Context, unit string, propertyName string) (*dbus.Property, error)
20 ListUnitsContext(ctx context.Context) ([]dbus.UnitStatus, error)
21 ListUnitsByPatternsContext(ctx context.Context, states []string, patterns []string) ([]dbus.UnitStatus, error)
22 ListUnitFilesByPatternsContext(ctx context.Context, states []string, patterns []string) ([]dbus.UnitFile, error)
23 }
24
25 type systemdDBusClient struct{}
26
27 func (systemdDBusClient) connect() (systemdConnection, error) {
28 return dbus.NewWithContext(context.Background())
29 }
30
31 func newSystemdDBusClient() *systemdDBusClient {
32 return &systemdDBusClient{}
33 }