* Add boundary ferry command (#4462) * Add boundary ferry status (#4463) * Add sending auth token automatically to ferry daemon (#4465) * Hide ferry cmds, background error msgs, and dont retry background add-token requests (#4571)
43 lines
1002 B
Go
43 lines
1002 B
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package ferry
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/hashicorp/boundary/internal/cmd/base"
|
|
"github.com/hashicorp/boundary/internal/cmd/wrapper"
|
|
)
|
|
|
|
// TODO (ICU-13140): Remove this and re-enable error output for background
|
|
// ferry daemon token sending.
|
|
const allowErrorOutput = false
|
|
|
|
func init() {
|
|
if err := wrapper.RegisterSuccessfulCommandCallback("ferry", hook); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func hook(ctx context.Context, baseCmd *base.Command, token string) {
|
|
if baseCmd.FlagSkipFerry {
|
|
return
|
|
}
|
|
client, err := baseCmd.Client()
|
|
if err != nil && allowErrorOutput {
|
|
baseCmd.PrintCliError(err)
|
|
return
|
|
}
|
|
if token != "" {
|
|
client.SetToken(token)
|
|
}
|
|
_, apiErr, err := addToken(ctx, client, baseCmd.FlagFerryDaemonPort)
|
|
if err != nil && allowErrorOutput {
|
|
baseCmd.PrintCliError(err)
|
|
}
|
|
if apiErr != nil && allowErrorOutput {
|
|
baseCmd.PrintApiError(apiErr, "sending token to ferry daemon in the background")
|
|
}
|
|
}
|