Plumb contexts through commands
This is to prepare for otel support. Signed-off-by: Brian Goff <cpuguy83@gmail.com> Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
committed by
Sebastiaan van Stijn
parent
9eb632dc7c
commit
5400a48aaf
@ -1,6 +1,7 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
@ -15,12 +16,12 @@ func newPromoteCommand(dockerCli command.Cli) *cobra.Command {
|
||||
Short: "Promote one or more nodes to manager in the swarm",
|
||||
Args: cli.RequiresMinArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runPromote(dockerCli, args)
|
||||
return runPromote(cmd.Context(), dockerCli, args)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func runPromote(dockerCli command.Cli, nodes []string) error {
|
||||
func runPromote(ctx context.Context, dockerCli command.Cli, nodes []string) error {
|
||||
promote := func(node *swarm.Node) error {
|
||||
if node.Spec.Role == swarm.NodeRoleManager {
|
||||
fmt.Fprintf(dockerCli.Out(), "Node %s is already a manager.\n", node.ID)
|
||||
@ -32,5 +33,5 @@ func runPromote(dockerCli command.Cli, nodes []string) error {
|
||||
success := func(nodeID string) {
|
||||
fmt.Fprintf(dockerCli.Out(), "Node %s promoted to a manager in the swarm.\n", nodeID)
|
||||
}
|
||||
return updateNodes(dockerCli, nodes, promote, success)
|
||||
return updateNodes(ctx, dockerCli, nodes, promote, success)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user