Files
threshold/internal/clientcache/cmd/cache/stop.go
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

70 lines
1.4 KiB
Go
Raw Normal View History

// 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 {
return "Stop the Threshold cache"
2023-06-11 20:40:47 -04:00
}
func (c *StopCommand) Help() string {
helpText := `
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
$ 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 {
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
}