MCPcopy Index your code
hub / github.com/docker/cli / checkDaemonIsSwarmManager

Function checkDaemonIsSwarmManager

cli/command/stack/deploy.go:101–110  ·  view source on GitHub ↗

checkDaemonIsSwarmManager does an Info API call to verify that the daemon is a swarm manager. This is necessary because we must create networks before we create services, but the API call for creating a network does not return a proper status code when it can't create a network in the "global" scope

(ctx context.Context, dockerCli command.Cli)

Source from the content-addressed store, hash-verified

99// create services, but the API call for creating a network does not return a
100// proper status code when it can't create a network in the "global" scope.
101func checkDaemonIsSwarmManager(ctx context.Context, dockerCli command.Cli) error {
102 res, err := dockerCli.Client().Info(ctx, client.InfoOptions{})
103 if err != nil {
104 return err
105 }
106 if !res.Info.Swarm.ControlAvailable {
107 return errors.New(`this node is not a swarm manager. Use "docker swarm init" or "docker swarm join" to connect this node to swarm and try again`)
108 }
109 return nil
110}
111
112// pruneServices removes services that are no longer referenced in the source
113func pruneServices(ctx context.Context, dockerCLI command.Cli, namespace convert.Namespace, services map[string]struct{}) {

Callers 1

deployComposeFunction · 0.85

Calls 2

ClientMethod · 0.65
InfoMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…