From e64443c66fca15f114c554438b15f217febf2758 Mon Sep 17 00:00:00 2001 From: Johan Brandhorst-Satzkorn Date: Wed, 22 May 2024 11:11:48 -0700 Subject: [PATCH] Rename daemon CLI command to cache (#4808) * internal/cmd/wrapper: add deprecation wrapper The deprecation wrapper can be used to display a warning to callers when a command is deprecated. * all: rename daemon to cache Rename the boundary daemon command to boundary cache. This avoids confusion with future client/daemons. * changes daemon to cache in nav --------- Co-authored-by: Robin Beck --- CHANGELOG.md | 7 ++ .../cmd/{daemon => cache}/addtoken.go | 18 ++--- internal/clientcache/cmd/cache/cache.go | 60 +++++++++++++++ .../cmd/{daemon => cache}/logfile_test.go | 2 +- .../{daemon => cache}/pidfile_nonwindows.go | 6 +- .../cmd/{daemon => cache}/pidfile_test.go | 2 +- .../cmd/{daemon => cache}/pidfile_windows.go | 6 +- .../cmd/{daemon => cache}/start.go | 26 +++---- .../cmd/{daemon => cache}/status.go | 20 ++--- .../clientcache/cmd/{daemon => cache}/stop.go | 12 +-- .../cmd/{daemon => cache}/stop_nonwindows.go | 10 +-- .../cmd/{daemon => cache}/stop_windows.go | 14 ++-- .../cmd/{daemon => cache}/wrapper_register.go | 6 +- internal/clientcache/cmd/daemon/daemon.go | 57 --------------- internal/clientcache/cmd/search/search.go | 16 ++-- .../cache/repository_refresh_token.go | 2 +- internal/clientcache/internal/cache/search.go | 2 +- .../clientcache/internal/client/client.go | 2 +- internal/clientcache/internal/db/schema.sql | 2 +- internal/cmd/search_cmd_darwin.go | 73 ++++++++++++++++--- internal/cmd/search_cmd_freebsd.go | 73 ++++++++++++++++--- internal/cmd/search_cmd_linux.go | 73 ++++++++++++++++--- internal/cmd/search_cmd_windows.go | 73 ++++++++++++++++--- internal/cmd/wrapper/command_wrapper.go | 6 +- internal/cmd/wrapper/deprecation_wrapper.go | 41 +++++++++++ .../content/docs/api-clients/client-cache.mdx | 24 +++--- .../commands/{daemon => cache}/add-token.mdx | 18 ++--- website/content/docs/commands/cache/index.mdx | 43 +++++++++++ .../docs/commands/{daemon => cache}/start.mdx | 22 +++--- .../commands/{daemon => cache}/status.mdx | 18 ++--- website/content/docs/commands/cache/stop.mdx | 32 ++++++++ .../content/docs/commands/daemon/index.mdx | 43 ----------- website/content/docs/commands/daemon/stop.mdx | 32 -------- website/data/docs-nav-data.json | 12 +-- 34 files changed, 554 insertions(+), 299 deletions(-) rename internal/clientcache/cmd/{daemon => cache}/addtoken.go (94%) create mode 100644 internal/clientcache/cmd/cache/cache.go rename internal/clientcache/cmd/{daemon => cache}/logfile_test.go (99%) rename internal/clientcache/cmd/{daemon => cache}/pidfile_nonwindows.go (95%) rename internal/clientcache/cmd/{daemon => cache}/pidfile_test.go (98%) rename internal/clientcache/cmd/{daemon => cache}/pidfile_windows.go (97%) rename internal/clientcache/cmd/{daemon => cache}/start.go (94%) rename internal/clientcache/cmd/{daemon => cache}/status.go (92%) rename internal/clientcache/cmd/{daemon => cache}/stop.go (88%) rename internal/clientcache/cmd/{daemon => cache}/stop_nonwindows.go (71%) rename internal/clientcache/cmd/{daemon => cache}/stop_windows.go (77%) rename internal/clientcache/cmd/{daemon => cache}/wrapper_register.go (97%) delete mode 100644 internal/clientcache/cmd/daemon/daemon.go create mode 100644 internal/cmd/wrapper/deprecation_wrapper.go rename website/content/docs/commands/{daemon => cache}/add-token.mdx (84%) create mode 100644 website/content/docs/commands/cache/index.mdx rename website/content/docs/commands/{daemon => cache}/start.mdx (66%) rename website/content/docs/commands/{daemon => cache}/status.mdx (62%) create mode 100644 website/content/docs/commands/cache/stop.mdx delete mode 100644 website/content/docs/commands/daemon/index.mdx delete mode 100644 website/content/docs/commands/daemon/stop.mdx diff --git a/CHANGELOG.md b/CHANGELOG.md index 10248be60..f70bf4214 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ Canonical reference for changes, improvements, and bugfixes for Boundary. ## Next +### Deprecations/Changes + +* The `boundary daemon` command has been deprecated in favor of the new + `boundary cache` command. The behavior remains the same. The `boundary search` + command is unchanged. + ([PR](https://github.com/hashicorp/boundary/pull/4808)) + ### Bug Fixes * Fix a dead lock issue where the controller could get stuck with all of its diff --git a/internal/clientcache/cmd/daemon/addtoken.go b/internal/clientcache/cmd/cache/addtoken.go similarity index 94% rename from internal/clientcache/cmd/daemon/addtoken.go rename to internal/clientcache/cmd/cache/addtoken.go index 7d35e4602..62d858673 100644 --- a/internal/clientcache/cmd/daemon/addtoken.go +++ b/internal/clientcache/cmd/cache/addtoken.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: BUSL-1.1 -package daemon +package cache import ( "context" @@ -28,16 +28,16 @@ type AddTokenCommand struct { } func (c *AddTokenCommand) Synopsis() string { - return "Add an auth token to a running boundary daemon" + return "Add an auth token to a running boundary cache" } func (c *AddTokenCommand) Help() string { helpText := ` -Usage: boundary daemon add-token [options] +Usage: boundary cache add-token [options] - Add an auth token to the daemon: + Add an auth token to the cache: - $ boundary daemon add-token + $ boundary cache add-token For a full list of examples, please see the documentation. @@ -121,7 +121,7 @@ func (c *AddTokenCommand) Run(args []string) int { return base.CommandCliError } if apiErr != nil { - c.PrintApiError(apiErr, "Error from daemon when adding a token") + c.PrintApiError(apiErr, "Error from cache when adding a token") return base.CommandApiError } switch base.Format(c.UI) { @@ -130,13 +130,13 @@ func (c *AddTokenCommand) Run(args []string) int { return base.CommandCliError } case "table": - c.UI.Output("The daemon add-token operation completed successfully.") + c.UI.Output("The cache add-token operation completed successfully.") } return base.CommandSuccess } // Add builds the UpsertTokenRequest using the client's address and token, -// and trying to leverage the keyring. It then sends the request to the daemon. +// and trying to leverage the keyring. It then sends the request to the cache. // The passed in cli.Ui is used to print out any errors when looking up the // auth token from the keyring. This allows background operations calling this // method to pass in a silent UI to suppress any output. @@ -206,7 +206,7 @@ func addToken(ctx context.Context, daemonPath string, p *daemon.UpsertTokenReque } resp, err := c.Post(ctx, "/v1/tokens", p, opt...) if err != nil { - return nil, nil, fmt.Errorf("Error when sending request to the daemon: %w.", err) + return nil, nil, fmt.Errorf("Error when sending request to the cache: %w.", err) } apiErr, err := resp.Decode(nil) return resp, apiErr, err diff --git a/internal/clientcache/cmd/cache/cache.go b/internal/clientcache/cmd/cache/cache.go new file mode 100644 index 000000000..f4767ca59 --- /dev/null +++ b/internal/clientcache/cmd/cache/cache.go @@ -0,0 +1,60 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: BUSL-1.1 + +package cache + +import ( + "strings" + + "github.com/hashicorp/boundary/internal/cmd/base" + "github.com/mitchellh/cli" + "github.com/posener/complete" +) + +var ( + _ cli.Command = (*StartCommand)(nil) + _ cli.CommandAutocomplete = (*StartCommand)(nil) +) + +type CacheCommand struct { + *base.Command +} + +func (c *CacheCommand) Synopsis() string { + return "Manages the client side Boundary cache" +} + +func (c *CacheCommand) Help() string { + helpText := ` +Usage: boundary cache [sub command] [options] + + This command allows interacting with the Boundary cache. + + Start a cache: + + $ boundary cache start + + For a full list of examples, please see the documentation. + +` + return strings.TrimSpace(helpText) +} + +func (c *CacheCommand) Flags() *base.FlagSets { + return c.FlagSet(base.FlagSetNone) +} + +func (c *CacheCommand) AutocompleteArgs() complete.Predictor { + return complete.PredictNothing +} + +func (c *CacheCommand) AutocompleteFlags() complete.Flags { + return c.Flags().Completions() +} + +func (c *CacheCommand) Run(args []string) int { + if len(args) >= 2 && args[1] == "daemon" { + c.UI.Warn("The `boundary daemon` command is deprecated, use `boundary cache` instead") + } + return cli.RunResultHelp +} diff --git a/internal/clientcache/cmd/daemon/logfile_test.go b/internal/clientcache/cmd/cache/logfile_test.go similarity index 99% rename from internal/clientcache/cmd/daemon/logfile_test.go rename to internal/clientcache/cmd/cache/logfile_test.go index 4d6501f66..a92ebed34 100644 --- a/internal/clientcache/cmd/daemon/logfile_test.go +++ b/internal/clientcache/cmd/cache/logfile_test.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: BUSL-1.1 -package daemon +package cache import ( "bytes" diff --git a/internal/clientcache/cmd/daemon/pidfile_nonwindows.go b/internal/clientcache/cmd/cache/pidfile_nonwindows.go similarity index 95% rename from internal/clientcache/cmd/daemon/pidfile_nonwindows.go rename to internal/clientcache/cmd/cache/pidfile_nonwindows.go index 5f67b766a..b10bffa6a 100644 --- a/internal/clientcache/cmd/daemon/pidfile_nonwindows.go +++ b/internal/clientcache/cmd/cache/pidfile_nonwindows.go @@ -4,7 +4,7 @@ //go:build !windows // +build !windows -package daemon +package cache import ( "context" @@ -16,7 +16,7 @@ import ( ) func writePidFile(ctx context.Context, pidFile string) (pidCleanup, error) { - const op = "daemon.writePidFile" + const op = "cache.writePidFile" // Determine if we should clean up the file after we are done or if // it should stick around in the case of lock aquision error since this @@ -57,7 +57,7 @@ func writePidFile(ctx context.Context, pidFile string) (pidCleanup, error) { } func pidFileInUse(ctx context.Context, pidFile string) (*os.Process, error) { - const op = "daemon.pidFileInUse" + const op = "cache.pidFileInUse" if pidFile == "" { return nil, errors.New(ctx, errors.InvalidParameter, op, "pid filename is empty") } diff --git a/internal/clientcache/cmd/daemon/pidfile_test.go b/internal/clientcache/cmd/cache/pidfile_test.go similarity index 98% rename from internal/clientcache/cmd/daemon/pidfile_test.go rename to internal/clientcache/cmd/cache/pidfile_test.go index 333f119fc..abe64e34d 100644 --- a/internal/clientcache/cmd/daemon/pidfile_test.go +++ b/internal/clientcache/cmd/cache/pidfile_test.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: BUSL-1.1 -package daemon +package cache import ( "context" diff --git a/internal/clientcache/cmd/daemon/pidfile_windows.go b/internal/clientcache/cmd/cache/pidfile_windows.go similarity index 97% rename from internal/clientcache/cmd/daemon/pidfile_windows.go rename to internal/clientcache/cmd/cache/pidfile_windows.go index 38b02f46c..fadffea22 100644 --- a/internal/clientcache/cmd/daemon/pidfile_windows.go +++ b/internal/clientcache/cmd/cache/pidfile_windows.go @@ -4,7 +4,7 @@ //go:build windows // +build windows -package daemon +package cache import ( "bytes" @@ -20,7 +20,7 @@ import ( ) func writePidFile(ctx context.Context, pidFile string) (pidCleanup, error) { - const op = "daemon.writePidFile" + const op = "cache.writePidFile" // Create the file for writing, and set shared read so following processes // cannot open this file for writing. fd, err := windows.CreateFile(&(windows.StringToUTF16(pidFile)[0]), windows.GENERIC_WRITE, @@ -59,7 +59,7 @@ func writePidFile(ctx context.Context, pidFile string) (pidCleanup, error) { } func pidFileInUse(ctx context.Context, pidFile string) (*os.Process, error) { - const op = "daemon.pidFileInUse" + const op = "cache.pidFileInUse" if pidFile == "" { return nil, errors.New(ctx, errors.InvalidParameter, op, "pid filename is empty") } diff --git a/internal/clientcache/cmd/daemon/start.go b/internal/clientcache/cmd/cache/start.go similarity index 94% rename from internal/clientcache/cmd/daemon/start.go rename to internal/clientcache/cmd/cache/start.go index b4a5d5a5c..93a914c5f 100644 --- a/internal/clientcache/cmd/daemon/start.go +++ b/internal/clientcache/cmd/cache/start.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: BUSL-1.1 -package daemon +package cache import ( "context" @@ -30,7 +30,7 @@ const ( logFileName = "cache.log" // Mark of process as having been started in the background - backgroundEnvName = "_BOUNDARY_DAEMON_BACKGROUND" + backgroundEnvName = "_BOUNDARY_CACHE_BACKGROUND" backgroundEnvVal = "1" ) @@ -54,16 +54,16 @@ type StartCommand struct { } func (c *StartCommand) Synopsis() string { - return "Start a Boundary daemon" + return "Start a Boundary cache" } func (c *StartCommand) Help() string { helpText := ` -Usage: boundary daemon start [options] +Usage: boundary cache start [options] - Start a daemon: + Start a cache: - $ boundary daemon start + $ boundary cache start For a full list of examples, please see the documentation. @@ -132,7 +132,7 @@ func (c *StartCommand) Flags() *base.FlagSets { Name: "background", Target: &c.flagBackground, Default: false, - Usage: `Run the client cache daemon in the background`, + Usage: `Run the cache daemon in the background`, }) return set @@ -242,7 +242,7 @@ func (c *StartCommand) Run(args []string) int { // DefaultDotDirectory returns the default path to the boundary dot directory. func DefaultDotDirectory(ctx context.Context) (string, error) { - const op = "daemon.DefaultDotDirectory" + const op = "cache.DefaultDotDirectory" homeDir, err := homedir.Dir() if err != nil { return "", errors.Wrap(ctx, err, op) @@ -256,7 +256,7 @@ func DefaultDotDirectory(ctx context.Context) (string, error) { // are saved as backup. When a new log file is rotated and there is already 3 // backups created, the oldest one is deleted. func logFile(ctx context.Context, dotDir string, maxSizeMb int) (io.WriteCloser, string, error) { - const op = "daemon.logFile" + const op = "cache.logFile" logFilePath := filepath.Join(dotDir, logFileName) { // Ensure the file is created with the desired permissions. @@ -277,14 +277,14 @@ func logFile(ctx context.Context, dotDir string, maxSizeMb int) (io.WriteCloser, } func (c *StartCommand) makeBackground(ctx context.Context, dotDir string) (bool, []io.Writer, pidCleanup, error) { - const op = "daemon.makeBackground" + const op = "cache.makeBackground" writers := []io.Writer{} pidPath := filepath.Join(dotDir, pidFileName) if running, err := pidFileInUse(ctx, pidPath); running != nil { - return false, writers, noopPidCleanup, stderrors.New("The daemon is already running.") + return false, writers, noopPidCleanup, stderrors.New("The cache is already running.") } else if err != nil && !errors.Match(errors.T(errors.NotFound), err) { - return false, writers, noopPidCleanup, fmt.Errorf("Error when checking if the daemon pid is in use: %w.", err) + return false, writers, noopPidCleanup, fmt.Errorf("Error when checking if the cache pid is in use: %w.", err) } if !c.flagBackground && os.Getenv(backgroundEnvName) != backgroundEnvVal { @@ -308,7 +308,7 @@ func (c *StartCommand) makeBackground(ctx context.Context, dotDir string) (bool, env := os.Environ() env = append(env, fmt.Sprintf("%s=%s", backgroundEnvName, backgroundEnvVal)) - args := []string{"daemon", "start"} + args := []string{"cache", "start"} args = append(args, "-refresh-interval", c.flagRefreshInterval.String()) args = append(args, "-max-search-staleness", c.flagMaxSearchStaleness.String()) args = append(args, "-max-search-refresh-timeout", c.flagMaxSearchRefreshTimeout.String()) diff --git a/internal/clientcache/cmd/daemon/status.go b/internal/clientcache/cmd/cache/status.go similarity index 92% rename from internal/clientcache/cmd/daemon/status.go rename to internal/clientcache/cmd/cache/status.go index b023b3ae8..a699ca7f0 100644 --- a/internal/clientcache/cmd/daemon/status.go +++ b/internal/clientcache/cmd/cache/status.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: BUSL-1.1 -package daemon +package cache import ( "context" @@ -22,7 +22,7 @@ import ( "golang.org/x/text/language" ) -var errDaemonNotRunning = stderr.New("The daemon process is not running.") +var errCacheNotRunning = stderr.New("The cache process is not running.") var ( _ cli.Command = (*AddTokenCommand)(nil) @@ -34,16 +34,16 @@ type StatusCommand struct { } func (c *StatusCommand) Synopsis() string { - return "Get the status information of the running boundary daemon" + return "Get the status information of the running boundary cache" } func (c *StatusCommand) Help() string { helpText := ` -Usage: boundary daemon status [options] +Usage: boundary cache status [options] - Get the status of the boundary daemon: + Get the status of the boundary cache: - $ boundary daemon status + $ boundary cache status For a full list of examples, please see the documentation. @@ -86,7 +86,7 @@ func (c *StatusCommand) Run(args []string) int { return base.CommandCliError } if apiErr != nil { - c.PrintApiError(apiErr, "Error from daemon when getting the status") + c.PrintApiError(apiErr, "Error from cache when getting the status") return base.CommandApiError } @@ -115,11 +115,11 @@ func (c *StatusCommand) Status(ctx context.Context) (*api.Response, *daemon.Stat } func status(ctx context.Context, daemonPath string, opt ...client.Option) (*api.Response, *daemon.StatusResult, *api.Error, error) { - const op = "daemon.status" + const op = "cache.status" addr := daemon.SocketAddress(daemonPath) _, err := os.Stat(addr.Path) if addr.Scheme == "unix" && err != nil { - return nil, nil, nil, errDaemonNotRunning + return nil, nil, nil, errCacheNotRunning } c, err := client.New(ctx, addr) if err != nil { @@ -134,7 +134,7 @@ func status(ctx context.Context, daemonPath string, opt ...client.Option) (*api. res := &daemon.StatusResult{} apiErr, err := resp.Decode(&res) if err != nil { - return nil, nil, nil, fmt.Errorf("Error when sending request to the daemon: %w.", err) + return nil, nil, nil, fmt.Errorf("Error when sending request to the cache: %w.", err) } if apiErr != nil { return resp, nil, apiErr, nil diff --git a/internal/clientcache/cmd/daemon/stop.go b/internal/clientcache/cmd/cache/stop.go similarity index 88% rename from internal/clientcache/cmd/daemon/stop.go rename to internal/clientcache/cmd/cache/stop.go index 02882287a..79d9876e0 100644 --- a/internal/clientcache/cmd/daemon/stop.go +++ b/internal/clientcache/cmd/cache/stop.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: BUSL-1.1 -package daemon +package cache import ( "context" @@ -17,16 +17,16 @@ type StopCommand struct { } func (c *StopCommand) Synopsis() string { - return "Stop a Boundary daemon" + return "Stop the Boundary cache" } func (c *StopCommand) Help() string { helpText := ` -Usage: boundary daemon stop +Usage: boundary cache stop - Stop a daemon: + Stop a cache: - $ boundary daemon stop + $ boundary cache stop For a full list of examples, please see the documentation. @@ -59,7 +59,7 @@ func (c *StopCommand) Run(args []string) int { } if err := c.stop(c.Context); err != nil { if errors.Match(errors.T(errors.NotFound), err) { - c.PrintCliError(errDaemonNotRunning) + c.PrintCliError(errCacheNotRunning) } else { c.PrintCliError(err) } diff --git a/internal/clientcache/cmd/daemon/stop_nonwindows.go b/internal/clientcache/cmd/cache/stop_nonwindows.go similarity index 71% rename from internal/clientcache/cmd/daemon/stop_nonwindows.go rename to internal/clientcache/cmd/cache/stop_nonwindows.go index d24ed4e4a..95eef5212 100644 --- a/internal/clientcache/cmd/daemon/stop_nonwindows.go +++ b/internal/clientcache/cmd/cache/stop_nonwindows.go @@ -4,7 +4,7 @@ //go:build !windows // +build !windows -package daemon +package cache import ( "context" @@ -16,7 +16,7 @@ import ( "github.com/hashicorp/boundary/internal/util" ) -// stop will send a term signal to the daemon to shut down. +// stop will send a term signal to the cache to shut down. func (c *StopCommand) stop(ctx context.Context) error { switch { case util.IsNil(ctx): @@ -30,13 +30,13 @@ func (c *StopCommand) stop(ctx context.Context) error { pidPath := filepath.Join(dotPath, pidFileName) p, err := pidFileInUse(ctx, pidPath) if err != nil { - return fmt.Errorf("Error when checking if the daemon's pid file is in use: %w", err) + return fmt.Errorf("Error when checking if the cache's pid file is in use: %w", err) } if p == nil { - return errors.New("The daemon is not running.") + return errors.New("The cache is not running.") } if err := p.Signal(syscall.SIGTERM); err != nil { - return fmt.Errorf("Error when sending sigterm to daemon process: %w", err) + return fmt.Errorf("Error when sending sigterm to cache process: %w", err) } return nil } diff --git a/internal/clientcache/cmd/daemon/stop_windows.go b/internal/clientcache/cmd/cache/stop_windows.go similarity index 77% rename from internal/clientcache/cmd/daemon/stop_windows.go rename to internal/clientcache/cmd/cache/stop_windows.go index ceab49cb2..a63452b51 100644 --- a/internal/clientcache/cmd/daemon/stop_windows.go +++ b/internal/clientcache/cmd/cache/stop_windows.go @@ -4,7 +4,7 @@ //go:build windows // +build windows -package daemon +package cache import ( "context" @@ -19,7 +19,7 @@ import ( "github.com/hashicorp/boundary/internal/util" ) -// stop will send a term signal to the daemon to shut down. +// stop will send a term signal to the cache to shut down. func (c *StopCommand) stop(ctx context.Context) error { switch { case util.IsNil(ctx): @@ -40,7 +40,7 @@ func (c *StopCommand) stop(ctx context.Context) error { } else if apiErr != nil { errMsg = apiErr.Message } - c.UI.Warn(fmt.Sprintf("Failed stopping the daemon through the handler: %q, now killing the process", errMsg)) + c.UI.Warn(fmt.Sprintf("Failed stopping the cache through the handler: %q, now killing the process", errMsg)) default: // there wasn't an error stopping it through the handler. No need to // force kill the process @@ -51,12 +51,12 @@ func (c *StopCommand) stop(ctx context.Context) error { p, err := pidFileInUse(ctx, pidPath) if err != nil { if os.IsNotExist(err) { - return errors.New("Unable to stop the daemon: pid file not found.") + return errors.New("Unable to stop the cache: pid file not found.") } - return fmt.Errorf("Error when trying to stop the daemon: %w", err) + return fmt.Errorf("Error when trying to stop the cache: %w", err) } if p == nil { - return errors.New("Daemon process was not found.") + return errors.New("Cache process was not found.") } if err := p.Kill(); err != nil { @@ -73,7 +73,7 @@ func stopThroughHandler(ctx context.Context, dotPath string) (*api.Error, error) } resp, err := c.Post(ctx, "/v1/stop", nil) if err != nil { - return nil, fmt.Errorf("Error when sending request to the daemon: %w.", err) + return nil, fmt.Errorf("Error when sending request to the cache: %w.", err) } apiErr, err := resp.Decode(nil) return apiErr, err diff --git a/internal/clientcache/cmd/daemon/wrapper_register.go b/internal/clientcache/cmd/cache/wrapper_register.go similarity index 97% rename from internal/clientcache/cmd/daemon/wrapper_register.go rename to internal/clientcache/cmd/cache/wrapper_register.go index 72b93be4a..9831a60fb 100644 --- a/internal/clientcache/cmd/daemon/wrapper_register.go +++ b/internal/clientcache/cmd/cache/wrapper_register.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: BUSL-1.1 -package daemon +package cache import ( "bytes" @@ -53,12 +53,12 @@ func startDaemon(ctx context.Context, baseCmd *base.Command) bool { cmdName, err := os.Executable() if err != nil { - baseCmd.UI.Error(fmt.Sprintf("unable to find boundary binary for daemon startup: %s", err.Error())) + baseCmd.UI.Error(fmt.Sprintf("unable to find boundary binary for cache startup: %s", err.Error())) return false } var stdErr bytes.Buffer - cmd := exec.Command(cmdName, "daemon", "start", "-background") + cmd := exec.Command(cmdName, "cache", "start", "-background") cmd.Stderr = &stdErr // We use Run here instead of Start because the command spawns off a subprocess and returns. diff --git a/internal/clientcache/cmd/daemon/daemon.go b/internal/clientcache/cmd/daemon/daemon.go deleted file mode 100644 index 083f40ccb..000000000 --- a/internal/clientcache/cmd/daemon/daemon.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: BUSL-1.1 - -package daemon - -import ( - "strings" - - "github.com/hashicorp/boundary/internal/cmd/base" - "github.com/mitchellh/cli" - "github.com/posener/complete" -) - -var ( - _ cli.Command = (*StartCommand)(nil) - _ cli.CommandAutocomplete = (*StartCommand)(nil) -) - -type DaemonCommand struct { - *base.Command -} - -func (c *DaemonCommand) Synopsis() string { - return "Manages the client side Boundary cache daemon" -} - -func (c *DaemonCommand) Help() string { - helpText := ` -Usage: boundary daemon [sub command] [options] - - This command allows interacting with the Boundary daemon. - - Start a daemon: - - $ boundary daemon start - - For a full list of examples, please see the documentation. - -` - return strings.TrimSpace(helpText) -} - -func (c *DaemonCommand) Flags() *base.FlagSets { - return c.FlagSet(base.FlagSetNone) -} - -func (c *DaemonCommand) AutocompleteArgs() complete.Predictor { - return complete.PredictNothing -} - -func (c *DaemonCommand) AutocompleteFlags() complete.Flags { - return c.Flags().Completions() -} - -func (c *DaemonCommand) Run(args []string) int { - return cli.RunResultHelp -} diff --git a/internal/clientcache/cmd/search/search.go b/internal/clientcache/cmd/search/search.go index e3a4ff552..f5fee5e47 100644 --- a/internal/clientcache/cmd/search/search.go +++ b/internal/clientcache/cmd/search/search.go @@ -16,7 +16,7 @@ import ( "github.com/hashicorp/boundary/api/aliases" "github.com/hashicorp/boundary/api/sessions" "github.com/hashicorp/boundary/api/targets" - daemoncmd "github.com/hashicorp/boundary/internal/clientcache/cmd/daemon" + cachecmd "github.com/hashicorp/boundary/internal/clientcache/cmd/cache" "github.com/hashicorp/boundary/internal/clientcache/internal/client" "github.com/hashicorp/boundary/internal/clientcache/internal/daemon" "github.com/hashicorp/boundary/internal/cmd/base" @@ -35,7 +35,7 @@ var ( "sessions", } - errDaemonNotRunning = stderrors.New("The deamon process is not running.") + errCacheNotRunning = stderrors.New("The cache process is not running.") ) type SearchCommand struct { @@ -46,7 +46,7 @@ type SearchCommand struct { } func (c *SearchCommand) Synopsis() string { - return "Search Boundary resources using client side cache" + return "Search Boundary resources using client cache" } func (c *SearchCommand) Help() string { @@ -154,7 +154,7 @@ func (c *SearchCommand) Run(args []string) int { return base.CommandCliError } if apiErr != nil { - c.PrintApiError(apiErr, "Error from daemon when performing search") + c.PrintApiError(apiErr, "Error from cache when performing search") return base.CommandApiError } @@ -204,7 +204,7 @@ func (c *SearchCommand) Search(ctx context.Context) (*api.Response, *daemon.Sear opts = append(opts, client.WithOutputCurlString()) } - dotPath, err := daemoncmd.DefaultDotDirectory(ctx) + dotPath, err := cachecmd.DefaultDotDirectory(ctx) if err != nil { return nil, nil, nil, err } @@ -215,7 +215,7 @@ func search(ctx context.Context, daemonPath string, fb filterBy, opt ...client.O addr := daemon.SocketAddress(daemonPath) _, err := os.Stat(addr.Path) if addr.Scheme == "unix" && err != nil { - return nil, nil, nil, errDaemonNotRunning + return nil, nil, nil, errCacheNotRunning } c, err := client.New(ctx, addr) if err != nil { @@ -232,12 +232,12 @@ func search(ctx context.Context, daemonPath string, fb filterBy, opt ...client.O } resp, err := c.Get(ctx, "/v1/search", q, opt...) if err != nil { - return nil, nil, nil, fmt.Errorf("Error when sending request to the daemon: %w.", err) + return nil, nil, nil, fmt.Errorf("Error when sending request to the cache: %w.", err) } res := &daemon.SearchResult{} apiErr, err := resp.Decode(&res) if err != nil { - return nil, nil, nil, fmt.Errorf("Error when decoding request from the daemon: %w.", err) + return nil, nil, nil, fmt.Errorf("Error when decoding request from the cache: %w.", err) } if apiErr != nil { return resp, nil, apiErr, nil diff --git a/internal/clientcache/internal/cache/repository_refresh_token.go b/internal/clientcache/internal/cache/repository_refresh_token.go index ed7feaf93..e23fab82f 100644 --- a/internal/clientcache/internal/cache/repository_refresh_token.go +++ b/internal/clientcache/internal/cache/repository_refresh_token.go @@ -28,7 +28,7 @@ type RefreshTokenValue string const sentinelNoRefreshToken RefreshTokenValue = "__no_refresh_token_supported__" // CacheSupport is an enum that identifies if a boundary instance can be supported -// by the client daemon cache. +// by the client cache. type CacheSupport string const ( diff --git a/internal/clientcache/internal/cache/search.go b/internal/clientcache/internal/cache/search.go index 676fcdd8d..223903022 100644 --- a/internal/clientcache/internal/cache/search.go +++ b/internal/clientcache/internal/cache/search.go @@ -189,7 +189,7 @@ type resourceSearcher interface { // is returned and the returned SearchResults will be empty. // search implements searcher. func (l *resourceSearchFns[T]) search(ctx context.Context, p SearchParams) (*SearchResult, error) { - const op = "daemon.(resourceSearchFns).search" + const op = "cache.(resourceSearchFns).search" var found []T var err error diff --git a/internal/clientcache/internal/client/client.go b/internal/clientcache/internal/client/client.go index bf92cd8ed..7789bf878 100644 --- a/internal/clientcache/internal/client/client.go +++ b/internal/clientcache/internal/client/client.go @@ -106,7 +106,7 @@ func (c *Client) Post(ctx context.Context, path string, body any, opt ...Option) } // request returns a retryablehttp.Request with the url set to the domain socket -// associated with this client and proper headers set for client daemon requests. +// associated with this client and proper headers set for client cache requests. func request(ctx context.Context, method, path string) *retryablehttp.Request { req := &http.Request{ Method: method, diff --git a/internal/clientcache/internal/db/schema.sql b/internal/clientcache/internal/db/schema.sql index be692f0a8..bf5023b19 100644 --- a/internal/clientcache/internal/db/schema.sql +++ b/internal/clientcache/internal/db/schema.sql @@ -27,7 +27,7 @@ values ('target'), ('session'); --- Contains refresh tokens for list requests sent by the client daemon to the +-- Contains refresh tokens for list requests sent by the client cache to the -- boundary instance. create table if not exists refresh_token( user_id text not null diff --git a/internal/cmd/search_cmd_darwin.go b/internal/cmd/search_cmd_darwin.go index 97c00bb6f..1a5d52f27 100644 --- a/internal/cmd/search_cmd_darwin.go +++ b/internal/cmd/search_cmd_darwin.go @@ -4,39 +4,90 @@ package cmd import ( - "github.com/hashicorp/boundary/internal/clientcache/cmd/daemon" + "github.com/hashicorp/boundary/internal/clientcache/cmd/cache" "github.com/hashicorp/boundary/internal/clientcache/cmd/search" "github.com/hashicorp/boundary/internal/cmd/base" + "github.com/hashicorp/boundary/internal/cmd/wrapper" "github.com/mitchellh/cli" ) func init() { extraCommandsFuncs = append(extraCommandsFuncs, func(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { - Commands["daemon"] = func() (cli.Command, error) { - return &daemon.DaemonCommand{ + Commands["cache"] = func() (cli.Command, error) { + return &cache.CacheCommand{ Command: base.NewCommand(ui), }, nil } - Commands["daemon start"] = func() (cli.Command, error) { - return &daemon.StartCommand{ + Commands["cache start"] = func() (cli.Command, error) { + return &cache.StartCommand{ Command: base.NewCommand(ui), }, nil } - Commands["daemon stop"] = func() (cli.Command, error) { - return &daemon.StopCommand{ + Commands["cache stop"] = func() (cli.Command, error) { + return &cache.StopCommand{ Command: base.NewCommand(ui), }, nil } - Commands["daemon add-token"] = func() (cli.Command, error) { - return &daemon.AddTokenCommand{ + Commands["cache add-token"] = func() (cli.Command, error) { + return &cache.AddTokenCommand{ Command: base.NewCommand(ui), }, nil } - Commands["daemon status"] = func() (cli.Command, error) { - return &daemon.StatusCommand{ + Commands["cache status"] = func() (cli.Command, error) { + return &cache.StatusCommand{ Command: base.NewCommand(ui), }, nil } + // TODO(johanbrandhorst): remove after deprecation period + Commands["daemon"] = wrapper.WrapForDeprecation( + func() wrapper.WrappableCommand { + return &cache.CacheCommand{ + Command: base.NewCommand(ui), + } + }, + "daemon", + "cache", + ) + // TODO(johanbrandhorst): remove after deprecation period + Commands["daemon start"] = wrapper.WrapForDeprecation( + func() wrapper.WrappableCommand { + return &cache.StartCommand{ + Command: base.NewCommand(ui), + } + }, + "daemon", + "cache", + ) + // TODO(johanbrandhorst): remove after deprecation period + Commands["daemon stop"] = wrapper.WrapForDeprecation( + func() wrapper.WrappableCommand { + return &cache.StopCommand{ + Command: base.NewCommand(ui), + } + }, + "daemon", + "cache", + ) + // TODO(johanbrandhorst): remove after deprecation period + Commands["daemon add-token"] = wrapper.WrapForDeprecation( + func() wrapper.WrappableCommand { + return &cache.AddTokenCommand{ + Command: base.NewCommand(ui), + } + }, + "daemon", + "cache", + ) + // TODO(johanbrandhorst): remove after deprecation period + Commands["daemon status"] = wrapper.WrapForDeprecation( + func() wrapper.WrappableCommand { + return &cache.StatusCommand{ + Command: base.NewCommand(ui), + } + }, + "daemon", + "cache", + ) Commands["search"] = func() (cli.Command, error) { return &search.SearchCommand{ Command: base.NewCommand(ui), diff --git a/internal/cmd/search_cmd_freebsd.go b/internal/cmd/search_cmd_freebsd.go index ad54e7fd4..a65d14e4d 100644 --- a/internal/cmd/search_cmd_freebsd.go +++ b/internal/cmd/search_cmd_freebsd.go @@ -6,39 +6,90 @@ package cmd import ( - "github.com/hashicorp/boundary/internal/clientcache/cmd/daemon" + "github.com/hashicorp/boundary/internal/clientcache/cmd/cache" "github.com/hashicorp/boundary/internal/clientcache/cmd/search" "github.com/hashicorp/boundary/internal/cmd/base" + "github.com/hashicorp/boundary/internal/cmd/wrapper" "github.com/mitchellh/cli" ) func init() { extraCommandsFuncs = append(extraCommandsFuncs, func(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { - Commands["daemon"] = func() (cli.Command, error) { - return &daemon.DaemonCommand{ + Commands["cache"] = func() (cli.Command, error) { + return &cache.CacheCommand{ Command: base.NewCommand(ui), }, nil } - Commands["daemon start"] = func() (cli.Command, error) { - return &daemon.StartCommand{ + Commands["cache start"] = func() (cli.Command, error) { + return &cache.StartCommand{ Command: base.NewCommand(ui), }, nil } - Commands["daemon stop"] = func() (cli.Command, error) { - return &daemon.StopCommand{ + Commands["cache stop"] = func() (cli.Command, error) { + return &cache.StopCommand{ Command: base.NewCommand(ui), }, nil } - Commands["daemon add-token"] = func() (cli.Command, error) { - return &daemon.AddTokenCommand{ + Commands["cache add-token"] = func() (cli.Command, error) { + return &cache.AddTokenCommand{ Command: base.NewCommand(ui), }, nil } - Commands["daemon status"] = func() (cli.Command, error) { - return &daemon.StatusCommand{ + Commands["cache status"] = func() (cli.Command, error) { + return &cache.StatusCommand{ Command: base.NewCommand(ui), }, nil } + // TODO(johanbrandhorst): remove after deprecation period + Commands["daemon"] = wrapper.WrapForDeprecation( + func() wrapper.WrappableCommand { + return &cache.CacheCommand{ + Command: base.NewCommand(ui), + } + }, + "daemon", + "cache", + ) + // TODO(johanbrandhorst): remove after deprecation period + Commands["daemon start"] = wrapper.WrapForDeprecation( + func() wrapper.WrappableCommand { + return &cache.StartCommand{ + Command: base.NewCommand(ui), + } + }, + "daemon", + "cache", + ) + // TODO(johanbrandhorst): remove after deprecation period + Commands["daemon stop"] = wrapper.WrapForDeprecation( + func() wrapper.WrappableCommand { + return &cache.StopCommand{ + Command: base.NewCommand(ui), + } + }, + "daemon", + "cache", + ) + // TODO(johanbrandhorst): remove after deprecation period + Commands["daemon add-token"] = wrapper.WrapForDeprecation( + func() wrapper.WrappableCommand { + return &cache.AddTokenCommand{ + Command: base.NewCommand(ui), + } + }, + "daemon", + "cache", + ) + // TODO(johanbrandhorst): remove after deprecation period + Commands["daemon status"] = wrapper.WrapForDeprecation( + func() wrapper.WrappableCommand { + return &cache.StatusCommand{ + Command: base.NewCommand(ui), + } + }, + "daemon", + "cache", + ) Commands["search"] = func() (cli.Command, error) { return &search.SearchCommand{ Command: base.NewCommand(ui), diff --git a/internal/cmd/search_cmd_linux.go b/internal/cmd/search_cmd_linux.go index 97c00bb6f..1a5d52f27 100644 --- a/internal/cmd/search_cmd_linux.go +++ b/internal/cmd/search_cmd_linux.go @@ -4,39 +4,90 @@ package cmd import ( - "github.com/hashicorp/boundary/internal/clientcache/cmd/daemon" + "github.com/hashicorp/boundary/internal/clientcache/cmd/cache" "github.com/hashicorp/boundary/internal/clientcache/cmd/search" "github.com/hashicorp/boundary/internal/cmd/base" + "github.com/hashicorp/boundary/internal/cmd/wrapper" "github.com/mitchellh/cli" ) func init() { extraCommandsFuncs = append(extraCommandsFuncs, func(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { - Commands["daemon"] = func() (cli.Command, error) { - return &daemon.DaemonCommand{ + Commands["cache"] = func() (cli.Command, error) { + return &cache.CacheCommand{ Command: base.NewCommand(ui), }, nil } - Commands["daemon start"] = func() (cli.Command, error) { - return &daemon.StartCommand{ + Commands["cache start"] = func() (cli.Command, error) { + return &cache.StartCommand{ Command: base.NewCommand(ui), }, nil } - Commands["daemon stop"] = func() (cli.Command, error) { - return &daemon.StopCommand{ + Commands["cache stop"] = func() (cli.Command, error) { + return &cache.StopCommand{ Command: base.NewCommand(ui), }, nil } - Commands["daemon add-token"] = func() (cli.Command, error) { - return &daemon.AddTokenCommand{ + Commands["cache add-token"] = func() (cli.Command, error) { + return &cache.AddTokenCommand{ Command: base.NewCommand(ui), }, nil } - Commands["daemon status"] = func() (cli.Command, error) { - return &daemon.StatusCommand{ + Commands["cache status"] = func() (cli.Command, error) { + return &cache.StatusCommand{ Command: base.NewCommand(ui), }, nil } + // TODO(johanbrandhorst): remove after deprecation period + Commands["daemon"] = wrapper.WrapForDeprecation( + func() wrapper.WrappableCommand { + return &cache.CacheCommand{ + Command: base.NewCommand(ui), + } + }, + "daemon", + "cache", + ) + // TODO(johanbrandhorst): remove after deprecation period + Commands["daemon start"] = wrapper.WrapForDeprecation( + func() wrapper.WrappableCommand { + return &cache.StartCommand{ + Command: base.NewCommand(ui), + } + }, + "daemon", + "cache", + ) + // TODO(johanbrandhorst): remove after deprecation period + Commands["daemon stop"] = wrapper.WrapForDeprecation( + func() wrapper.WrappableCommand { + return &cache.StopCommand{ + Command: base.NewCommand(ui), + } + }, + "daemon", + "cache", + ) + // TODO(johanbrandhorst): remove after deprecation period + Commands["daemon add-token"] = wrapper.WrapForDeprecation( + func() wrapper.WrappableCommand { + return &cache.AddTokenCommand{ + Command: base.NewCommand(ui), + } + }, + "daemon", + "cache", + ) + // TODO(johanbrandhorst): remove after deprecation period + Commands["daemon status"] = wrapper.WrapForDeprecation( + func() wrapper.WrappableCommand { + return &cache.StatusCommand{ + Command: base.NewCommand(ui), + } + }, + "daemon", + "cache", + ) Commands["search"] = func() (cli.Command, error) { return &search.SearchCommand{ Command: base.NewCommand(ui), diff --git a/internal/cmd/search_cmd_windows.go b/internal/cmd/search_cmd_windows.go index ad54e7fd4..a65d14e4d 100644 --- a/internal/cmd/search_cmd_windows.go +++ b/internal/cmd/search_cmd_windows.go @@ -6,39 +6,90 @@ package cmd import ( - "github.com/hashicorp/boundary/internal/clientcache/cmd/daemon" + "github.com/hashicorp/boundary/internal/clientcache/cmd/cache" "github.com/hashicorp/boundary/internal/clientcache/cmd/search" "github.com/hashicorp/boundary/internal/cmd/base" + "github.com/hashicorp/boundary/internal/cmd/wrapper" "github.com/mitchellh/cli" ) func init() { extraCommandsFuncs = append(extraCommandsFuncs, func(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { - Commands["daemon"] = func() (cli.Command, error) { - return &daemon.DaemonCommand{ + Commands["cache"] = func() (cli.Command, error) { + return &cache.CacheCommand{ Command: base.NewCommand(ui), }, nil } - Commands["daemon start"] = func() (cli.Command, error) { - return &daemon.StartCommand{ + Commands["cache start"] = func() (cli.Command, error) { + return &cache.StartCommand{ Command: base.NewCommand(ui), }, nil } - Commands["daemon stop"] = func() (cli.Command, error) { - return &daemon.StopCommand{ + Commands["cache stop"] = func() (cli.Command, error) { + return &cache.StopCommand{ Command: base.NewCommand(ui), }, nil } - Commands["daemon add-token"] = func() (cli.Command, error) { - return &daemon.AddTokenCommand{ + Commands["cache add-token"] = func() (cli.Command, error) { + return &cache.AddTokenCommand{ Command: base.NewCommand(ui), }, nil } - Commands["daemon status"] = func() (cli.Command, error) { - return &daemon.StatusCommand{ + Commands["cache status"] = func() (cli.Command, error) { + return &cache.StatusCommand{ Command: base.NewCommand(ui), }, nil } + // TODO(johanbrandhorst): remove after deprecation period + Commands["daemon"] = wrapper.WrapForDeprecation( + func() wrapper.WrappableCommand { + return &cache.CacheCommand{ + Command: base.NewCommand(ui), + } + }, + "daemon", + "cache", + ) + // TODO(johanbrandhorst): remove after deprecation period + Commands["daemon start"] = wrapper.WrapForDeprecation( + func() wrapper.WrappableCommand { + return &cache.StartCommand{ + Command: base.NewCommand(ui), + } + }, + "daemon", + "cache", + ) + // TODO(johanbrandhorst): remove after deprecation period + Commands["daemon stop"] = wrapper.WrapForDeprecation( + func() wrapper.WrappableCommand { + return &cache.StopCommand{ + Command: base.NewCommand(ui), + } + }, + "daemon", + "cache", + ) + // TODO(johanbrandhorst): remove after deprecation period + Commands["daemon add-token"] = wrapper.WrapForDeprecation( + func() wrapper.WrappableCommand { + return &cache.AddTokenCommand{ + Command: base.NewCommand(ui), + } + }, + "daemon", + "cache", + ) + // TODO(johanbrandhorst): remove after deprecation period + Commands["daemon status"] = wrapper.WrapForDeprecation( + func() wrapper.WrappableCommand { + return &cache.StatusCommand{ + Command: base.NewCommand(ui), + } + }, + "daemon", + "cache", + ) Commands["search"] = func() (cli.Command, error) { return &search.SearchCommand{ Command: base.NewCommand(ui), diff --git a/internal/cmd/wrapper/command_wrapper.go b/internal/cmd/wrapper/command_wrapper.go index 6986eff99..0f7fc2b18 100644 --- a/internal/cmd/wrapper/command_wrapper.go +++ b/internal/cmd/wrapper/command_wrapper.go @@ -35,7 +35,7 @@ type WrappableCommand interface { BaseCommand() *base.Command } -// CommandWrapper starts the boundary daemon after the command was Run and attempts +// CommandWrapper starts the boundary cache after the command was Run and attempts // to send the current persona to any running daemon. type CommandWrapper struct { WrappableCommand @@ -50,8 +50,8 @@ func Wrap(c func() WrappableCommand) cli.CommandFactory { } } -// Run runs the wrapped command and then attempts to start the boundary daemon and send -// the current persona +// Run runs the wrapped command and then attempts to start the boundary cache and send +// the current token to it. func (w *CommandWrapper) Run(args []string) int { // potentially intercept the token in case it isn't stored in the keyring var token string diff --git a/internal/cmd/wrapper/deprecation_wrapper.go b/internal/cmd/wrapper/deprecation_wrapper.go new file mode 100644 index 000000000..50a84a303 --- /dev/null +++ b/internal/cmd/wrapper/deprecation_wrapper.go @@ -0,0 +1,41 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: BUSL-1.1 + +package wrapper + +import ( + "fmt" + + "github.com/mitchellh/cli" +) + +// DeprecationWrapper can be used to mark a command as deprecated. +type DeprecationWrapper struct { + WrappableCommand + old string + new string +} + +// WrapForDeprecation returns a cli.CommandFactory that will print a deprecation warning when invoked. +func WrapForDeprecation(c func() WrappableCommand, old, new string) cli.CommandFactory { + return func() (cli.Command, error) { + return &DeprecationWrapper{ + WrappableCommand: c(), + old: old, + new: new, + }, nil + } +} + +// Run prints a deprecation warning and then runs the wrapped command. +func (w *DeprecationWrapper) Run(args []string) int { + w.WrappableCommand.BaseCommand().UI.Warn( + fmt.Sprintf( + "The '%s' command is deprecated and will be removed in a future release. Please use the '%s' command instead.", + w.old, + w.new, + ), + ) + + return w.WrappableCommand.Run(args) +} diff --git a/website/content/docs/api-clients/client-cache.mdx b/website/content/docs/api-clients/client-cache.mdx index 7a2a5a387..fcbe7b491 100644 --- a/website/content/docs/api-clients/client-cache.mdx +++ b/website/content/docs/api-clients/client-cache.mdx @@ -7,7 +7,7 @@ description: |- # Client cache -The Boundary client daemon runs on end users' computers and locally caches session and target resource information from Boundary instances. +The Boundary client cache runs on end users' computers and locally caches session and target resource information from Boundary instances. The cache helps expedite searches. ## Boundary `list` vs. `search` @@ -16,7 +16,7 @@ You can use the Boundary API or CLI to `list` resources like targets, sessions, When you use the `list` command, Boundary searches the control plane to provide a current total of resources when it produces the list of results. Some Boundary resources can provide a significant number of items in the response. -Because large lists of results may overwhelm your system resources, the client daemon caches the results of the `list` operation. +Because large lists of results may overwhelm your system resources, the client cache caches the results of the `list` operation. You can search the local cache instead of the control plane to help protect your system resources. The Boundary `search` command also produces a list of Boundary resources. When you use the `search` command, however, Boundary searches the local cache to create the list. @@ -34,16 +34,16 @@ For more information, refer to [Identity and access management (IAM)](/boundary/ ## Client cache management -The Boundary client daemon starts automatically in the background when a user runs a CLI command that interacts with a Boundary instance. -If you do not want the daemon to automatically start, you can include the `-skip-cache-daemon` flag or set the **BOUNDARY_SKIP_CACHE_DAEMON** environment variable when you use the Boundary CLI to interact with a Boundary instance. +The Boundary client cache starts automatically in the background when a user runs a CLI command that interacts with a Boundary instance. +If you do not want the cache to automatically start, you can include the `-skip-cache-daemon` flag or set the **BOUNDARY_SKIP_CACHE_DAEMON** environment variable when you use the Boundary CLI to interact with a Boundary instance. ### Startup and customization -You can start the daemon manually using the `boundary daemon start` command. -By default, the daemon starts in the foreground. +You can start the cache manually using the `boundary cache start` command. +By default, the cache starts in the foreground. You can start it in the background by adding the `-background` flag. -If you start the daemon manually, you can customize the caching behavior. +If you start the cache manually, you can customize the caching behavior. Include any of the following options to customize the behavior: - `max-search-staleness` - The amount of time that can pass since the last refresh before calling `boundary search` results in a blocking refresh from the Boundary instance of the resources being searched. @@ -52,7 +52,7 @@ In the event of a timeout, Boundary uses the stale data that is currently in the - `refresh-interval` - A duration that specifies how frequently the client cache should query Boundary for changes to sessions and targets. Note that Boundary only searches sessions and targets that the user who ran the command has access to. -For more information, refer to the [`daemon start`](/boundary/docs/commands/daemon/start) command documentation. +For more information, refer to the [`cache start`](/boundary/docs/commands/cache/start) command documentation. ### Logging @@ -62,10 +62,10 @@ It compresses and keeps the last 3 rotated logs before deleting a log. ### Status -You can check the status of the cache using the `boundary daemon status` command. +You can check the status of the cache using the `boundary cache status` command. The command returns information about the cache including the uptime, user count, user information, and which Boundary resources the cache is tracking. -For more information, refer to the [`daemon status`](/boundary/docs/commands/daemon/status) command documentation. +For more information, refer to the [`cache status`](/boundary/docs/commands/cache/status) command documentation. ### Auth tokens @@ -74,6 +74,6 @@ By default, the Boundary CLI tries to use a keyring to store and receive auth to Whenever you use an auth token to interact with Boundary, the client cache stores the auth token and syncs the data associated with it. If you authenticate to multiple Boundary instances, the client cache stores multiple auth tokens and syncs the data associated with each token. -To search the client cache for a specific Boundary instance, you can specify the appropriate auth token using the `boundary daemon add-token` command. +To search the client cache for a specific Boundary instance, you can specify the appropriate auth token using the `boundary cache add-token` command. -For more information, refer to the [`daemon add-token`](/boundary/docs/commands/daemon/add-token) command documentation. \ No newline at end of file +For more information, refer to the [`cache add-token`](/boundary/docs/commands/cache/add-token) command documentation. diff --git a/website/content/docs/commands/daemon/add-token.mdx b/website/content/docs/commands/cache/add-token.mdx similarity index 84% rename from website/content/docs/commands/daemon/add-token.mdx rename to website/content/docs/commands/cache/add-token.mdx index 3e8c50191..075298f53 100644 --- a/website/content/docs/commands/daemon/add-token.mdx +++ b/website/content/docs/commands/cache/add-token.mdx @@ -1,15 +1,15 @@ --- layout: docs -page_title: daemon add-token - Command +page_title: cache add-token - Command description: |- - The "daemon add-token" command lets you add an auth token to a Boundary daemon that is running. + The "cache add-token" command lets you add an auth token to a Boundary cache that is running. --- -# daemon add-token +# cache add-token -Command: `boundary daemon add-token` +Command: `boundary cache add-token` -The `boundary daemon add-token` command lets you add an auth token from your keyring to a Boundary daemon that is running. +The `boundary cache add-token` command lets you add an auth token from your keyring to a Boundary cache that is running. By default, the Boundary CLI tries to use a keyring to store and receive auth tokens. Whenever you use an auth token to interact with Boundary, the client cache stores the auth token and syncs the data associated with it. @@ -32,13 +32,13 @@ For more information, refer to [Identity and access management (IAM)](/boundary/ The following command adds an auth token to the client cache from your keyring: ```shell-session -$ boundary daemon add-token +$ boundary cache add-token ``` The following command specifies the name of the keyring `development` from which you want to add the token: ```shell-session -$ boundary daemon add-token -token-name development +$ boundary cache add-token -token-name development ``` ## Usage @@ -46,7 +46,7 @@ $ boundary daemon add-token -token-name development ```shell-session -$ boundary daemon add-token [options] +$ boundary cache add-token [options] ``` @@ -71,4 +71,4 @@ If you set this parameter, it overrides the `token-name` parameter. You can use this value to switch user identities for different commands. You can also specify a token name using the **BOUNDARY_TOKEN_NAME** environment variable. -@include 'cmd-option-note.mdx' \ No newline at end of file +@include 'cmd-option-note.mdx' diff --git a/website/content/docs/commands/cache/index.mdx b/website/content/docs/commands/cache/index.mdx new file mode 100644 index 000000000..ba9f87194 --- /dev/null +++ b/website/content/docs/commands/cache/index.mdx @@ -0,0 +1,43 @@ +--- +layout: docs +page_title: cache - Command +description: |- + Boundary's "cache" command lets you manage a local cache of information to facilitate searches and protect your system resources from being overwhelmed. +--- + +# cache + +Command: `boundary cache` + +The `cache` command lets you manage the Boundary cache and perform operations on the local cache of information. + +## Example + +The following command starts the Boundary cache in the background: + +```shell-session +$ boundary cache start -background +``` + +## Usage + + + +```shell-session +Usage: boundary cache [options] [args] + # ... +Subcommands: + add-token Add an auth token to a Boundary cache that is currently running. + start Starts the Boundary cache. + status Gets the status information of a Boundary cache that is currently running. + stop Stops the Boundary cache. +``` + + + +For more information, examples, and usage, click on the name of the subcommand in the sidebar or one of the links below: + +- [add-token](/boundary/docs/commands/cache/add-token) +- [start](/boundary/docs/commands/cache/start) +- [status](/boundary/docs/commands/cache/status) +- [stop](/boundary/docs/commands/cache/stop) diff --git a/website/content/docs/commands/daemon/start.mdx b/website/content/docs/commands/cache/start.mdx similarity index 66% rename from website/content/docs/commands/daemon/start.mdx rename to website/content/docs/commands/cache/start.mdx index 73648173f..ce2b4c713 100644 --- a/website/content/docs/commands/daemon/start.mdx +++ b/website/content/docs/commands/cache/start.mdx @@ -1,22 +1,22 @@ --- layout: docs -page_title: daemon start - Command +page_title: cache start - Command description: |- - The "daemon start" command lets you manually start the Boundary daemon and customize the behavior of the local cache. + The "cache start" command lets you manually start the Boundary cache and customize the behavior of the local cache. --- -# daemon start +# cache start -Command: `boundary daemon start` +Command: `boundary cache start` -The `boundary daemon start` command lets you manually start the Boundary daemon and customize the behavior of the local cache. +The `boundary cache start` command lets you manually start the Boundary cache and customize the behavior of the local cache. ## Example -The following command starts the Boundary daemon in the background: +The following command starts the Boundary cache in the background: ```shell-session -$ boundary daemon start -background +$ boundary cache start -background ``` ## Usage @@ -24,16 +24,16 @@ $ boundary daemon start -background ```shell-session -$ boundary daemon start [options] [args] +$ boundary cache start [options] [args] ``` ### Command options -- `background` - Starts the Boundary daemon in the background. +- `background` - Starts the Boundary cache in the background. The default value is `false`. -By default, the daemon starts in the foreground. +By default, the cache starts in the foreground. - `log-format=` - Specifies the log format, mostly as a fallback for events. Supported values are `standard` and `json`. - `max-search-refresh-timeout=` - If a search request triggers a best effort refresh, this value specifies how long the refresh should run before time out. @@ -46,4 +46,4 @@ The default value is 30 seconds. - `refresh-interval` - A duration that specifies how frequently the client cache should query Boundary for changes to sessions and targets. Note that Boundary only searches sessions and targets that the user who ran the command has access to. -@include 'cmd-option-note.mdx' \ No newline at end of file +@include 'cmd-option-note.mdx' diff --git a/website/content/docs/commands/daemon/status.mdx b/website/content/docs/commands/cache/status.mdx similarity index 62% rename from website/content/docs/commands/daemon/status.mdx rename to website/content/docs/commands/cache/status.mdx index bc5e5bb9e..1ef5b2f06 100644 --- a/website/content/docs/commands/daemon/status.mdx +++ b/website/content/docs/commands/cache/status.mdx @@ -1,23 +1,23 @@ --- layout: docs -page_title: daemon status - Command +page_title: cache status - Command description: |- - The "daemon status" command lets you manually check the status of the Boundary daemon. + The "cache status" command lets you manually check the status of the Boundary cache. --- -# daemon status +# cache status -Command: `boundary daemon status` +Command: `boundary cache status` -The `boundary daemon status` command lets you manually check the status of the Boundary daemon. +The `boundary cache status` command lets you manually check the status of the Boundary cache. Boundary prints out a status report that includes configuration, user, and resource information. ## Example -The following command checks the status of the Boundary daemon: +The following command checks the status of the Boundary cache: ```shell-session -$ boundary daemon status +$ boundary cache status ``` **Example output:** @@ -39,7 +39,7 @@ Status: ```shell-session -$ boundary daemon status [options] [args] +$ boundary cache status [options] [args] ``` @@ -49,4 +49,4 @@ $ boundary daemon status [options] [args] - `output-curl-string` - Specifies that Boundary should print an equivalent cURL command string and exit, instead of executing the request. The default value is `false`. -@include 'cmd-option-note.mdx' \ No newline at end of file +@include 'cmd-option-note.mdx' diff --git a/website/content/docs/commands/cache/stop.mdx b/website/content/docs/commands/cache/stop.mdx new file mode 100644 index 000000000..e99248c28 --- /dev/null +++ b/website/content/docs/commands/cache/stop.mdx @@ -0,0 +1,32 @@ +--- +layout: docs +page_title: cache stop - Command +description: |- + The "cache stop" command lets you manually stop the Boundary cache. +--- + +# cache stop + +Command: `boundary cache stop` + +The `boundary cache stop` command lets you manually stop the Boundary cache. + +## Example + +The following command stops the Boundary cache: + +```shell-session +$ boundary cache stop +``` + +## Usage + + + +```shell-session +$ boundary cache stop [options] [args] +``` + + + +@include 'cmd-option-note.mdx' diff --git a/website/content/docs/commands/daemon/index.mdx b/website/content/docs/commands/daemon/index.mdx deleted file mode 100644 index 2947706f3..000000000 --- a/website/content/docs/commands/daemon/index.mdx +++ /dev/null @@ -1,43 +0,0 @@ ---- -layout: docs -page_title: daemon - Command -description: |- - Boundary's "daemon" command lets you manage a local cache of information to facilitate searches and protect your system resources from being overwhelmed. ---- - -# daemon - -Command: `boundary daemon` - -The `daemon` command lets you manage the Boundary daemon and perform operations on the local cache of information. - -## Example - -The following command starts the Boundary daemon in the background: - -```shell-session -$ boundary daemon start -background -``` - -## Usage - - - -```shell-session -Usage: boundary daemon [options] [args] - # ... -Subcommands: - add-token Add an auth token to a Boundary daemon that is currently running. - start Starts the Boundary daemon. - status Gets the status information of a Boundary daemon that is currently running. - stop Stops the Boundary daemon. -``` - - - -For more information, examples, and usage, click on the name of the subcommand in the sidebar or one of the links below: - -- [add-token](/boundary/docs/commands/daemon/add-token) -- [start](/boundary/docs/commands/daemon/start) -- [status](/boundary/docs/commands/daemon/status) -- [stop](/boundary/docs/commands/daemon/stop) \ No newline at end of file diff --git a/website/content/docs/commands/daemon/stop.mdx b/website/content/docs/commands/daemon/stop.mdx deleted file mode 100644 index 63a42b119..000000000 --- a/website/content/docs/commands/daemon/stop.mdx +++ /dev/null @@ -1,32 +0,0 @@ ---- -layout: docs -page_title: daemon stop - Command -description: |- - The "daemon stop" command lets you manually stop the Boundary daemon. ---- - -# daemon stop - -Command: `boundary daemon stop` - -The `boundary daemon stop` command lets you manually stop the Boundary daemon. - -## Example - -The following command stops the Boundary daemon: - -```shell-session -$ boundary daemon stop -``` - -## Usage - - - -```shell-session -$ boundary daemon stop [options] [args] -``` - - - -@include 'cmd-option-note.mdx' \ No newline at end of file diff --git a/website/data/docs-nav-data.json b/website/data/docs-nav-data.json index ab92cba4f..e39a235d1 100644 --- a/website/data/docs-nav-data.json +++ b/website/data/docs-nav-data.json @@ -982,27 +982,27 @@ ] }, { - "title": "daemon", + "title": "cache", "routes": [ { "title": "Overview", - "path": "commands/daemon" + "path": "commands/cache" }, { "title": "add-token", - "path": "commands/daemon/add-token" + "path": "commands/cache/add-token" }, { "title": "start", - "path": "commands/daemon/start" + "path": "commands/cache/start" }, { "title": "status", - "path": "commands/daemon/status" + "path": "commands/cache/status" }, { "title": "stop", - "path": "commands/daemon/stop" + "path": "commands/cache/stop" } ] },