rearrange ctx parameter to match stdlib

This commit is contained in:
Tai Groot 2021-05-14 16:20:58 -07:00
parent 8bb696fb51
commit f9f44604e1
Signed by: taigrr
GPG Key ID: D00C269A87614812
2 changed files with 24 additions and 14 deletions

View File

@ -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)

View File

@ -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
}