From f9f44604e1c9e8e1dd33c1c0e80177d1ad420ba1 Mon Sep 17 00:00:00 2001 From: Tai Groot Date: Fri, 14 May 2021 16:20:58 -0700 Subject: [PATCH] rearrange ctx parameter to match stdlib --- README.md | 10 +++++++++- systemctl.go | 28 +++++++++++++++------------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 4601fe6..76f7bd7 100644 --- a/README.md +++ b/README.md @@ -48,13 +48,21 @@ func main() { defer cancel() // Equivalent to `systemctl enable dhcpd` with a 10 second timeout - err := systemctl.Enable("dhcpd", ctx) + err := systemctl.Enable(ctx, "dhcpd") if err != nil { log.Fatalf("unable to enable unit %s: %v", "dhcpd", err) } } ``` +## License + +This project is licensed under the 0BSD License, written by [Rob Landley](https://github.com/landley). +As such, you may use this library without restriction or attribution, but please don't pass it off as your own. +Attribution, though not required, is appreciated. + +By contributing, you agree all code submitted also falls under the License. + ## External resources - [Official systemctl documentation](https://www.man7.org/linux/man-pages/man1/systemctl.1.html) diff --git a/systemctl.go b/systemctl.go index 4667aa2..8c7e46f 100644 --- a/systemctl.go +++ b/systemctl.go @@ -1,66 +1,68 @@ package systemctl +import "context" + // TODO -func IsFailed(unit string) (bool, error) { +func IsFailed(ctx context.Context, unit string) (bool, error) { return false, nil } // TODO -func IsActive(unit string) (bool, error) { +func IsActive(ctx context.Context, unit string) (bool, error) { return false, nil } // TODO -func Status(unit string) (bool, error) { +func Status(ctx context.Context, unit string) (bool, error) { return false, nil } // TODO -func Restart(unit string) error { +func Restart(ctx context.Context, unit string) error { return nil } // TODO -func Start(unit string) error { +func Start(ctx context.Context, unit string) error { return nil } // TODO -func Stop(unit string) error { +func Stop(ctx context.Context, unit string) error { return nil } // TODO -func Enable(unit string) error { +func Enable(ctx context.Context, unit string) error { return nil } // TODO -func Disable(unit string) error { +func Disable(ctx context.Context, unit string) error { return nil } // TODO -func IsEnabled(unit string) (bool, error) { +func IsEnabled(ctx context.Context, unit string) (bool, error) { return false, nil } // TODO -func DaemonReload(unit string) error { +func DaemonReload(ctx context.Context, unit string) error { return nil } //TODO -func Show(unit string, property string) (string, error) { +func Show(ctx context.Context, unit string, property string) (string, error) { return "", nil } //TODO -func Mask(unit string) error { +func Mask(ctx context.Context, unit string) error { return nil } -func Unmask(unit string) error { +func Unmask(ctx context.Context, unit string) error { return nil }