docker

package
v0.11.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2024 License: MPL-2.0 Imports: 42 Imported by: 1

Documentation

Index

Constants

View Source
const DefaultNumCores = 3
View Source
const MaxClusterNameLength = 52

Variables

This section is empty.

Functions

func NewReplicationSetDocker

func NewReplicationSetDocker(t *testing.T, opts *DockerClusterOptions) (*testcluster.ReplicationSet, error)

Types

type CertificateGetter

type CertificateGetter struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

CertificateGetter satisfies ReloadFunc and its GetCertificate method satisfies the tls.GetCertificate function signature. Currently it does not allow changing paths after the fact.

func NewCertificateGetter

func NewCertificateGetter(certFile, keyFile, passphrase string) *CertificateGetter

func (*CertificateGetter) GetCertificate

func (cg *CertificateGetter) GetCertificate(clientHello *tls.ClientHelloInfo) (*tls.Certificate, error)

func (*CertificateGetter) Reload

func (cg *CertificateGetter) Reload() error

type DockerCluster

type DockerCluster struct {
	ClusterName string

	ClusterNodes []*DockerClusterNode

	// Certificate fields
	*testcluster.CA
	RootCAs *x509.CertPool

	DockerAPI *docker.Client
	ID        string
	Logger    log.Logger
	// contains filtered or unexported fields
}

DockerCluster is used to managing the lifecycle of the test Vault cluster

func NewDockerCluster

func NewDockerCluster(ctx context.Context, opts *DockerClusterOptions) (*DockerCluster, error)

func NewTestDockerCluster

func NewTestDockerCluster(t *testing.T, opts *DockerClusterOptions) *DockerCluster

func (*DockerCluster) AddNode

func (dc *DockerCluster) AddNode(ctx context.Context, opts *DockerClusterOptions) error

func (*DockerCluster) Cleanup

func (dc *DockerCluster) Cleanup()

func (*DockerCluster) ClusterID

func (dc *DockerCluster) ClusterID() string

func (*DockerCluster) GetActiveClusterNode added in v0.11.0

func (dc *DockerCluster) GetActiveClusterNode() *DockerClusterNode

func (*DockerCluster) GetBarrierKeys

func (dc *DockerCluster) GetBarrierKeys() [][]byte

func (*DockerCluster) GetBarrierOrRecoveryKeys

func (dc *DockerCluster) GetBarrierOrRecoveryKeys() [][]byte

func (*DockerCluster) GetCACertPEMFile

func (dc *DockerCluster) GetCACertPEMFile() string

func (*DockerCluster) GetRecoveryKeys

func (dc *DockerCluster) GetRecoveryKeys() [][]byte

func (*DockerCluster) GetRootToken

func (dc *DockerCluster) GetRootToken() string

GetRootToken returns the root token of the cluster, if set

func (*DockerCluster) NamedLogger

func (dc *DockerCluster) NamedLogger(s string) log.Logger

func (*DockerCluster) Nodes

func (*DockerCluster) SetBarrierKeys

func (dc *DockerCluster) SetBarrierKeys(keys [][]byte)

func (*DockerCluster) SetRecoveryKeys

func (dc *DockerCluster) SetRecoveryKeys(keys [][]byte)

func (*DockerCluster) SetRootToken

func (dc *DockerCluster) SetRootToken(s string)

type DockerClusterNode

type DockerClusterNode struct {
	NodeID   string
	HostPort string

	ServerCert        *x509.Certificate
	ServerCertBytes   []byte
	ServerCertPEM     []byte
	ServerCertPEMFile string
	ServerKey         *ecdsa.PrivateKey
	ServerKeyPEM      []byte
	ServerKeyPEMFile  string

	WorkDir   string
	Cluster   *DockerCluster
	Container *types.ContainerJSON
	DockerAPI *docker.Client

	Logger log.Logger

	RealAPIAddr          string
	ContainerNetworkName string
	ContainerIPAddress   string
	ImageRepo            string
	ImageTag             string
	DataVolumeName       string

	AllClients []*api.Client
	// contains filtered or unexported fields
}

DockerClusterNode represents a single instance of Vault in a cluster

func (*DockerClusterNode) APIClient

func (n *DockerClusterNode) APIClient() *api.Client

func (*DockerClusterNode) APIClientN added in v0.10.0

func (n *DockerClusterNode) APIClientN(listenerNumber int) (*api.Client, error)

func (*DockerClusterNode) AddNetworkDelay

func (n *DockerClusterNode) AddNetworkDelay(ctx context.Context, delay time.Duration, targetIP string) error

func (*DockerClusterNode) Cleanup

func (n *DockerClusterNode) Cleanup()

Cleanup kills the container of the node and deletes its data volume

func (*DockerClusterNode) Name

func (n *DockerClusterNode) Name() string

func (*DockerClusterNode) PartitionFromCluster added in v0.10.1

func (n *DockerClusterNode) PartitionFromCluster(ctx context.Context) error

PartitionFromCluster will cause the node to be disconnected at the network level from the rest of the docker cluster. It does so in a way that the node will not see TCP RSTs and all packets it sends will be "black holed". It attempts to keep packets to and from the host intact which allows docker daemon to continue streaming logs and any test code to continue making requests from the host to the partitioned node.

func (*DockerClusterNode) Pause

func (n *DockerClusterNode) Pause(ctx context.Context) error

func (*DockerClusterNode) Restart added in v0.11.0

func (n *DockerClusterNode) Restart(ctx context.Context) error

func (*DockerClusterNode) Start

func (*DockerClusterNode) Stop

func (n *DockerClusterNode) Stop()

Stop kills the container of the node

func (*DockerClusterNode) TLSConfig

func (n *DockerClusterNode) TLSConfig() *tls.Config

func (*DockerClusterNode) UnpartitionFromCluster added in v0.10.1

func (n *DockerClusterNode) UnpartitionFromCluster(ctx context.Context) error

UnpartitionFromCluster reverses a previous call to PartitionFromCluster and restores full connectivity. Currently assumes the default "bridge" network.

type DockerClusterOptions

type DockerClusterOptions struct {
	testcluster.ClusterOptions
	CAKey       *ecdsa.PrivateKey
	NetworkName string
	ImageRepo   string
	ImageTag    string
	CA          *testcluster.CA
	VaultBinary string
	Args        []string
	StartProbe  func(*api.Client) error
	Storage     testcluster.ClusterStorage
	DisableTLS  bool
}

DockerClusterOptions has options for setting up the docker cluster

func DefaultOptions

func DefaultOptions(t *testing.T) *DockerClusterOptions

type LogConsumerWriter

type LogConsumerWriter struct {
	// contains filtered or unexported fields
}

func (LogConsumerWriter) Write

func (l LogConsumerWriter) Write(p []byte) (n int, err error)

type ReloadFunc

type ReloadFunc func() error

ReloadFunc are functions that are called when a reload is requested

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL