Private
(cmd *cobra.Command, args []string)
| 28 | // Private |
| 29 | |
| 30 | func (b *backgroundUninstallCommand) run(cmd *cobra.Command, args []string) error { |
| 31 | if os.Getuid() != 0 { |
| 32 | return fmt.Errorf("must be run as root") |
| 33 | } |
| 34 | |
| 35 | ctx := context.Background() |
| 36 | namespace := namespaceFlag(cmd) |
| 37 | |
| 38 | svc, err := service.New() |
| 39 | if err != nil { |
| 40 | return err |
| 41 | } |
| 42 | |
| 43 | serviceName := namespace + backgroundServiceSuffix |
| 44 | |
| 45 | if !svc.IsInstalled(serviceName) { |
| 46 | fmt.Printf("Service %s is not installed\n", svc.ServiceName(serviceName)) |
| 47 | return nil |
| 48 | } |
| 49 | |
| 50 | if err := svc.Remove(ctx, serviceName); err != nil { |
| 51 | return fmt.Errorf("removing service: %w", err) |
| 52 | } |
| 53 | |
| 54 | fmt.Printf("Uninstalled %s\n", svc.ServiceName(serviceName)) |
| 55 | return nil |
| 56 | } |
nothing calls this directly
no test coverage detected