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)
| 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. |
| 101 | func 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 |
| 113 | func pruneServices(ctx context.Context, dockerCLI command.Cli, namespace convert.Namespace, services map[string]struct{}) { |
no test coverage detected
searching dependent graphs…