vendor: github.com/coreos/go-systemd/v22 v22.6.0
| ... | ... |
@@ -29,7 +29,7 @@ require ( |
| 29 | 29 |
github.com/containerd/log v0.1.0 |
| 30 | 30 |
github.com/containerd/platforms v1.0.0-rc.1 |
| 31 | 31 |
github.com/containerd/typeurl/v2 v2.2.3 |
| 32 |
- github.com/coreos/go-systemd/v22 v22.5.0 |
|
| 32 |
+ github.com/coreos/go-systemd/v22 v22.6.0 |
|
| 33 | 33 |
github.com/cpuguy83/tar2go v0.3.1 |
| 34 | 34 |
github.com/creack/pty v1.1.24 |
| 35 | 35 |
github.com/deckarep/golang-set/v2 v2.3.0 |
| ... | ... |
@@ -155,8 +155,8 @@ github.com/containernetworking/cni v1.3.0 h1:v6EpN8RznAZj9765HhXQrtXgX+ECGebEYEm |
| 155 | 155 |
github.com/containernetworking/cni v1.3.0/go.mod h1:Bs8glZjjFfGPHMw6hQu82RUgEPNGEaBb9KS5KtNMnJ4= |
| 156 | 156 |
github.com/containernetworking/plugins v1.7.1 h1:CNAR0jviDj6FS5Vg85NTgKWLDzZPfi/lj+VJfhMDTIs= |
| 157 | 157 |
github.com/containernetworking/plugins v1.7.1/go.mod h1:xuMdjuio+a1oVQsHKjr/mgzuZ24leAsqUYRnzGoXHy0= |
| 158 |
-github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= |
|
| 159 |
-github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= |
|
| 158 |
+github.com/coreos/go-systemd/v22 v22.6.0 h1:aGVa/v8B7hpb0TKl0MWoAavPDmHvobFe5R5zn0bCJWo= |
|
| 159 |
+github.com/coreos/go-systemd/v22 v22.6.0/go.mod h1:iG+pp635Fo7ZmV/j14KUcmEyWF+0X7Lua8rrTWzYgWU= |
|
| 160 | 160 |
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= |
| 161 | 161 |
github.com/cpuguy83/tar2go v0.3.1 h1:DMWlaIyoh9FBWR4hyfZSOEDA7z8rmCiGF1IJIzlTlR8= |
| 162 | 162 |
github.com/cpuguy83/tar2go v0.3.1/go.mod h1:2Ys2/Hu+iPHQRa4DjIVJ7UAaKnDhAhNACeK3A0Rr5rM= |
| ... | ... |
@@ -222,7 +222,6 @@ github.com/go-stack/stack v1.6.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/me |
| 222 | 222 |
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= |
| 223 | 223 |
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= |
| 224 | 224 |
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= |
| 225 |
-github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= |
|
| 226 | 225 |
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= |
| 227 | 226 |
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= |
| 228 | 227 |
github.com/gofrs/flock v0.12.1 h1:MTLVXXHf8ekldpJk3AKicLij9MdwOWkZ+a/jHHZby9E= |
| ... | ... |
@@ -13,7 +13,6 @@ |
| 13 | 13 |
// limitations under the License. |
| 14 | 14 |
|
| 15 | 15 |
//go:build !windows |
| 16 |
-// +build !windows |
|
| 17 | 16 |
|
| 18 | 17 |
// Package activation implements primitives for systemd socket activation. |
| 19 | 18 |
package activation |
| ... | ... |
@@ -38,9 +37,12 @@ const ( |
| 38 | 38 |
// fd usage and to avoid leaking environment flags to child processes. |
| 39 | 39 |
func Files(unsetEnv bool) []*os.File {
|
| 40 | 40 |
if unsetEnv {
|
| 41 |
- defer os.Unsetenv("LISTEN_PID")
|
|
| 42 |
- defer os.Unsetenv("LISTEN_FDS")
|
|
| 43 |
- defer os.Unsetenv("LISTEN_FDNAMES")
|
|
| 41 |
+ defer func() {
|
|
| 42 |
+ // Unsetenv implementation for unix never returns an error. |
|
| 43 |
+ _ = os.Unsetenv("LISTEN_PID")
|
|
| 44 |
+ _ = os.Unsetenv("LISTEN_FDS")
|
|
| 45 |
+ _ = os.Unsetenv("LISTEN_FDNAMES")
|
|
| 46 |
+ }() |
|
| 44 | 47 |
} |
| 45 | 48 |
|
| 46 | 49 |
pid, err := strconv.Atoi(os.Getenv("LISTEN_PID"))
|
| ... | ... |
@@ -12,7 +12,8 @@ |
| 12 | 12 |
// See the License for the specific language governing permissions and |
| 13 | 13 |
// limitations under the License. |
| 14 | 14 |
|
| 15 |
-// Integration with the systemd D-Bus API. See http://www.freedesktop.org/wiki/Software/systemd/dbus/ |
|
| 15 |
+// Package dbus provides integration with the systemd D-Bus API. |
|
| 16 |
+// See http://www.freedesktop.org/wiki/Software/systemd/dbus/ |
|
| 16 | 17 |
package dbus |
| 17 | 18 |
|
| 18 | 19 |
import ( |
| ... | ... |
@@ -24,15 +24,15 @@ import ( |
| 24 | 24 |
"github.com/godbus/dbus/v5" |
| 25 | 25 |
) |
| 26 | 26 |
|
| 27 |
-// Who can be used to specify which process to kill in the unit via the KillUnitWithTarget API |
|
| 27 |
+// Who specifies which process to send a signal to via the [KillUnitWithTarget]. |
|
| 28 | 28 |
type Who string |
| 29 | 29 |
|
| 30 | 30 |
const ( |
| 31 |
- // All sends the signal to all processes in the unit |
|
| 31 |
+ // All sends the signal to all processes in the unit. |
|
| 32 | 32 |
All Who = "all" |
| 33 |
- // Main sends the signal to the main process of the unit |
|
| 33 |
+ // Main sends the signal to the main process of the unit. |
|
| 34 | 34 |
Main Who = "main" |
| 35 |
- // Control sends the signal to the control process of the unit |
|
| 35 |
+ // Control sends the signal to the control process of the unit. |
|
| 36 | 36 |
Control Who = "control" |
| 37 | 37 |
) |
| 38 | 38 |
|
| ... | ... |
@@ -41,7 +41,8 @@ func (c *Conn) jobComplete(signal *dbus.Signal) {
|
| 41 | 41 |
var job dbus.ObjectPath |
| 42 | 42 |
var unit string |
| 43 | 43 |
var result string |
| 44 |
- dbus.Store(signal.Body, &id, &job, &unit, &result) |
|
| 44 |
+ |
|
| 45 |
+ _ = dbus.Store(signal.Body, &id, &job, &unit, &result) |
|
| 45 | 46 |
c.jobListener.Lock() |
| 46 | 47 |
out, ok := c.jobListener.jobs[job] |
| 47 | 48 |
if ok {
|
| ... | ... |
@@ -51,7 +52,7 @@ func (c *Conn) jobComplete(signal *dbus.Signal) {
|
| 51 | 51 |
c.jobListener.Unlock() |
| 52 | 52 |
} |
| 53 | 53 |
|
| 54 |
-func (c *Conn) startJob(ctx context.Context, ch chan<- string, job string, args ...interface{}) (int, error) {
|
|
| 54 |
+func (c *Conn) startJob(ctx context.Context, ch chan<- string, job string, args ...any) (int, error) {
|
|
| 55 | 55 |
if ch != nil {
|
| 56 | 56 |
c.jobListener.Lock() |
| 57 | 57 |
defer c.jobListener.Unlock() |
| ... | ... |
@@ -102,6 +103,10 @@ func (c *Conn) StartUnit(name string, mode string, ch chan<- string) (int, error |
| 102 | 102 |
// has been removed too. skipped indicates that a job was skipped because it |
| 103 | 103 |
// didn't apply to the units current state. |
| 104 | 104 |
// |
| 105 |
+// Important: It is the caller's responsibility to unblock the provided channel write, |
|
| 106 |
+// either by reading from the channel or by using a buffered channel. Until the write |
|
| 107 |
+// is unblocked, the Conn object cannot handle other jobs. |
|
| 108 |
+// |
|
| 105 | 109 |
// If no error occurs, the ID of the underlying systemd job will be returned. There |
| 106 | 110 |
// does exist the possibility for no error to be returned, but for the returned job |
| 107 | 111 |
// ID to be 0. In this case, the actual underlying ID is not 0 and this datapoint |
| ... | ... |
@@ -192,19 +197,21 @@ func (c *Conn) StartTransientUnitContext(ctx context.Context, name string, mode |
| 192 | 192 |
return c.startJob(ctx, ch, "org.freedesktop.systemd1.Manager.StartTransientUnit", name, mode, properties, make([]PropertyCollection, 0)) |
| 193 | 193 |
} |
| 194 | 194 |
|
| 195 |
-// Deprecated: use KillUnitContext instead. |
|
| 195 |
+// Deprecated: use [KillUnitWithTarget] instead. |
|
| 196 | 196 |
func (c *Conn) KillUnit(name string, signal int32) {
|
| 197 | 197 |
c.KillUnitContext(context.Background(), name, signal) |
| 198 | 198 |
} |
| 199 | 199 |
|
| 200 | 200 |
// KillUnitContext takes the unit name and a UNIX signal number to send. |
| 201 | 201 |
// All of the unit's processes are killed. |
| 202 |
+// |
|
| 203 |
+// Deprecated: use [KillUnitWithTarget] instead, with target argument set to [All]. |
|
| 202 | 204 |
func (c *Conn) KillUnitContext(ctx context.Context, name string, signal int32) {
|
| 203 |
- c.KillUnitWithTarget(ctx, name, All, signal) |
|
| 205 |
+ _ = c.KillUnitWithTarget(ctx, name, All, signal) |
|
| 204 | 206 |
} |
| 205 | 207 |
|
| 206 |
-// KillUnitWithTarget is like KillUnitContext, but allows you to specify which |
|
| 207 |
-// process in the unit to send the signal to. |
|
| 208 |
+// KillUnitWithTarget sends a signal to the specified unit. |
|
| 209 |
+// The target argument can be one of [All], [Main], or [Control]. |
|
| 208 | 210 |
func (c *Conn) KillUnitWithTarget(ctx context.Context, name string, target Who, signal int32) error {
|
| 209 | 211 |
return c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.KillUnit", 0, name, string(target), signal).Store() |
| 210 | 212 |
} |
| ... | ... |
@@ -240,7 +247,7 @@ func (c *Conn) SystemStateContext(ctx context.Context) (*Property, error) {
|
| 240 | 240 |
} |
| 241 | 241 |
|
| 242 | 242 |
// getProperties takes the unit path and returns all of its dbus object properties, for the given dbus interface. |
| 243 |
-func (c *Conn) getProperties(ctx context.Context, path dbus.ObjectPath, dbusInterface string) (map[string]interface{}, error) {
|
|
| 243 |
+func (c *Conn) getProperties(ctx context.Context, path dbus.ObjectPath, dbusInterface string) (map[string]any, error) {
|
|
| 244 | 244 |
var err error |
| 245 | 245 |
var props map[string]dbus.Variant |
| 246 | 246 |
|
| ... | ... |
@@ -254,7 +261,7 @@ func (c *Conn) getProperties(ctx context.Context, path dbus.ObjectPath, dbusInte |
| 254 | 254 |
return nil, err |
| 255 | 255 |
} |
| 256 | 256 |
|
| 257 |
- out := make(map[string]interface{}, len(props))
|
|
| 257 |
+ out := make(map[string]any, len(props)) |
|
| 258 | 258 |
for k, v := range props {
|
| 259 | 259 |
out[k] = v.Value() |
| 260 | 260 |
} |
| ... | ... |
@@ -263,36 +270,36 @@ func (c *Conn) getProperties(ctx context.Context, path dbus.ObjectPath, dbusInte |
| 263 | 263 |
} |
| 264 | 264 |
|
| 265 | 265 |
// Deprecated: use GetUnitPropertiesContext instead. |
| 266 |
-func (c *Conn) GetUnitProperties(unit string) (map[string]interface{}, error) {
|
|
| 266 |
+func (c *Conn) GetUnitProperties(unit string) (map[string]any, error) {
|
|
| 267 | 267 |
return c.GetUnitPropertiesContext(context.Background(), unit) |
| 268 | 268 |
} |
| 269 | 269 |
|
| 270 | 270 |
// GetUnitPropertiesContext takes the (unescaped) unit name and returns all of |
| 271 | 271 |
// its dbus object properties. |
| 272 |
-func (c *Conn) GetUnitPropertiesContext(ctx context.Context, unit string) (map[string]interface{}, error) {
|
|
| 272 |
+func (c *Conn) GetUnitPropertiesContext(ctx context.Context, unit string) (map[string]any, error) {
|
|
| 273 | 273 |
path := unitPath(unit) |
| 274 | 274 |
return c.getProperties(ctx, path, "org.freedesktop.systemd1.Unit") |
| 275 | 275 |
} |
| 276 | 276 |
|
| 277 | 277 |
// Deprecated: use GetUnitPathPropertiesContext instead. |
| 278 |
-func (c *Conn) GetUnitPathProperties(path dbus.ObjectPath) (map[string]interface{}, error) {
|
|
| 278 |
+func (c *Conn) GetUnitPathProperties(path dbus.ObjectPath) (map[string]any, error) {
|
|
| 279 | 279 |
return c.GetUnitPathPropertiesContext(context.Background(), path) |
| 280 | 280 |
} |
| 281 | 281 |
|
| 282 | 282 |
// GetUnitPathPropertiesContext takes the (escaped) unit path and returns all |
| 283 | 283 |
// of its dbus object properties. |
| 284 |
-func (c *Conn) GetUnitPathPropertiesContext(ctx context.Context, path dbus.ObjectPath) (map[string]interface{}, error) {
|
|
| 284 |
+func (c *Conn) GetUnitPathPropertiesContext(ctx context.Context, path dbus.ObjectPath) (map[string]any, error) {
|
|
| 285 | 285 |
return c.getProperties(ctx, path, "org.freedesktop.systemd1.Unit") |
| 286 | 286 |
} |
| 287 | 287 |
|
| 288 | 288 |
// Deprecated: use GetAllPropertiesContext instead. |
| 289 |
-func (c *Conn) GetAllProperties(unit string) (map[string]interface{}, error) {
|
|
| 289 |
+func (c *Conn) GetAllProperties(unit string) (map[string]any, error) {
|
|
| 290 | 290 |
return c.GetAllPropertiesContext(context.Background(), unit) |
| 291 | 291 |
} |
| 292 | 292 |
|
| 293 | 293 |
// GetAllPropertiesContext takes the (unescaped) unit name and returns all of |
| 294 | 294 |
// its dbus object properties. |
| 295 |
-func (c *Conn) GetAllPropertiesContext(ctx context.Context, unit string) (map[string]interface{}, error) {
|
|
| 295 |
+func (c *Conn) GetAllPropertiesContext(ctx context.Context, unit string) (map[string]any, error) {
|
|
| 296 | 296 |
path := unitPath(unit) |
| 297 | 297 |
return c.getProperties(ctx, path, "") |
| 298 | 298 |
} |
| ... | ... |
@@ -331,20 +338,20 @@ func (c *Conn) GetServiceProperty(service string, propertyName string) (*Propert |
| 331 | 331 |
return c.GetServicePropertyContext(context.Background(), service, propertyName) |
| 332 | 332 |
} |
| 333 | 333 |
|
| 334 |
-// GetServiceProperty returns property for given service name and property name. |
|
| 334 |
+// GetServicePropertyContext returns property for given service name and property name. |
|
| 335 | 335 |
func (c *Conn) GetServicePropertyContext(ctx context.Context, service string, propertyName string) (*Property, error) {
|
| 336 | 336 |
return c.getProperty(ctx, service, "org.freedesktop.systemd1.Service", propertyName) |
| 337 | 337 |
} |
| 338 | 338 |
|
| 339 | 339 |
// Deprecated: use GetUnitTypePropertiesContext instead. |
| 340 |
-func (c *Conn) GetUnitTypeProperties(unit string, unitType string) (map[string]interface{}, error) {
|
|
| 340 |
+func (c *Conn) GetUnitTypeProperties(unit string, unitType string) (map[string]any, error) {
|
|
| 341 | 341 |
return c.GetUnitTypePropertiesContext(context.Background(), unit, unitType) |
| 342 | 342 |
} |
| 343 | 343 |
|
| 344 | 344 |
// GetUnitTypePropertiesContext returns the extra properties for a unit, specific to the unit type. |
| 345 | 345 |
// Valid values for unitType: Service, Socket, Target, Device, Mount, Automount, Snapshot, Timer, Swap, Path, Slice, Scope. |
| 346 | 346 |
// Returns "dbus.Error: Unknown interface" error if the unitType is not the correct type of the unit. |
| 347 |
-func (c *Conn) GetUnitTypePropertiesContext(ctx context.Context, unit string, unitType string) (map[string]interface{}, error) {
|
|
| 347 |
+func (c *Conn) GetUnitTypePropertiesContext(ctx context.Context, unit string, unitType string) (map[string]any, error) {
|
|
| 348 | 348 |
path := unitPath(unit) |
| 349 | 349 |
return c.getProperties(ctx, path, "org.freedesktop.systemd1."+unitType) |
| 350 | 350 |
} |
| ... | ... |
@@ -389,22 +396,22 @@ type UnitStatus struct {
|
| 389 | 389 |
JobPath dbus.ObjectPath // The job object path |
| 390 | 390 |
} |
| 391 | 391 |
|
| 392 |
-type storeFunc func(retvalues ...interface{}) error
|
|
| 392 |
+type storeFunc func(retvalues ...any) error |
|
| 393 | 393 |
|
| 394 | 394 |
func (c *Conn) listUnitsInternal(f storeFunc) ([]UnitStatus, error) {
|
| 395 |
- result := make([][]interface{}, 0)
|
|
| 395 |
+ result := make([][]any, 0) |
|
| 396 | 396 |
err := f(&result) |
| 397 | 397 |
if err != nil {
|
| 398 | 398 |
return nil, err |
| 399 | 399 |
} |
| 400 | 400 |
|
| 401 |
- resultInterface := make([]interface{}, len(result))
|
|
| 401 |
+ resultInterface := make([]any, len(result)) |
|
| 402 | 402 |
for i := range result {
|
| 403 | 403 |
resultInterface[i] = result[i] |
| 404 | 404 |
} |
| 405 | 405 |
|
| 406 | 406 |
status := make([]UnitStatus, len(result)) |
| 407 |
- statusInterface := make([]interface{}, len(status))
|
|
| 407 |
+ statusInterface := make([]any, len(status)) |
|
| 408 | 408 |
for i := range status {
|
| 409 | 409 |
statusInterface[i] = &status[i] |
| 410 | 410 |
} |
| ... | ... |
@@ -499,19 +506,19 @@ type UnitFile struct {
|
| 499 | 499 |
} |
| 500 | 500 |
|
| 501 | 501 |
func (c *Conn) listUnitFilesInternal(f storeFunc) ([]UnitFile, error) {
|
| 502 |
- result := make([][]interface{}, 0)
|
|
| 502 |
+ result := make([][]any, 0) |
|
| 503 | 503 |
err := f(&result) |
| 504 | 504 |
if err != nil {
|
| 505 | 505 |
return nil, err |
| 506 | 506 |
} |
| 507 | 507 |
|
| 508 |
- resultInterface := make([]interface{}, len(result))
|
|
| 508 |
+ resultInterface := make([]any, len(result)) |
|
| 509 | 509 |
for i := range result {
|
| 510 | 510 |
resultInterface[i] = result[i] |
| 511 | 511 |
} |
| 512 | 512 |
|
| 513 | 513 |
files := make([]UnitFile, len(result)) |
| 514 |
- fileInterface := make([]interface{}, len(files))
|
|
| 514 |
+ fileInterface := make([]any, len(files)) |
|
| 515 | 515 |
for i := range files {
|
| 516 | 516 |
fileInterface[i] = &files[i] |
| 517 | 517 |
} |
| ... | ... |
@@ -529,7 +536,7 @@ func (c *Conn) ListUnitFiles() ([]UnitFile, error) {
|
| 529 | 529 |
return c.ListUnitFilesContext(context.Background()) |
| 530 | 530 |
} |
| 531 | 531 |
|
| 532 |
-// ListUnitFiles returns an array of all available units on disk. |
|
| 532 |
+// ListUnitFilesContext returns an array of all available units on disk. |
|
| 533 | 533 |
func (c *Conn) ListUnitFilesContext(ctx context.Context) ([]UnitFile, error) {
|
| 534 | 534 |
return c.listUnitFilesInternal(c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.ListUnitFiles", 0).Store) |
| 535 | 535 |
} |
| ... | ... |
@@ -569,19 +576,19 @@ func (c *Conn) LinkUnitFiles(files []string, runtime bool, force bool) ([]LinkUn |
| 569 | 569 |
// or unlink), the file name of the symlink and the destination of the |
| 570 | 570 |
// symlink. |
| 571 | 571 |
func (c *Conn) LinkUnitFilesContext(ctx context.Context, files []string, runtime bool, force bool) ([]LinkUnitFileChange, error) {
|
| 572 |
- result := make([][]interface{}, 0)
|
|
| 572 |
+ result := make([][]any, 0) |
|
| 573 | 573 |
err := c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.LinkUnitFiles", 0, files, runtime, force).Store(&result) |
| 574 | 574 |
if err != nil {
|
| 575 | 575 |
return nil, err |
| 576 | 576 |
} |
| 577 | 577 |
|
| 578 |
- resultInterface := make([]interface{}, len(result))
|
|
| 578 |
+ resultInterface := make([]any, len(result)) |
|
| 579 | 579 |
for i := range result {
|
| 580 | 580 |
resultInterface[i] = result[i] |
| 581 | 581 |
} |
| 582 | 582 |
|
| 583 | 583 |
changes := make([]LinkUnitFileChange, len(result)) |
| 584 |
- changesInterface := make([]interface{}, len(changes))
|
|
| 584 |
+ changesInterface := make([]any, len(changes)) |
|
| 585 | 585 |
for i := range changes {
|
| 586 | 586 |
changesInterface[i] = &changes[i] |
| 587 | 587 |
} |
| ... | ... |
@@ -618,19 +625,19 @@ func (c *Conn) EnableUnitFiles(files []string, runtime bool, force bool) (bool, |
| 618 | 618 |
func (c *Conn) EnableUnitFilesContext(ctx context.Context, files []string, runtime bool, force bool) (bool, []EnableUnitFileChange, error) {
|
| 619 | 619 |
var carries_install_info bool |
| 620 | 620 |
|
| 621 |
- result := make([][]interface{}, 0)
|
|
| 621 |
+ result := make([][]any, 0) |
|
| 622 | 622 |
err := c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.EnableUnitFiles", 0, files, runtime, force).Store(&carries_install_info, &result) |
| 623 | 623 |
if err != nil {
|
| 624 | 624 |
return false, nil, err |
| 625 | 625 |
} |
| 626 | 626 |
|
| 627 |
- resultInterface := make([]interface{}, len(result))
|
|
| 627 |
+ resultInterface := make([]any, len(result)) |
|
| 628 | 628 |
for i := range result {
|
| 629 | 629 |
resultInterface[i] = result[i] |
| 630 | 630 |
} |
| 631 | 631 |
|
| 632 | 632 |
changes := make([]EnableUnitFileChange, len(result)) |
| 633 |
- changesInterface := make([]interface{}, len(changes))
|
|
| 633 |
+ changesInterface := make([]any, len(changes)) |
|
| 634 | 634 |
for i := range changes {
|
| 635 | 635 |
changesInterface[i] = &changes[i] |
| 636 | 636 |
} |
| ... | ... |
@@ -667,19 +674,19 @@ func (c *Conn) DisableUnitFiles(files []string, runtime bool) ([]DisableUnitFile |
| 667 | 667 |
// symlink or unlink), the file name of the symlink and the destination of the |
| 668 | 668 |
// symlink. |
| 669 | 669 |
func (c *Conn) DisableUnitFilesContext(ctx context.Context, files []string, runtime bool) ([]DisableUnitFileChange, error) {
|
| 670 |
- result := make([][]interface{}, 0)
|
|
| 670 |
+ result := make([][]any, 0) |
|
| 671 | 671 |
err := c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.DisableUnitFiles", 0, files, runtime).Store(&result) |
| 672 | 672 |
if err != nil {
|
| 673 | 673 |
return nil, err |
| 674 | 674 |
} |
| 675 | 675 |
|
| 676 |
- resultInterface := make([]interface{}, len(result))
|
|
| 676 |
+ resultInterface := make([]any, len(result)) |
|
| 677 | 677 |
for i := range result {
|
| 678 | 678 |
resultInterface[i] = result[i] |
| 679 | 679 |
} |
| 680 | 680 |
|
| 681 | 681 |
changes := make([]DisableUnitFileChange, len(result)) |
| 682 |
- changesInterface := make([]interface{}, len(changes))
|
|
| 682 |
+ changesInterface := make([]any, len(changes)) |
|
| 683 | 683 |
for i := range changes {
|
| 684 | 684 |
changesInterface[i] = &changes[i] |
| 685 | 685 |
} |
| ... | ... |
@@ -713,19 +720,19 @@ func (c *Conn) MaskUnitFiles(files []string, runtime bool, force bool) ([]MaskUn |
| 713 | 713 |
// runtime only (true, /run/systemd/..), or persistently (false, |
| 714 | 714 |
// /etc/systemd/..). |
| 715 | 715 |
func (c *Conn) MaskUnitFilesContext(ctx context.Context, files []string, runtime bool, force bool) ([]MaskUnitFileChange, error) {
|
| 716 |
- result := make([][]interface{}, 0)
|
|
| 716 |
+ result := make([][]any, 0) |
|
| 717 | 717 |
err := c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.MaskUnitFiles", 0, files, runtime, force).Store(&result) |
| 718 | 718 |
if err != nil {
|
| 719 | 719 |
return nil, err |
| 720 | 720 |
} |
| 721 | 721 |
|
| 722 |
- resultInterface := make([]interface{}, len(result))
|
|
| 722 |
+ resultInterface := make([]any, len(result)) |
|
| 723 | 723 |
for i := range result {
|
| 724 | 724 |
resultInterface[i] = result[i] |
| 725 | 725 |
} |
| 726 | 726 |
|
| 727 | 727 |
changes := make([]MaskUnitFileChange, len(result)) |
| 728 |
- changesInterface := make([]interface{}, len(changes))
|
|
| 728 |
+ changesInterface := make([]any, len(changes)) |
|
| 729 | 729 |
for i := range changes {
|
| 730 | 730 |
changesInterface[i] = &changes[i] |
| 731 | 731 |
} |
| ... | ... |
@@ -757,19 +764,19 @@ func (c *Conn) UnmaskUnitFiles(files []string, runtime bool) ([]UnmaskUnitFileCh |
| 757 | 757 |
// for runtime only (true, /run/systemd/..), or persistently (false, |
| 758 | 758 |
// /etc/systemd/..). |
| 759 | 759 |
func (c *Conn) UnmaskUnitFilesContext(ctx context.Context, files []string, runtime bool) ([]UnmaskUnitFileChange, error) {
|
| 760 |
- result := make([][]interface{}, 0)
|
|
| 760 |
+ result := make([][]any, 0) |
|
| 761 | 761 |
err := c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.UnmaskUnitFiles", 0, files, runtime).Store(&result) |
| 762 | 762 |
if err != nil {
|
| 763 | 763 |
return nil, err |
| 764 | 764 |
} |
| 765 | 765 |
|
| 766 |
- resultInterface := make([]interface{}, len(result))
|
|
| 766 |
+ resultInterface := make([]any, len(result)) |
|
| 767 | 767 |
for i := range result {
|
| 768 | 768 |
resultInterface[i] = result[i] |
| 769 | 769 |
} |
| 770 | 770 |
|
| 771 | 771 |
changes := make([]UnmaskUnitFileChange, len(result)) |
| 772 |
- changesInterface := make([]interface{}, len(changes))
|
|
| 772 |
+ changesInterface := make([]any, len(changes)) |
|
| 773 | 773 |
for i := range changes {
|
| 774 | 774 |
changesInterface[i] = &changes[i] |
| 775 | 775 |
} |
| ... | ... |
@@ -829,18 +836,18 @@ func (c *Conn) ListJobsContext(ctx context.Context) ([]JobStatus, error) {
|
| 829 | 829 |
} |
| 830 | 830 |
|
| 831 | 831 |
func (c *Conn) listJobsInternal(ctx context.Context) ([]JobStatus, error) {
|
| 832 |
- result := make([][]interface{}, 0)
|
|
| 832 |
+ result := make([][]any, 0) |
|
| 833 | 833 |
if err := c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.ListJobs", 0).Store(&result); err != nil {
|
| 834 | 834 |
return nil, err |
| 835 | 835 |
} |
| 836 | 836 |
|
| 837 |
- resultInterface := make([]interface{}, len(result))
|
|
| 837 |
+ resultInterface := make([]any, len(result)) |
|
| 838 | 838 |
for i := range result {
|
| 839 | 839 |
resultInterface[i] = result[i] |
| 840 | 840 |
} |
| 841 | 841 |
|
| 842 | 842 |
status := make([]JobStatus, len(result)) |
| 843 |
- statusInterface := make([]interface{}, len(status))
|
|
| 843 |
+ statusInterface := make([]any, len(status)) |
|
| 844 | 844 |
for i := range status {
|
| 845 | 845 |
statusInterface[i] = &status[i] |
| 846 | 846 |
} |
| ... | ... |
@@ -852,13 +859,18 @@ func (c *Conn) listJobsInternal(ctx context.Context) ([]JobStatus, error) {
|
| 852 | 852 |
return status, nil |
| 853 | 853 |
} |
| 854 | 854 |
|
| 855 |
-// Freeze the cgroup associated with the unit. |
|
| 856 |
-// Note that FreezeUnit and ThawUnit are only supported on systems running with cgroup v2. |
|
| 855 |
+// FreezeUnit freezes the cgroup associated with the unit. |
|
| 856 |
+// Note that FreezeUnit and [ThawUnit] are only supported on systems running with cgroup v2. |
|
| 857 | 857 |
func (c *Conn) FreezeUnit(ctx context.Context, unit string) error {
|
| 858 | 858 |
return c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.FreezeUnit", 0, unit).Store() |
| 859 | 859 |
} |
| 860 | 860 |
|
| 861 |
-// Unfreeze the cgroup associated with the unit. |
|
| 861 |
+// ThawUnit unfreezes the cgroup associated with the unit. |
|
| 862 | 862 |
func (c *Conn) ThawUnit(ctx context.Context, unit string) error {
|
| 863 | 863 |
return c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.ThawUnit", 0, unit).Store() |
| 864 | 864 |
} |
| 865 |
+ |
|
| 866 |
+// AttachProcessesToUnit moves existing processes, identified by pids, into an existing systemd unit. |
|
| 867 |
+func (c *Conn) AttachProcessesToUnit(ctx context.Context, unit, subcgroup string, pids []uint32) error {
|
|
| 868 |
+ return c.sysobj.CallWithContext(ctx, "org.freedesktop.systemd1.Manager.AttachProcessesToUnit", 0, unit, subcgroup, pids).Store() |
|
| 869 |
+} |
| ... | ... |
@@ -70,7 +70,7 @@ func (c *Conn) dispatch() {
|
| 70 | 70 |
switch signal.Name {
|
| 71 | 71 |
case "org.freedesktop.systemd1.Manager.JobRemoved": |
| 72 | 72 |
unitName := signal.Body[2].(string) |
| 73 |
- c.sysobj.Call("org.freedesktop.systemd1.Manager.GetUnit", 0, unitName).Store(&unitPath)
|
|
| 73 |
+ _ = c.sysobj.Call("org.freedesktop.systemd1.Manager.GetUnit", 0, unitName).Store(&unitPath)
|
|
| 74 | 74 |
case "org.freedesktop.systemd1.Manager.UnitNew": |
| 75 | 75 |
unitPath = signal.Body[1].(dbus.ObjectPath) |
| 76 | 76 |
case "org.freedesktop.DBus.Properties.PropertiesChanged": |
| ... | ... |
@@ -262,7 +262,7 @@ func (c *Conn) shouldIgnore(path dbus.ObjectPath) bool {
|
| 262 | 262 |
return ok && t >= time.Now().UnixNano() |
| 263 | 263 |
} |
| 264 | 264 |
|
| 265 |
-func (c *Conn) updateIgnore(path dbus.ObjectPath, info map[string]interface{}) {
|
|
| 265 |
+func (c *Conn) updateIgnore(path dbus.ObjectPath, info map[string]any) {
|
|
| 266 | 266 |
loadState, ok := info["LoadState"].(string) |
| 267 | 267 |
if !ok {
|
| 268 | 268 |
return |
| ... | ... |
@@ -40,8 +40,8 @@ func (s *SubscriptionSet) Subscribe() (<-chan map[string]*UnitStatus, <-chan err |
| 40 | 40 |
} |
| 41 | 41 |
|
| 42 | 42 |
// NewSubscriptionSet returns a new subscription set. |
| 43 |
-func (conn *Conn) NewSubscriptionSet() *SubscriptionSet {
|
|
| 44 |
- return &SubscriptionSet{newSet(), conn}
|
|
| 43 |
+func (c *Conn) NewSubscriptionSet() *SubscriptionSet {
|
|
| 44 |
+ return &SubscriptionSet{newSet(), c}
|
|
| 45 | 45 |
} |
| 46 | 46 |
|
| 47 | 47 |
// mismatchUnitStatus returns true if the provided UnitStatus objects |
| ... | ... |
@@ -41,6 +41,6 @@ const ( |
| 41 | 41 |
) |
| 42 | 42 |
|
| 43 | 43 |
// Print prints a message to the local systemd journal using Send(). |
| 44 |
-func Print(priority Priority, format string, a ...interface{}) error {
|
|
| 44 |
+func Print(priority Priority, format string, a ...any) error {
|
|
| 45 | 45 |
return Send(fmt.Sprintf(format, a...), priority, nil) |
| 46 | 46 |
} |
| ... | ... |
@@ -13,7 +13,6 @@ |
| 13 | 13 |
// limitations under the License. |
| 14 | 14 |
|
| 15 | 15 |
//go:build !windows |
| 16 |
-// +build !windows |
|
| 17 | 16 |
|
| 18 | 17 |
// Package journal provides write bindings to the local systemd journal. |
| 19 | 18 |
// It is implemented in pure Go and connects to the journal directly over its |
| ... | ... |
@@ -31,7 +30,6 @@ import ( |
| 31 | 31 |
"errors" |
| 32 | 32 |
"fmt" |
| 33 | 33 |
"io" |
| 34 |
- "io/ioutil" |
|
| 35 | 34 |
"net" |
| 36 | 35 |
"os" |
| 37 | 36 |
"strconv" |
| ... | ... |
@@ -194,7 +192,7 @@ func appendVariable(w io.Writer, name, value string) {
|
| 194 | 194 |
* - the data, followed by a newline |
| 195 | 195 |
*/ |
| 196 | 196 |
fmt.Fprintln(w, name) |
| 197 |
- binary.Write(w, binary.LittleEndian, uint64(len(value))) |
|
| 197 |
+ _ = binary.Write(w, binary.LittleEndian, uint64(len(value))) |
|
| 198 | 198 |
fmt.Fprintln(w, value) |
| 199 | 199 |
} else {
|
| 200 | 200 |
/* just write the variable and value all on one line */ |
| ... | ... |
@@ -214,7 +212,7 @@ func validVarName(name string) error {
|
| 214 | 214 |
} |
| 215 | 215 |
|
| 216 | 216 |
for _, c := range name {
|
| 217 |
- if !(('A' <= c && c <= 'Z') || ('0' <= c && c <= '9') || c == '_') {
|
|
| 217 |
+ if ('A' > c || c > 'Z') && ('0' > c || c > '9') && c != '_' {
|
|
| 218 | 218 |
return errors.New("Variable name contains invalid characters")
|
| 219 | 219 |
} |
| 220 | 220 |
} |
| ... | ... |
@@ -239,7 +237,7 @@ func isSocketSpaceError(err error) bool {
|
| 239 | 239 |
|
| 240 | 240 |
// tempFd creates a temporary, unlinked file under `/dev/shm`. |
| 241 | 241 |
func tempFd() (*os.File, error) {
|
| 242 |
- file, err := ioutil.TempFile("/dev/shm/", "journal.XXXXX")
|
|
| 242 |
+ file, err := os.CreateTemp("/dev/shm/", "journal.XXXXX")
|
|
| 243 | 243 |
if err != nil {
|
| 244 | 244 |
return nil, err |
| 245 | 245 |
} |
| ... | ... |
@@ -461,8 +461,8 @@ github.com/containernetworking/cni/pkg/version |
| 461 | 461 |
# github.com/containernetworking/plugins v1.7.1 |
| 462 | 462 |
## explicit; go 1.23.0 |
| 463 | 463 |
github.com/containernetworking/plugins/pkg/ns |
| 464 |
-# github.com/coreos/go-systemd/v22 v22.5.0 |
|
| 465 |
-## explicit; go 1.12 |
|
| 464 |
+# github.com/coreos/go-systemd/v22 v22.6.0 |
|
| 465 |
+## explicit; go 1.23 |
|
| 466 | 466 |
github.com/coreos/go-systemd/v22/activation |
| 467 | 467 |
github.com/coreos/go-systemd/v22/daemon |
| 468 | 468 |
github.com/coreos/go-systemd/v22/dbus |