2026-04-06 15:48:37 +05:30
|
|
|
// Copyright IBM Corp. 2020, 2026
|
2023-06-11 20:40:47 -04:00
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
|
|
2024-05-22 11:11:48 -07:00
|
|
|
package cache
|
2023-06-11 20:40:47 -04:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
"github.com/hashicorp/boundary/internal/cmd/base"
|
|
|
|
|
"github.com/hashicorp/boundary/internal/errors"
|
|
|
|
|
"github.com/posener/complete"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type StopCommand struct {
|
|
|
|
|
*base.Command
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *StopCommand) Synopsis() string {
|
2026-10-12 10:20:06 -07:00
|
|
|
return "Stop the Threshold cache"
|
2023-06-11 20:40:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *StopCommand) Help() string {
|
|
|
|
|
helpText := `
|
2026-10-12 10:20:06 -07:00
|
|
|
Usage: threshold cache stop
|
2023-06-11 20:40:47 -04:00
|
|
|
|
2024-05-22 11:11:48 -07:00
|
|
|
Stop a cache:
|
2023-06-11 20:40:47 -04:00
|
|
|
|
2026-10-12 10:20:06 -07:00
|
|
|
$ threshold cache stop
|
2023-06-11 20:40:47 -04:00
|
|
|
|
|
|
|
|
For a full list of examples, please see the documentation.
|
|
|
|
|
|
|
|
|
|
` + c.Flags().Help()
|
|
|
|
|
return strings.TrimSpace(helpText)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *StopCommand) Flags() *base.FlagSets {
|
2024-01-26 15:56:41 -08:00
|
|
|
set := c.FlagSet(base.FlagSetNone)
|
2023-06-11 20:40:47 -04:00
|
|
|
return set
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *StopCommand) AutocompleteArgs() complete.Predictor {
|
|
|
|
|
return complete.PredictNothing
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *StopCommand) AutocompleteFlags() complete.Flags {
|
|
|
|
|
return c.Flags().Completions()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *StopCommand) Run(args []string) int {
|
|
|
|
|
ctx, cancel := context.WithCancel(c.Context)
|
|
|
|
|
c.Context = ctx
|
|
|
|
|
c.ContextCancel = cancel
|
|
|
|
|
|
|
|
|
|
f := c.Flags()
|
|
|
|
|
if err := f.Parse(args); err != nil {
|
|
|
|
|
c.PrintCliError(err)
|
|
|
|
|
return base.CommandUserError
|
|
|
|
|
}
|
|
|
|
|
if err := c.stop(c.Context); err != nil {
|
|
|
|
|
if errors.Match(errors.T(errors.NotFound), err) {
|
2024-05-22 11:11:48 -07:00
|
|
|
c.PrintCliError(errCacheNotRunning)
|
2023-06-11 20:40:47 -04:00
|
|
|
} else {
|
|
|
|
|
c.PrintCliError(err)
|
|
|
|
|
}
|
|
|
|
|
return base.CommandUserError
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return base.CommandSuccess
|
|
|
|
|
}
|