Revendor engine-api
Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
This commit is contained in:
parent
2cc5bd33ee
commit
852091ad41
7 changed files with 46 additions and 50 deletions
|
@ -60,7 +60,7 @@ clone git golang.org/x/net 2beffdc2e92c8a3027590f898fe88f69af48a3f8 https://gith
|
||||||
clone git golang.org/x/sys eb2c74142fd19a79b3f237334c7384d5167b1b46 https://github.com/golang/sys.git
|
clone git golang.org/x/sys eb2c74142fd19a79b3f237334c7384d5167b1b46 https://github.com/golang/sys.git
|
||||||
clone git github.com/docker/go-units 651fc226e7441360384da338d0fd37f2440ffbe3
|
clone git github.com/docker/go-units 651fc226e7441360384da338d0fd37f2440ffbe3
|
||||||
clone git github.com/docker/go-connections fa2850ff103453a9ad190da0df0af134f0314b3d
|
clone git github.com/docker/go-connections fa2850ff103453a9ad190da0df0af134f0314b3d
|
||||||
clone git github.com/docker/engine-api 1d247454d4307fb1ddf10d09fd2996394b085904
|
clone git github.com/docker/engine-api c977588a28fa81fbbb06c295e936853cef37cf27
|
||||||
clone git github.com/RackSec/srslog 259aed10dfa74ea2961eddd1d9847619f6e98837
|
clone git github.com/RackSec/srslog 259aed10dfa74ea2961eddd1d9847619f6e98837
|
||||||
clone git github.com/imdario/mergo 0.2.1
|
clone git github.com/imdario/mergo 0.2.1
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ type SwarmAPIClient interface {
|
||||||
SwarmJoin(ctx context.Context, req swarm.JoinRequest) error
|
SwarmJoin(ctx context.Context, req swarm.JoinRequest) error
|
||||||
SwarmLeave(ctx context.Context, force bool) error
|
SwarmLeave(ctx context.Context, force bool) error
|
||||||
SwarmInspect(ctx context.Context) (swarm.Swarm, error)
|
SwarmInspect(ctx context.Context) (swarm.Swarm, error)
|
||||||
SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec) error
|
SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags swarm.UpdateFlags) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// SystemAPIClient defines API client methods for the system
|
// SystemAPIClient defines API client methods for the system
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package client
|
package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
@ -9,9 +10,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// SwarmUpdate updates the Swarm.
|
// SwarmUpdate updates the Swarm.
|
||||||
func (cli *Client) SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec) error {
|
func (cli *Client) SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags swarm.UpdateFlags) error {
|
||||||
query := url.Values{}
|
query := url.Values{}
|
||||||
query.Set("version", strconv.FormatUint(version.Index, 10))
|
query.Set("version", strconv.FormatUint(version.Index, 10))
|
||||||
|
query.Set("rotate_worker_token", fmt.Sprintf("%v", flags.RotateWorkerToken))
|
||||||
|
query.Set("rotate_manager_token", fmt.Sprintf("%v", flags.RotateManagerToken))
|
||||||
resp, err := cli.post(ctx, "/swarm/update", query, swarm, nil)
|
resp, err := cli.post(ctx, "/swarm/update", query, swarm, nil)
|
||||||
ensureReaderClosed(resp)
|
ensureReaderClosed(resp)
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -30,7 +30,7 @@ var (
|
||||||
//
|
//
|
||||||
// This function deviates from the upstream version in golang.org/x/net/context/ctxhttp by
|
// This function deviates from the upstream version in golang.org/x/net/context/ctxhttp by
|
||||||
// taking a Sender interface rather than a *http.Client directly. That allow us to use
|
// taking a Sender interface rather than a *http.Client directly. That allow us to use
|
||||||
// this funcion with mocked clients and hijacked connections.
|
// this function with mocked clients and hijacked connections.
|
||||||
func Do(ctx context.Context, client transport.Sender, req *http.Request) (*http.Response, error) {
|
func Do(ctx context.Context, client transport.Sender, req *http.Request) (*http.Response, error) {
|
||||||
if client == nil {
|
if client == nil {
|
||||||
client = http.DefaultClient
|
client = http.DefaultClient
|
||||||
|
|
|
@ -45,8 +45,8 @@ type ExecConfig struct {
|
||||||
Privileged bool // Is the container in privileged mode
|
Privileged bool // Is the container in privileged mode
|
||||||
Tty bool // Attach standard streams to a tty.
|
Tty bool // Attach standard streams to a tty.
|
||||||
AttachStdin bool // Attach the standard input, makes possible user interaction
|
AttachStdin bool // Attach the standard input, makes possible user interaction
|
||||||
AttachStderr bool // Attach the standard output
|
AttachStderr bool // Attach the standard error
|
||||||
AttachStdout bool // Attach the standard error
|
AttachStdout bool // Attach the standard output
|
||||||
Detach bool // Execute in detach mode
|
Detach bool // Execute in detach mode
|
||||||
DetachKeys string // Escape keys for detach
|
DetachKeys string // Escape keys for detach
|
||||||
Cmd []string // Execution commands and args
|
Cmd []string // Execution commands and args
|
||||||
|
|
|
@ -15,7 +15,6 @@ type Node struct {
|
||||||
type NodeSpec struct {
|
type NodeSpec struct {
|
||||||
Annotations
|
Annotations
|
||||||
Role NodeRole `json:",omitempty"`
|
Role NodeRole `json:",omitempty"`
|
||||||
Membership NodeMembership `json:",omitempty"`
|
|
||||||
Availability NodeAvailability `json:",omitempty"`
|
Availability NodeAvailability `json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,16 +28,6 @@ const (
|
||||||
NodeRoleManager NodeRole = "manager"
|
NodeRoleManager NodeRole = "manager"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NodeMembership represents the membership of a node.
|
|
||||||
type NodeMembership string
|
|
||||||
|
|
||||||
const (
|
|
||||||
// NodeMembershipPending PENDING
|
|
||||||
NodeMembershipPending NodeMembership = "pending"
|
|
||||||
// NodeMembershipAccepted ACCEPTED
|
|
||||||
NodeMembershipAccepted NodeMembership = "accepted"
|
|
||||||
)
|
|
||||||
|
|
||||||
// NodeAvailability represents the availability of a node.
|
// NodeAvailability represents the availability of a node.
|
||||||
type NodeAvailability string
|
type NodeAvailability string
|
||||||
|
|
||||||
|
|
|
@ -7,37 +7,24 @@ type Swarm struct {
|
||||||
ID string
|
ID string
|
||||||
Meta
|
Meta
|
||||||
Spec Spec
|
Spec Spec
|
||||||
|
JoinTokens JoinTokens
|
||||||
|
}
|
||||||
|
|
||||||
|
// JoinTokens contains the tokens workers and managers need to join the swarm.
|
||||||
|
type JoinTokens struct {
|
||||||
|
Worker string
|
||||||
|
Manager string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Spec represents the spec of a swarm.
|
// Spec represents the spec of a swarm.
|
||||||
type Spec struct {
|
type Spec struct {
|
||||||
Annotations
|
Annotations
|
||||||
|
|
||||||
AcceptancePolicy AcceptancePolicy `json:",omitempty"`
|
|
||||||
Orchestration OrchestrationConfig `json:",omitempty"`
|
Orchestration OrchestrationConfig `json:",omitempty"`
|
||||||
Raft RaftConfig `json:",omitempty"`
|
Raft RaftConfig `json:",omitempty"`
|
||||||
Dispatcher DispatcherConfig `json:",omitempty"`
|
Dispatcher DispatcherConfig `json:",omitempty"`
|
||||||
CAConfig CAConfig `json:",omitempty"`
|
CAConfig CAConfig `json:",omitempty"`
|
||||||
|
TaskDefaults TaskDefaults `json:",omitempty"`
|
||||||
// DefaultLogDriver sets the log driver to use at task creation time if
|
|
||||||
// unspecified by a task.
|
|
||||||
//
|
|
||||||
// Updating this value will only have an affect on new tasks. Old tasks
|
|
||||||
// will continue use their previously configured log driver until
|
|
||||||
// recreated.
|
|
||||||
DefaultLogDriver *Driver `json:",omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// AcceptancePolicy represents the list of policies.
|
|
||||||
type AcceptancePolicy struct {
|
|
||||||
Policies []Policy `json:",omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Policy represents a role, autoaccept and secret.
|
|
||||||
type Policy struct {
|
|
||||||
Role NodeRole
|
|
||||||
Autoaccept bool
|
|
||||||
Secret *string `json:",omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// OrchestrationConfig represents orchestration configuration.
|
// OrchestrationConfig represents orchestration configuration.
|
||||||
|
@ -45,6 +32,17 @@ type OrchestrationConfig struct {
|
||||||
TaskHistoryRetentionLimit int64 `json:",omitempty"`
|
TaskHistoryRetentionLimit int64 `json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TaskDefaults parameterizes cluster-level task creation with default values.
|
||||||
|
type TaskDefaults struct {
|
||||||
|
// LogDriver selects the log driver to use for tasks created in the
|
||||||
|
// orchestrator if unspecified by a service.
|
||||||
|
//
|
||||||
|
// Updating this value will only have an affect on new tasks. Old tasks
|
||||||
|
// will continue use their previously configured log driver until
|
||||||
|
// recreated.
|
||||||
|
LogDriver *Driver `json:",omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// RaftConfig represents raft configuration.
|
// RaftConfig represents raft configuration.
|
||||||
type RaftConfig struct {
|
type RaftConfig struct {
|
||||||
SnapshotInterval uint64 `json:",omitempty"`
|
SnapshotInterval uint64 `json:",omitempty"`
|
||||||
|
@ -81,6 +79,7 @@ type ExternalCA struct {
|
||||||
// InitRequest is the request used to init a swarm.
|
// InitRequest is the request used to init a swarm.
|
||||||
type InitRequest struct {
|
type InitRequest struct {
|
||||||
ListenAddr string
|
ListenAddr string
|
||||||
|
AdvertiseAddr string
|
||||||
ForceNewCluster bool
|
ForceNewCluster bool
|
||||||
Spec Spec
|
Spec Spec
|
||||||
}
|
}
|
||||||
|
@ -88,10 +87,9 @@ type InitRequest struct {
|
||||||
// JoinRequest is the request used to join a swarm.
|
// JoinRequest is the request used to join a swarm.
|
||||||
type JoinRequest struct {
|
type JoinRequest struct {
|
||||||
ListenAddr string
|
ListenAddr string
|
||||||
|
AdvertiseAddr string
|
||||||
RemoteAddrs []string
|
RemoteAddrs []string
|
||||||
Secret string // accept by secret
|
JoinToken string // accept by secret
|
||||||
CACertHash string
|
|
||||||
Manager bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// LocalNodeState represents the state of the local node.
|
// LocalNodeState represents the state of the local node.
|
||||||
|
@ -111,6 +109,7 @@ const (
|
||||||
// Info represents generic information about swarm.
|
// Info represents generic information about swarm.
|
||||||
type Info struct {
|
type Info struct {
|
||||||
NodeID string
|
NodeID string
|
||||||
|
NodeAddr string
|
||||||
|
|
||||||
LocalNodeState LocalNodeState
|
LocalNodeState LocalNodeState
|
||||||
ControlAvailable bool
|
ControlAvailable bool
|
||||||
|
@ -119,7 +118,6 @@ type Info struct {
|
||||||
RemoteManagers []Peer
|
RemoteManagers []Peer
|
||||||
Nodes int
|
Nodes int
|
||||||
Managers int
|
Managers int
|
||||||
CACertHash string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Peer represents a peer.
|
// Peer represents a peer.
|
||||||
|
@ -127,3 +125,9 @@ type Peer struct {
|
||||||
NodeID string
|
NodeID string
|
||||||
Addr string
|
Addr string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UpdateFlags contains flags for SwarmUpdate.
|
||||||
|
type UpdateFlags struct {
|
||||||
|
RotateWorkerToken bool
|
||||||
|
RotateManagerToken bool
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue