forked from fengbaicanhe/cockroach-prod
/
driver.go
72 lines (59 loc) · 2.42 KB
/
driver.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright 2015 The Cockroach Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License. See the AUTHORS file
// for names of contributors.
//
// Author: Marc Berhault (marc@cockroachlabs.com)
package drivers
import "github.com/cockroachdb/cockroach-prod/base"
// HostConfig describes the docker-machine host config.
// Driver is the driver-specific config.
// We only specify the fields we currently use. For the full list, see:
// https://github.com/docker/machine/blob/master/libmachine/host.go
type HostConfig struct {
DriverName string
Driver DriverConfig
}
// DriverConfig describes the docker-machine host driver configs.
// It is implemented by each driver.
type DriverConfig interface {
// DataDir is the directory used as the data directory.
DataDir() string
// IPAddress is the node address cockroach should bind to.
IPAddress() string
// GossipAddress is the address to reach the gossip network.
GossipAddress() string
}
// Driver is the interface for all drivers.
type Driver interface {
// Context returns the base context.
Context() *base.Context
// DockerMachineDriver returns the name of the docker-machine driver.
DockerMachineDriver() string
// Init is called when creating the driver. This will typically
// setup credentials.
Init() error
// DockerMachineCreateArgs returns the list of driver-specific arguments
// to pass to 'docker-machine create'
DockerMachineCreateArgs() []string
// PrintStatus asks the driver to print some basic status to stdout.
PrintStatus()
// GetNodeConfig takes a node name and reads its docker-machine config.
GetNodeConfig(name string) (*HostConfig, error)
// AfterFirstNode runs any steps needed after the first node was created.
AfterFirstNode() error
// StartNode runs any steps needed when starting an existing node.
StartNode(name string, config *HostConfig) error
// StopNode runs any steps needed when stopping a node.
StopNode(name string, config *HostConfig) error
}