(socketPath *string)
| 10 | ) |
| 11 | |
| 12 | func (*RootCmd) syncComplete(socketPath *string) *serpent.Command { |
| 13 | cmd := &serpent.Command{ |
| 14 | Use: "complete <unit>", |
| 15 | Short: "Mark a unit as complete", |
| 16 | Long: "Mark a unit as complete. Indicating to other units that it has completed its work. This allows units that depend on it to proceed with their startup.", |
| 17 | Handler: func(i *serpent.Invocation) error { |
| 18 | ctx := i.Context() |
| 19 | |
| 20 | if len(i.Args) != 1 { |
| 21 | return xerrors.New("exactly one unit name is required") |
| 22 | } |
| 23 | unit := unit.ID(i.Args[0]) |
| 24 | |
| 25 | opts := []agentsocket.Option{} |
| 26 | if *socketPath != "" { |
| 27 | opts = append(opts, agentsocket.WithPath(*socketPath)) |
| 28 | } |
| 29 | |
| 30 | client, err := agentsocket.NewClient(ctx, opts...) |
| 31 | if err != nil { |
| 32 | return xerrors.Errorf("connect to agent socket: %w", err) |
| 33 | } |
| 34 | defer client.Close() |
| 35 | |
| 36 | if err := client.SyncComplete(ctx, unit); err != nil { |
| 37 | return xerrors.Errorf("complete unit failed: %w", err) |
| 38 | } |
| 39 | |
| 40 | cliui.Info(i.Stdout, "Success") |
| 41 | |
| 42 | return nil |
| 43 | }, |
| 44 | } |
| 45 | |
| 46 | return cmd |
| 47 | } |
no test coverage detected