internal/cmd: rename ferry to client-agent
Renames the ferry command and related flags and env vars to client-agent following the new naming decision.
This commit is contained in:
1 parent
d87a4bab8b
commit
8ff18f6c3c
13 files changed
+194
-194
No files matched your search
+12
-12
@@ -74,8 +74,8 @@ const (
|
||||
EnvKeyringType = "BOUNDARY_KEYRING_TYPE"
|
||||
envRecoveryConfig = "BOUNDARY_RECOVERY_CONFIG"
|
||||
envSkipCacheDaemon = "BOUNDARY_SKIP_CACHE_DAEMON"
|
||||
envSkipFerry = "BOUNDARY_SKIP_FERRY_DAEMON"
|
||||
EnvFerryDaemonPort = "BOUNDARY_FERRY_LISTENING_PORT"
|
||||
envSkipClientAgent = "BOUNDARY_SKIP_CLIENT_AGENT"
|
||||
EnvClientAgentPort = "BOUNDARY_CLIENT_AGENT_LISTENING_PORT"
|
||||
|
||||
StoredTokenName = "HashiCorp Boundary Auth Token"
|
||||
)
|
||||
@@ -114,9 +114,9 @@ type Command struct {
|
||||
FlagRecoveryConfig string
|
||||
FlagOutputCurlString bool
|
||||
FlagSkipCacheDaemon bool
|
||||
FlagSkipFerry bool
|
||||
FlagSkipClientAgent bool
|
||||
|
||||
FlagFerryDaemonPort uint
|
||||
FlagClientAgentPort uint
|
||||
|
||||
FlagScopeId string
|
||||
FlagScopeName string
|
||||
@@ -492,20 +492,20 @@ func (c *Command) FlagSet(bit FlagSetBit) *FlagSets {
|
||||
})
|
||||
|
||||
f.BoolVar(&BoolVar{
|
||||
Name: "skip-ferry-daemon",
|
||||
Target: &c.FlagSkipFerry,
|
||||
Name: "skip-client-agent",
|
||||
Target: &c.FlagSkipClientAgent,
|
||||
Default: false,
|
||||
EnvVar: envSkipFerry,
|
||||
Usage: "Skips sending the auth token used for this command to the ferry daemon if it is running.",
|
||||
EnvVar: envSkipClientAgent,
|
||||
Usage: "Skips sending the auth token used for this command to the client agent if it is running.",
|
||||
Hidden: true,
|
||||
})
|
||||
|
||||
f.UintVar(&UintVar{
|
||||
Name: "ferry-port",
|
||||
Target: &c.FlagFerryDaemonPort,
|
||||
Name: "client-agent-port",
|
||||
Target: &c.FlagClientAgentPort,
|
||||
Default: 9300,
|
||||
EnvVar: EnvFerryDaemonPort,
|
||||
Usage: "The port on which the ferry daemon is listening.",
|
||||
EnvVar: EnvClientAgentPort,
|
||||
Usage: "The port on which the client agent is listening.",
|
||||
Hidden: true,
|
||||
})
|
||||
}
|
||||
|
||||
+23
-23
@@ -338,6 +338,13 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) {
|
||||
}
|
||||
}),
|
||||
|
||||
"client-agent": func() (cli.Command, error) {
|
||||
return &unsupported.UnsupportedCommand{
|
||||
Command: base.NewCommand(ui, opts...),
|
||||
CommandName: "client-agent",
|
||||
}, nil
|
||||
},
|
||||
|
||||
"config": func() (cli.Command, error) {
|
||||
return &config.Command{
|
||||
Command: base.NewCommand(ui, opts...),
|
||||
@@ -417,22 +424,6 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) {
|
||||
}
|
||||
}),
|
||||
|
||||
"database": func() (cli.Command, error) {
|
||||
return &database.Command{
|
||||
Command: base.NewCommand(ui, opts...),
|
||||
}, nil
|
||||
},
|
||||
"database init": func() (cli.Command, error) {
|
||||
return &database.InitCommand{
|
||||
Server: base.NewServer(base.NewCommand(ui, opts...)),
|
||||
}, nil
|
||||
},
|
||||
"database migrate": func() (cli.Command, error) {
|
||||
return &database.MigrateCommand{
|
||||
Command: base.NewCommand(ui, opts...),
|
||||
}, nil
|
||||
},
|
||||
|
||||
"credential-libraries": func() (cli.Command, error) {
|
||||
return &credentiallibrariescmd.Command{
|
||||
Command: base.NewCommand(ui, opts...),
|
||||
@@ -644,6 +635,22 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) {
|
||||
}, nil
|
||||
},
|
||||
|
||||
"database": func() (cli.Command, error) {
|
||||
return &database.Command{
|
||||
Command: base.NewCommand(ui, opts...),
|
||||
}, nil
|
||||
},
|
||||
"database init": func() (cli.Command, error) {
|
||||
return &database.InitCommand{
|
||||
Server: base.NewServer(base.NewCommand(ui, opts...)),
|
||||
}, nil
|
||||
},
|
||||
"database migrate": func() (cli.Command, error) {
|
||||
return &database.MigrateCommand{
|
||||
Command: base.NewCommand(ui, opts...),
|
||||
}, nil
|
||||
},
|
||||
|
||||
"delete": func() (cli.Command, error) {
|
||||
return &genericcmd.Command{
|
||||
Command: base.NewCommand(ui, opts...),
|
||||
@@ -651,13 +658,6 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) {
|
||||
}, nil
|
||||
},
|
||||
|
||||
"ferry": func() (cli.Command, error) {
|
||||
return &unsupported.UnsupportedCommand{
|
||||
Command: base.NewCommand(ui, opts...),
|
||||
CommandName: "ferry",
|
||||
}, nil
|
||||
},
|
||||
|
||||
"groups": func() (cli.Command, error) {
|
||||
return &groupscmd.Command{
|
||||
Command: base.NewCommand(ui, opts...),
|
||||
|
||||
+6
-6
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
package ferry
|
||||
package clientagentcmd
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -26,7 +26,7 @@ type UpsertTokenRequest struct {
|
||||
}
|
||||
|
||||
// addToken builds the UpsertTokenRequest using the client's address and token.
|
||||
// It then sends the request to the ferry daemon.
|
||||
// It then sends the request to the client agent.
|
||||
// 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.
|
||||
@@ -48,12 +48,12 @@ func addToken(ctx context.Context, apiClient *api.Client, port uint) (*api.Respo
|
||||
client.RetryWaitMin = 100 * time.Millisecond
|
||||
client.RetryWaitMax = 1500 * time.Millisecond
|
||||
|
||||
// TODO (ICU-13140): Until we release ferry feature, do not retry attempts
|
||||
// to connect to the ferry daemon since it adds a noticeably long delay to
|
||||
// TODO (ICU-13140): Until we release the client agent, do not retry attempts
|
||||
// to connect to the client agent since it adds a noticeably long delay to
|
||||
// the command.
|
||||
client.RetryMax = 0
|
||||
|
||||
req, err := retryablehttp.NewRequestWithContext(ctx, "POST", ferryUrl(port, "v1/tokens"),
|
||||
req, err := retryablehttp.NewRequestWithContext(ctx, "POST", clientAgentUrl(port, "v1/tokens"),
|
||||
retryablehttp.ReaderFunc(func() (io.Reader, error) {
|
||||
b, err := json.Marshal(&pa)
|
||||
if err != nil {
|
||||
@@ -67,7 +67,7 @@ func addToken(ctx context.Context, apiClient *api.Client, port uint) (*api.Respo
|
||||
req.Header.Set("content-type", "application/json")
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("Error when sending request to the ferry daemon: %w.", err)
|
||||
return nil, nil, fmt.Errorf("Error when sending request to the client agent: %w.", err)
|
||||
}
|
||||
apiResp := api.NewResponse(resp)
|
||||
apiErr, err := apiResp.Decode(nil)
|
||||
@@ -0,0 +1,72 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
package clientagentcmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/cmd/base"
|
||||
"github.com/mitchellh/cli"
|
||||
"github.com/posener/complete"
|
||||
)
|
||||
|
||||
var (
|
||||
_ cli.Command = (*ClientAgentCommand)(nil)
|
||||
_ cli.CommandAutocomplete = (*ClientAgentCommand)(nil)
|
||||
)
|
||||
|
||||
type ClientAgentCommand struct {
|
||||
*base.Command
|
||||
}
|
||||
|
||||
func (c *ClientAgentCommand) Synopsis() string {
|
||||
return "Manages the Boundary client agent"
|
||||
}
|
||||
|
||||
func (c *ClientAgentCommand) Help() string {
|
||||
helpText := `
|
||||
Usage: boundary client-agent [sub command] [options]
|
||||
|
||||
This command allows interacting with the Boundary client agent.
|
||||
|
||||
Get the status of the agent:
|
||||
|
||||
$ boundary client-agent status
|
||||
|
||||
Pause and resume the agent:
|
||||
|
||||
$ boundary client-agent pause
|
||||
$ boundary client-agent resume
|
||||
|
||||
List active transparent sessions:
|
||||
|
||||
$ boundary client-agent sessions
|
||||
|
||||
For a full list of examples, please see the documentation.
|
||||
|
||||
`
|
||||
return strings.TrimSpace(helpText)
|
||||
}
|
||||
|
||||
func (c *ClientAgentCommand) Flags() *base.FlagSets {
|
||||
return c.FlagSet(base.FlagSetNone)
|
||||
}
|
||||
|
||||
func (c *ClientAgentCommand) AutocompleteArgs() complete.Predictor {
|
||||
return complete.PredictNothing
|
||||
}
|
||||
|
||||
func (c *ClientAgentCommand) AutocompleteFlags() complete.Flags {
|
||||
return c.Flags().Completions()
|
||||
}
|
||||
|
||||
func (c *ClientAgentCommand) Run(args []string) int {
|
||||
return cli.RunResultHelp
|
||||
}
|
||||
|
||||
// clientAgentUrl constructs the full URL for a client agent request given a port and path.
|
||||
func clientAgentUrl(port uint, path string) string {
|
||||
return fmt.Sprintf("http://127.0.0.1:%d/%s", port, path)
|
||||
}
|
||||
+13
-13
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
package ferry
|
||||
package clientagentcmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -26,16 +26,16 @@ type PauseCommand struct {
|
||||
}
|
||||
|
||||
func (c *PauseCommand) Synopsis() string {
|
||||
return "Pauses the running boundary ferry daemon"
|
||||
return "Pauses the running boundary client agent"
|
||||
}
|
||||
|
||||
func (c *PauseCommand) Help() string {
|
||||
helpText := `
|
||||
Usage: boundary ferry pause
|
||||
Usage: boundary client-agent pause
|
||||
|
||||
Pause the boundary ferry daemon:
|
||||
Pause the boundary client agent:
|
||||
|
||||
$ boundary ferry pause
|
||||
$ boundary client-agent pause
|
||||
|
||||
For a full list of examples, please see the documentation.
|
||||
|
||||
@@ -54,11 +54,11 @@ func (c *PauseCommand) Flags() *base.FlagSets {
|
||||
})
|
||||
|
||||
f.UintVar(&base.UintVar{
|
||||
Name: "ferry-port",
|
||||
Target: &c.FlagFerryDaemonPort,
|
||||
Name: "client-agent--port",
|
||||
Target: &c.FlagClientAgentPort,
|
||||
Default: 9300,
|
||||
EnvVar: base.EnvFerryDaemonPort,
|
||||
Usage: "The port on which the ferry daemon is listening.",
|
||||
EnvVar: base.EnvClientAgentPort,
|
||||
Usage: "The port on which the client agent is listening.",
|
||||
})
|
||||
|
||||
return set
|
||||
@@ -86,7 +86,7 @@ func (c *PauseCommand) Run(args []string) int {
|
||||
return base.CommandCliError
|
||||
}
|
||||
if apiErr != nil {
|
||||
c.PrintApiError(apiErr, "Error from ferry daemon when attempting to pause")
|
||||
c.PrintApiError(apiErr, "Error from client agent when attempting to pause")
|
||||
return base.CommandApiError
|
||||
}
|
||||
|
||||
@@ -96,19 +96,19 @@ func (c *PauseCommand) Run(args []string) int {
|
||||
return base.CommandCliError
|
||||
}
|
||||
default:
|
||||
c.UI.Output("Ferry has been successfully paused.")
|
||||
c.UI.Output("The client agent has been successfully paused.")
|
||||
}
|
||||
return base.CommandSuccess
|
||||
}
|
||||
|
||||
func (c *PauseCommand) Pause(ctx context.Context) (*api.Response, *api.Error, error) {
|
||||
const op = "ferry.(PauseCommand).Pause"
|
||||
const op = "clientagentcmd.(PauseCommand).Pause"
|
||||
client := retryablehttp.NewClient()
|
||||
client.Logger = nil
|
||||
client.RetryWaitMin = 100 * time.Millisecond
|
||||
client.RetryWaitMax = 1000 * time.Millisecond
|
||||
|
||||
req, err := retryablehttp.NewRequestWithContext(ctx, "POST", ferryUrl(c.FlagFerryDaemonPort, "v1/pause"), nil)
|
||||
req, err := retryablehttp.NewRequestWithContext(ctx, "POST", clientAgentUrl(c.FlagClientAgentPort, "v1/pause"), nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
+13
-13
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
package ferry
|
||||
package clientagentcmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -26,16 +26,16 @@ type ResumeCommand struct {
|
||||
}
|
||||
|
||||
func (c *ResumeCommand) Synopsis() string {
|
||||
return "Resumes the paused boundary ferry daemon"
|
||||
return "Resumes the paused boundary client agent"
|
||||
}
|
||||
|
||||
func (c *ResumeCommand) Help() string {
|
||||
helpText := `
|
||||
Usage: boundary ferry resume
|
||||
Usage: boundary client-agent resume
|
||||
|
||||
Resume the boundary ferry daemon:
|
||||
Resume the boundary client agent:
|
||||
|
||||
$ boundary ferry resume
|
||||
$ boundary client-agent resume
|
||||
|
||||
For a full list of examples, please see the documentation.
|
||||
|
||||
@@ -54,11 +54,11 @@ func (c *ResumeCommand) Flags() *base.FlagSets {
|
||||
})
|
||||
|
||||
f.UintVar(&base.UintVar{
|
||||
Name: "ferry-port",
|
||||
Target: &c.FlagFerryDaemonPort,
|
||||
Name: "client-agent-port",
|
||||
Target: &c.FlagClientAgentPort,
|
||||
Default: 9300,
|
||||
EnvVar: base.EnvFerryDaemonPort,
|
||||
Usage: "The port on which the ferry daemon is listening.",
|
||||
EnvVar: base.EnvClientAgentPort,
|
||||
Usage: "The port on which the client agent is listening.",
|
||||
})
|
||||
|
||||
return set
|
||||
@@ -86,7 +86,7 @@ func (c *ResumeCommand) Run(args []string) int {
|
||||
return base.CommandCliError
|
||||
}
|
||||
if apiErr != nil {
|
||||
c.PrintApiError(apiErr, "Error from ferry daemon when attempting to resume")
|
||||
c.PrintApiError(apiErr, "Error from client agent when attempting to resume")
|
||||
return base.CommandApiError
|
||||
}
|
||||
|
||||
@@ -96,19 +96,19 @@ func (c *ResumeCommand) Run(args []string) int {
|
||||
return base.CommandCliError
|
||||
}
|
||||
default:
|
||||
c.UI.Output("Ferry has been successfully resumed.")
|
||||
c.UI.Output("The client agent has been successfully resumed.")
|
||||
}
|
||||
return base.CommandSuccess
|
||||
}
|
||||
|
||||
func (c *ResumeCommand) Resume(ctx context.Context) (*api.Response, *api.Error, error) {
|
||||
const op = "ferry.(ResumeCommand).Resume"
|
||||
const op = "clientagentcmd.(ResumeCommand).Resume"
|
||||
client := retryablehttp.NewClient()
|
||||
client.Logger = nil
|
||||
client.RetryWaitMin = 100 * time.Millisecond
|
||||
client.RetryWaitMax = 1000 * time.Millisecond
|
||||
|
||||
req, err := retryablehttp.NewRequestWithContext(ctx, "POST", ferryUrl(c.FlagFerryDaemonPort, "v1/resume"), nil)
|
||||
req, err := retryablehttp.NewRequestWithContext(ctx, "POST", clientAgentUrl(c.FlagClientAgentPort, "v1/resume"), nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
+12
-12
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
package ferry
|
||||
package clientagentcmd
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -31,16 +31,16 @@ type SessionsCommand struct {
|
||||
}
|
||||
|
||||
func (c *SessionsCommand) Synopsis() string {
|
||||
return "List active transparent sessions managed by the Ferry daemon."
|
||||
return "List active transparent sessions managed by the client agent."
|
||||
}
|
||||
|
||||
func (c *SessionsCommand) Help() string {
|
||||
helpText := `
|
||||
Usage: boundary ferry sessions [options]
|
||||
Usage: boundary client-agent sessions [options]
|
||||
|
||||
List the active transparent sessions:
|
||||
|
||||
$ boundary ferry sessions
|
||||
$ boundary client-agent sessions
|
||||
|
||||
For a full list of examples, please see the documentation.
|
||||
|
||||
@@ -59,11 +59,11 @@ func (c *SessionsCommand) Flags() *base.FlagSets {
|
||||
})
|
||||
|
||||
f.UintVar(&base.UintVar{
|
||||
Name: "ferry-port",
|
||||
Target: &c.FlagFerryDaemonPort,
|
||||
Name: "client-agent-port",
|
||||
Target: &c.FlagClientAgentPort,
|
||||
Default: 9300,
|
||||
EnvVar: base.EnvFerryDaemonPort,
|
||||
Usage: "The port on which the ferry daemon is listening.",
|
||||
EnvVar: base.EnvClientAgentPort,
|
||||
Usage: "The port on which the client agent is listening.",
|
||||
})
|
||||
|
||||
return set
|
||||
@@ -91,7 +91,7 @@ func (c *SessionsCommand) Run(args []string) int {
|
||||
return base.CommandCliError
|
||||
}
|
||||
if apiErr != nil {
|
||||
c.PrintApiError(apiErr, "Error from ferry daemon when getting its Sessions")
|
||||
c.PrintApiError(apiErr, "Error from client agent when getting its Sessions")
|
||||
return base.CommandApiError
|
||||
}
|
||||
|
||||
@@ -120,13 +120,13 @@ type ListSessionsResponse struct {
|
||||
}
|
||||
|
||||
func (c *SessionsCommand) Sessions(ctx context.Context) (*api.Response, *ListSessionsResponse, *api.Error, error) {
|
||||
const op = "ferry.(SessionsCommand).Sessions"
|
||||
const op = "clientagentcmd.(SessionsCommand).Sessions"
|
||||
client := retryablehttp.NewClient()
|
||||
client.Logger = nil
|
||||
client.RetryWaitMin = 100 * time.Millisecond
|
||||
client.RetryWaitMax = 1500 * time.Millisecond
|
||||
|
||||
req, err := retryablehttp.NewRequestWithContext(ctx, "GET", ferryUrl(c.FlagFerryDaemonPort, "v1/sessions"), nil)
|
||||
req, err := retryablehttp.NewRequestWithContext(ctx, "GET", clientAgentUrl(c.FlagClientAgentPort, "v1/sessions"), nil)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
@@ -146,7 +146,7 @@ func (c *SessionsCommand) Sessions(ctx context.Context) (*api.Response, *ListSes
|
||||
res := &ListSessionsResponse{}
|
||||
apiErr, err := apiResp.Decode(&res)
|
||||
if err != nil {
|
||||
return nil, nil, nil, fmt.Errorf("Error when sending request to the ferry daemon: %w.", err)
|
||||
return nil, nil, nil, fmt.Errorf("Error when sending request to the client agent: %w.", err)
|
||||
}
|
||||
if apiErr != nil {
|
||||
return apiResp, nil, apiErr, nil
|
||||
+13
-13
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
package ferry
|
||||
package clientagentcmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -27,16 +27,16 @@ type StatusCommand struct {
|
||||
}
|
||||
|
||||
func (c *StatusCommand) Synopsis() string {
|
||||
return "Get the status information of the running boundary ferry daemon"
|
||||
return "Get the status information of the running boundary client agent"
|
||||
}
|
||||
|
||||
func (c *StatusCommand) Help() string {
|
||||
helpText := `
|
||||
Usage: boundary ferry status [options]
|
||||
Usage: boundary client-agent status [options]
|
||||
|
||||
Get the status of the boundary ferry daemon:
|
||||
Get the status of the boundary client agent:
|
||||
|
||||
$ boundary ferry status
|
||||
$ boundary client-agent status
|
||||
|
||||
For a full list of examples, please see the documentation.
|
||||
|
||||
@@ -55,11 +55,11 @@ func (c *StatusCommand) Flags() *base.FlagSets {
|
||||
})
|
||||
|
||||
f.UintVar(&base.UintVar{
|
||||
Name: "ferry-port",
|
||||
Target: &c.FlagFerryDaemonPort,
|
||||
Name: "client-agent-port",
|
||||
Target: &c.FlagClientAgentPort,
|
||||
Default: 9300,
|
||||
EnvVar: base.EnvFerryDaemonPort,
|
||||
Usage: "The port on which the ferry daemon is listening.",
|
||||
EnvVar: base.EnvClientAgentPort,
|
||||
Usage: "The port on which the client agent is listening.",
|
||||
})
|
||||
|
||||
return set
|
||||
@@ -87,7 +87,7 @@ func (c *StatusCommand) Run(args []string) int {
|
||||
return base.CommandCliError
|
||||
}
|
||||
if apiErr != nil {
|
||||
c.PrintApiError(apiErr, "Error from ferry daemon when getting its status")
|
||||
c.PrintApiError(apiErr, "Error from client agent when getting its status")
|
||||
return base.CommandApiError
|
||||
}
|
||||
|
||||
@@ -113,13 +113,13 @@ type GetStatusResponse struct {
|
||||
}
|
||||
|
||||
func (c *StatusCommand) Status(ctx context.Context) (*api.Response, *GetStatusResponse, *api.Error, error) {
|
||||
const op = "ferry.(StatusCommand).Status"
|
||||
const op = "clientagentcmd.(StatusCommand).Status"
|
||||
client := retryablehttp.NewClient()
|
||||
client.Logger = nil
|
||||
client.RetryWaitMin = 100 * time.Millisecond
|
||||
client.RetryWaitMax = 1500 * time.Millisecond
|
||||
|
||||
req, err := retryablehttp.NewRequestWithContext(ctx, "GET", ferryUrl(c.FlagFerryDaemonPort, "v1/status"), nil)
|
||||
req, err := retryablehttp.NewRequestWithContext(ctx, "GET", clientAgentUrl(c.FlagClientAgentPort, "v1/status"), nil)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
@@ -139,7 +139,7 @@ func (c *StatusCommand) Status(ctx context.Context) (*api.Response, *GetStatusRe
|
||||
res := &GetStatusResponse{}
|
||||
apiErr, err := apiResp.Decode(&res)
|
||||
if err != nil {
|
||||
return nil, nil, nil, fmt.Errorf("Error when sending request to the ferry daemon: %w.", err)
|
||||
return nil, nil, nil, fmt.Errorf("Error when sending request to the client agent: %w.", err)
|
||||
}
|
||||
if apiErr != nil {
|
||||
return apiResp, nil, apiErr, nil
|
||||
+6
-6
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
package ferry
|
||||
package clientagentcmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -11,17 +11,17 @@ import (
|
||||
)
|
||||
|
||||
// TODO (ICU-13140): Remove this and re-enable error output for background
|
||||
// ferry daemon token sending.
|
||||
// client agent token sending.
|
||||
const allowErrorOutput = false
|
||||
|
||||
func init() {
|
||||
if err := wrapper.RegisterSuccessfulCommandCallback("ferry", hook); err != nil {
|
||||
if err := wrapper.RegisterSuccessfulCommandCallback("client-agent", hook); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func hook(ctx context.Context, baseCmd *base.Command, token string) {
|
||||
if baseCmd.FlagSkipFerry {
|
||||
if baseCmd.FlagSkipClientAgent {
|
||||
return
|
||||
}
|
||||
client, err := baseCmd.Client()
|
||||
@@ -32,11 +32,11 @@ func hook(ctx context.Context, baseCmd *base.Command, token string) {
|
||||
if token != "" {
|
||||
client.SetToken(token)
|
||||
}
|
||||
_, apiErr, err := addToken(ctx, client, baseCmd.FlagFerryDaemonPort)
|
||||
_, apiErr, err := addToken(ctx, client, baseCmd.FlagClientAgentPort)
|
||||
if err != nil && allowErrorOutput {
|
||||
baseCmd.PrintCliError(err)
|
||||
}
|
||||
if apiErr != nil && allowErrorOutput {
|
||||
baseCmd.PrintApiError(apiErr, "sending token to ferry daemon in the background")
|
||||
baseCmd.PrintApiError(apiErr, "sending token to client agent in the background")
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
package ferry
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/cmd/base"
|
||||
"github.com/mitchellh/cli"
|
||||
"github.com/posener/complete"
|
||||
)
|
||||
|
||||
var (
|
||||
_ cli.Command = (*FerryCommand)(nil)
|
||||
_ cli.CommandAutocomplete = (*FerryCommand)(nil)
|
||||
)
|
||||
|
||||
type FerryCommand struct {
|
||||
*base.Command
|
||||
}
|
||||
|
||||
func (c *FerryCommand) Synopsis() string {
|
||||
return "Manages the Boundary ferry daemon"
|
||||
}
|
||||
|
||||
func (c *FerryCommand) Help() string {
|
||||
helpText := `
|
||||
Usage: boundary ferry [sub command] [options]
|
||||
|
||||
This command allows interacting with the Boundary ferry daemon.
|
||||
|
||||
Get the status of the daemon:
|
||||
|
||||
$ boundary ferry status
|
||||
|
||||
Pause and resume the daemon:
|
||||
|
||||
$ boundary ferry pause
|
||||
$ boundary ferry resume
|
||||
|
||||
List active transparent sessions:
|
||||
|
||||
$ boundary ferry sessions
|
||||
|
||||
For a full list of examples, please see the documentation.
|
||||
|
||||
`
|
||||
return strings.TrimSpace(helpText)
|
||||
}
|
||||
|
||||
func (c *FerryCommand) Flags() *base.FlagSets {
|
||||
return c.FlagSet(base.FlagSetNone)
|
||||
}
|
||||
|
||||
func (c *FerryCommand) AutocompleteArgs() complete.Predictor {
|
||||
return complete.PredictNothing
|
||||
}
|
||||
|
||||
func (c *FerryCommand) AutocompleteFlags() complete.Flags {
|
||||
return c.Flags().Completions()
|
||||
}
|
||||
|
||||
func (c *FerryCommand) Run(args []string) int {
|
||||
return cli.RunResultHelp
|
||||
}
|
||||
|
||||
// ferryUrl constructs the full URL for a ferry request given a port and path.
|
||||
func ferryUrl(port uint, path string) string {
|
||||
return fmt.Sprintf("http://127.0.0.1:%d/%s", port, path)
|
||||
}
|
||||
@@ -5,34 +5,34 @@ package cmd
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/boundary/internal/cmd/base"
|
||||
"github.com/hashicorp/boundary/internal/cmd/commands/ferry"
|
||||
"github.com/hashicorp/boundary/internal/cmd/commands/clientagentcmd"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
func init() {
|
||||
extraCommandsFuncs = append(extraCommandsFuncs, func(ui, serverCmdUi cli.Ui, runOpts *RunOptions) {
|
||||
Commands["ferry"] = func() (cli.Command, error) {
|
||||
return &ferry.FerryCommand{
|
||||
Commands["client-agent"] = func() (cli.Command, error) {
|
||||
return &clientagentcmd.ClientAgentCommand{
|
||||
Command: base.NewCommand(ui),
|
||||
}, nil
|
||||
}
|
||||
Commands["ferry status"] = func() (cli.Command, error) {
|
||||
return &ferry.StatusCommand{
|
||||
Commands["client-agent status"] = func() (cli.Command, error) {
|
||||
return &clientagentcmd.StatusCommand{
|
||||
Command: base.NewCommand(ui),
|
||||
}, nil
|
||||
}
|
||||
Commands["ferry pause"] = func() (cli.Command, error) {
|
||||
return &ferry.PauseCommand{
|
||||
Commands["client-agent pause"] = func() (cli.Command, error) {
|
||||
return &clientagentcmd.PauseCommand{
|
||||
Command: base.NewCommand(ui),
|
||||
}, nil
|
||||
}
|
||||
Commands["ferry resume"] = func() (cli.Command, error) {
|
||||
return &ferry.ResumeCommand{
|
||||
Commands["client-agent resume"] = func() (cli.Command, error) {
|
||||
return &clientagentcmd.ResumeCommand{
|
||||
Command: base.NewCommand(ui),
|
||||
}, nil
|
||||
}
|
||||
Commands["ferry sessions"] = func() (cli.Command, error) {
|
||||
return &ferry.SessionsCommand{
|
||||
Commands["client-agent sessions"] = func() (cli.Command, error) {
|
||||
return &clientagentcmd.SessionsCommand{
|
||||
Command: base.NewCommand(ui),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -7,34 +7,34 @@ package cmd
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/boundary/internal/cmd/base"
|
||||
"github.com/hashicorp/boundary/internal/cmd/commands/ferry"
|
||||
"github.com/hashicorp/boundary/internal/cmd/commands/clientagentcmd"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
func init() {
|
||||
extraCommandsFuncs = append(extraCommandsFuncs, func(ui, serverCmdUi cli.Ui, runOpts *RunOptions) {
|
||||
Commands["ferry"] = func() (cli.Command, error) {
|
||||
return &ferry.FerryCommand{
|
||||
Commands["client-agent"] = func() (cli.Command, error) {
|
||||
return &clientagentcmd.ClientAgentCommand{
|
||||
Command: base.NewCommand(ui),
|
||||
}, nil
|
||||
}
|
||||
Commands["ferry status"] = func() (cli.Command, error) {
|
||||
return &ferry.StatusCommand{
|
||||
Commands["client-agent status"] = func() (cli.Command, error) {
|
||||
return &clientagentcmd.StatusCommand{
|
||||
Command: base.NewCommand(ui),
|
||||
}, nil
|
||||
}
|
||||
Commands["ferry pause"] = func() (cli.Command, error) {
|
||||
return &ferry.PauseCommand{
|
||||
Commands["client-agent pause"] = func() (cli.Command, error) {
|
||||
return &clientagentcmd.PauseCommand{
|
||||
Command: base.NewCommand(ui),
|
||||
}, nil
|
||||
}
|
||||
Commands["ferry resume"] = func() (cli.Command, error) {
|
||||
return &ferry.ResumeCommand{
|
||||
Commands["client-agent resume"] = func() (cli.Command, error) {
|
||||
return &clientagentcmd.ResumeCommand{
|
||||
Command: base.NewCommand(ui),
|
||||
}, nil
|
||||
}
|
||||
Commands["ferry sessions"] = func() (cli.Command, error) {
|
||||
return &ferry.SessionsCommand{
|
||||
Commands["client-agent sessions"] = func() (cli.Command, error) {
|
||||
return &clientagentcmd.SessionsCommand{
|
||||
Command: base.NewCommand(ui),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ func RunCustom(args []string, runOpts *RunOptions) (exitCode int) {
|
||||
|
||||
initCommands(ui, serverCmdUi, runOpts)
|
||||
|
||||
hiddenCommands := []string{"version", "ferry", "ferry status", "ferry pause", "ferry resume"}
|
||||
hiddenCommands := []string{"version", "client-agent", "client-agent status", "client-agent pause", "client-agent resume", "client-agent sessions"}
|
||||
|
||||
cli := &cli.CLI{
|
||||
Name: "boundary",
|
||||
@@ -298,7 +298,7 @@ func groupedHelpFunc(f cli.HelpFunc) cli.HelpFunc {
|
||||
typeSpecificCommands := make([]string, 0, len(commands)-cap(genericCommands)-cap(clientCommands))
|
||||
for k := range commands {
|
||||
switch k {
|
||||
case "authenticate", "config", "connect", "daemon", "dev", "ferry", "logout", "search", "server":
|
||||
case "authenticate", "config", "connect", "daemon", "dev", "client-agent", "logout", "search", "server":
|
||||
clientCommands = append(clientCommands, k)
|
||||
case "read", "update", "delete":
|
||||
genericCommands = append(genericCommands, k)
|
||||
|
||||
Reference in new issue
Block a user