2023-06-11 20:40:47 -04:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
|
|
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/hashicorp/boundary/internal/clientcache/cmd/daemon"
|
|
|
|
|
"github.com/hashicorp/boundary/internal/clientcache/cmd/search"
|
|
|
|
|
"github.com/hashicorp/boundary/internal/cmd/base"
|
|
|
|
|
"github.com/mitchellh/cli"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func init() {
|
2023-11-01 12:45:35 -07:00
|
|
|
clientCacheWrapper = daemonWrap
|
2023-06-11 20:40:47 -04:00
|
|
|
|
|
|
|
|
extraCommandsFuncs = append(extraCommandsFuncs, func(ui, serverCmdUi cli.Ui, runOpts *RunOptions) {
|
|
|
|
|
delete(Commands, "daemon")
|
|
|
|
|
Commands["daemon start"] = func() (cli.Command, error) {
|
|
|
|
|
return &daemon.StartCommand{
|
|
|
|
|
Command: base.NewCommand(ui),
|
|
|
|
|
}, nil
|
|
|
|
|
}
|
|
|
|
|
Commands["daemon stop"] = func() (cli.Command, error) {
|
|
|
|
|
return &daemon.StopCommand{
|
|
|
|
|
Command: base.NewCommand(ui),
|
|
|
|
|
}, nil
|
|
|
|
|
}
|
|
|
|
|
Commands["daemon add-token"] = func() (cli.Command, error) {
|
|
|
|
|
return &daemon.AddTokenCommand{
|
|
|
|
|
Command: base.NewCommand(ui),
|
|
|
|
|
}, nil
|
|
|
|
|
}
|
2023-11-03 14:22:55 -07:00
|
|
|
Commands["daemon status"] = func() (cli.Command, error) {
|
|
|
|
|
return &daemon.StatusCommand{
|
|
|
|
|
Command: base.NewCommand(ui),
|
|
|
|
|
}, nil
|
|
|
|
|
}
|
2023-06-11 20:40:47 -04:00
|
|
|
Commands["search"] = func() (cli.Command, error) {
|
|
|
|
|
return &search.SearchCommand{
|
|
|
|
|
Command: base.NewCommand(ui),
|
|
|
|
|
}, nil
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-01 12:45:35 -07:00
|
|
|
// daemonWrap wraps the provided cacheEnabledCommand with a daemon writer which
|
2023-06-11 20:40:47 -04:00
|
|
|
// conditionally starts the client side daemon after the command completes
|
2023-11-01 12:45:35 -07:00
|
|
|
func daemonWrap(c cacheEnabledCommand) cli.CommandFactory {
|
|
|
|
|
return daemon.Wrap(c)
|
2023-06-11 20:40:47 -04:00
|
|
|
}
|