github.com/nullne/docker@v1.13.0-rc1/client/service_update.go (about)

     1  package client
     2  
     3  import (
     4  	"net/url"
     5  	"strconv"
     6  
     7  	"github.com/docker/docker/api/types"
     8  	"github.com/docker/docker/api/types/swarm"
     9  	"golang.org/x/net/context"
    10  )
    11  
    12  // ServiceUpdate updates a Service.
    13  func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) error {
    14  	var (
    15  		headers map[string][]string
    16  		query   = url.Values{}
    17  	)
    18  
    19  	if options.EncodedRegistryAuth != "" {
    20  		headers = map[string][]string{
    21  			"X-Registry-Auth": {options.EncodedRegistryAuth},
    22  		}
    23  	}
    24  
    25  	if options.RegistryAuthFrom != "" {
    26  		query.Set("registryAuthFrom", options.RegistryAuthFrom)
    27  	}
    28  
    29  	query.Set("version", strconv.FormatUint(version.Index, 10))
    30  
    31  	resp, err := cli.post(ctx, "/services/"+serviceID+"/update", query, service, headers)
    32  	ensureReaderClosed(resp)
    33  	return err
    34  }