code: func (c *Cluster) Update(version uint64, spec types.Spec, flags types.UpdateFlags) error {
  	return c.lockedManagerAction(func(ctx context.Context, state nodeState) error {
  		swarm, err := getSwarm(ctx, state.controlClient)
  		if err != nil {
  			return err
  		}
  
  		// Validate spec name.
  		if spec.Annotations.Name == "" {
  			spec.Annotations.Name = "default"
  		} else if spec.Annotations.Name != "default" {
  			return errdefs.InvalidParameter(errors.New(`swarm spec must be named "default"`))
  		}
  
  		// In update, client should provide the complete spec of the swarm, including
  		// Name and Labels. If a field is specified with 0 or nil, then the default value
  		// will be used to swarmkit.
  		clusterSpec, err := convert.SwarmSpecToGRPC(spec)
  		if err != nil {
  			return errdefs.InvalidParameter(err)
  		}
  
  		_, err = state.controlClient.UpdateCluster(
  			ctx,
  			&swarmapi.UpdateClusterRequest{
  				ClusterID: swarm.ID,
  				Spec:      &clusterSpec,
  				ClusterVersion: &swarmapi.Version{
  					Index: version,
  				},
  				Rotation: swarmapi.KeyRotation{
  					WorkerJoinToken:  flags.RotateWorkerToken,
  					ManagerJoinToken: flags.RotateManagerToken,
  					ManagerUnlockKey: flags.RotateManagerUnlockKey,
  				},
  			},
  		)
  		return err
  	})
  }
docs: // Update updates configuration of a managed swarm cluster.