hcp

package
v1.14.4 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2023 License: MPL-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BootstrapConfig

type BootstrapConfig struct {
	Name            string
	BootstrapExpect int
	GossipKey       string
	TLSCert         string
	TLSCertKey      string
	TLSCAs          []string
	ConsulConfig    string
}

type Client

type Client interface {
	FetchBootstrap(ctx context.Context) (*BootstrapConfig, error)
	PushServerStatus(ctx context.Context, status *ServerStatus) error
	DiscoverServers(ctx context.Context) ([]string, error)
}

Client interface exposes HCP operations that can be invoked by Consul

func NewClient

func NewClient(cfg config.CloudConfig) (Client, error)

type Deps

type Deps struct {
	Client   Client
	Provider scada.Provider
}

Deps contains the interfaces that the rest of Consul core depends on for HCP integration.

func NewDeps

func NewDeps(cfg config.CloudConfig, logger hclog.Logger) (d Deps, err error)

type Manager

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

func NewManager

func NewManager(cfg ManagerConfig) *Manager

NewManager returns an initialized Manager with a zero configuration. It won't do anything until UpdateConfig is called with a config that provides credentials to contact HCP.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context)

Run executes the Manager it's designed to be run in its own goroutine for the life of a server agent. It should be run even if HCP is not configured yet for servers since a config update might configure it later and UpdateConfig called. It will effectively do nothing if there are no HCP credentials set other than wait for some to be added.

func (*Manager) SendUpdate

func (m *Manager) SendUpdate()

func (*Manager) UpdateConfig

func (m *Manager) UpdateConfig(cfg ManagerConfig)

type ManagerConfig

type ManagerConfig struct {
	Client Client

	StatusFn    StatusCallback
	MinInterval time.Duration
	MaxInterval time.Duration

	Logger hclog.Logger
}

type MockClient

type MockClient struct {
	mock.Mock
}

MockClient is an autogenerated mock type for the Client type

func NewMockClient

func NewMockClient(t mockConstructorTestingTNewMockClient) *MockClient

NewMockClient creates a new instance of MockClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*MockClient) DiscoverServers

func (_m *MockClient) DiscoverServers(ctx context.Context) ([]string, error)

DiscoverServers provides a mock function with given fields: ctx

func (*MockClient) EXPECT

func (_m *MockClient) EXPECT() *MockClient_Expecter

func (*MockClient) FetchBootstrap

func (_m *MockClient) FetchBootstrap(ctx context.Context) (*BootstrapConfig, error)

FetchBootstrap provides a mock function with given fields: ctx

func (*MockClient) PushServerStatus

func (_m *MockClient) PushServerStatus(ctx context.Context, status *ServerStatus) error

PushServerStatus provides a mock function with given fields: ctx, status

type MockClient_DiscoverServers_Call

type MockClient_DiscoverServers_Call struct {
	*mock.Call
}

MockClient_DiscoverServers_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DiscoverServers'

func (*MockClient_DiscoverServers_Call) Return

func (*MockClient_DiscoverServers_Call) Run

type MockClient_Expecter

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

func (*MockClient_Expecter) DiscoverServers

func (_e *MockClient_Expecter) DiscoverServers(ctx interface{}) *MockClient_DiscoverServers_Call

DiscoverServers is a helper method to define mock.On call

  • ctx context.Context

func (*MockClient_Expecter) FetchBootstrap

func (_e *MockClient_Expecter) FetchBootstrap(ctx interface{}) *MockClient_FetchBootstrap_Call

FetchBootstrap is a helper method to define mock.On call

  • ctx context.Context

func (*MockClient_Expecter) PushServerStatus

func (_e *MockClient_Expecter) PushServerStatus(ctx interface{}, status interface{}) *MockClient_PushServerStatus_Call

PushServerStatus is a helper method to define mock.On call

  • ctx context.Context
  • status *ServerStatus

type MockClient_FetchBootstrap_Call

type MockClient_FetchBootstrap_Call struct {
	*mock.Call
}

MockClient_FetchBootstrap_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FetchBootstrap'

func (*MockClient_FetchBootstrap_Call) Return

func (*MockClient_FetchBootstrap_Call) Run

type MockClient_PushServerStatus_Call

type MockClient_PushServerStatus_Call struct {
	*mock.Call
}

MockClient_PushServerStatus_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PushServerStatus'

func (*MockClient_PushServerStatus_Call) Return

func (*MockClient_PushServerStatus_Call) Run

type MockHCPServer

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

func NewMockHCPServer

func NewMockHCPServer() *MockHCPServer

func (*MockHCPServer) AddEndpoint

func (s *MockHCPServer) AddEndpoint(e TestEndpoint)

AddEndpoint allows adding additional endpoints from other packages e.g. bootstrap (which can't be merged into one package due to dependency cycles). It's not safe to call this concurrently with any other call to AddEndpoint or ServeHTTP.

func (*MockHCPServer) ServeHTTP

func (s *MockHCPServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ServerAutopilot

type ServerAutopilot struct {
	FailureTolerance int
	Healthy          bool
	MinQuorum        int
	NumServers       int
	NumVoters        int
}

type ServerRaft

type ServerRaft struct {
	IsLeader             bool
	KnownLeader          bool
	AppliedIndex         uint64
	TimeSinceLastContact time.Duration
}

type ServerStatus

type ServerStatus struct {
	ID         string
	Name       string
	Version    string
	LanAddress string
	GossipPort int
	RPCPort    int

	Autopilot ServerAutopilot
	Raft      ServerRaft
	TLS       ServerTLSInfo

	ScadaStatus string
}

type ServerTLSInfo

type ServerTLSInfo struct {
	Enabled              bool
	CertExpiry           time.Time
	CertName             string
	CertSerial           string
	VerifyIncoming       bool
	VerifyOutgoing       bool
	VerifyServerHostname bool
}

type StatusCallback

type StatusCallback func(context.Context) (ServerStatus, error)

type TestEndpoint

type TestEndpoint struct {
	Methods    []string
	PathSuffix string
	Handler    func(r *http.Request, cluster resource.Resource) (interface{}, error)
}

Directories

Path Synopsis
Package bootstrap handles bootstrapping an agent's config from HCP.
Package bootstrap handles bootstrapping an agent's config from HCP.

Jump to

Keyboard shortcuts

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