mirror of
https://github.com/status-im/consul.git
synced 2025-01-26 05:29:55 +00:00
b4151780d6
1. Upgraded agent can inherit the persisted token and join the cluster 2. Agent token prior to upgrade is still valid after upgrade 3. Enable ACL in the agent configuration
78 lines
1.6 KiB
Go
78 lines
1.6 KiB
Go
package cluster
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/testcontainers/testcontainers-go"
|
|
|
|
"github.com/hashicorp/consul/api"
|
|
|
|
"github.com/hashicorp/consul/test/integration/consul-container/libs/utils"
|
|
)
|
|
|
|
// Agent represent a Consul agent abstraction
|
|
type Agent interface {
|
|
GetIP() string
|
|
GetClient() *api.Client
|
|
NewClient(string, bool) (*api.Client, error)
|
|
GetName() string
|
|
GetAgentName() string
|
|
GetPod() testcontainers.Container
|
|
ClaimAdminPort() (int, error)
|
|
GetConfig() Config
|
|
GetInfo() AgentInfo
|
|
GetDatacenter() string
|
|
IsServer() bool
|
|
RegisterTermination(func() error)
|
|
Terminate() error
|
|
TerminateAndRetainPod(bool) error
|
|
Upgrade(ctx context.Context, config Config) error
|
|
Exec(ctx context.Context, cmd []string) (string, error)
|
|
DataDir() string
|
|
}
|
|
|
|
// Config is a set of configurations required to create a Agent
|
|
//
|
|
// Constructed by (Builder).ToAgentConfig()
|
|
type Config struct {
|
|
ScratchDir string
|
|
CertVolume string
|
|
CACert string
|
|
JSON string
|
|
ConfigBuilder *ConfigBuilder
|
|
Image string
|
|
Version string
|
|
Cmd []string
|
|
LogConsumer testcontainers.LogConsumer
|
|
|
|
// service defaults
|
|
UseAPIWithTLS bool // TODO
|
|
UseGRPCWithTLS bool
|
|
|
|
ACLEnabled bool
|
|
}
|
|
|
|
func (c *Config) DockerImage() string {
|
|
return utils.DockerImage(c.Image, c.Version)
|
|
}
|
|
|
|
// Clone copies everything. It is the caller's job to replace fields that
|
|
// should be unique.
|
|
func (c Config) Clone() Config {
|
|
c2 := c
|
|
if c.Cmd != nil {
|
|
c2.Cmd = make([]string, len(c.Cmd))
|
|
for i, v := range c.Cmd {
|
|
c2.Cmd[i] = v
|
|
}
|
|
}
|
|
return c2
|
|
}
|
|
|
|
// TODO: refactor away
|
|
type AgentInfo struct {
|
|
CACertFile string
|
|
UseTLSForAPI bool
|
|
UseTLSForGRPC bool
|
|
}
|