consul

package
v0.10.5 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2020 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewIdentitiesClient added in v0.10.4

func NewIdentitiesClient(logger hclog.Logger, tokenDeriver TokenDeriverFunc) *identitiesClient

Types

type ConsulServiceAPI added in v0.9.0

type ConsulServiceAPI interface {
	// RegisterWorkload with Consul. Adds all service entries and checks to Consul.
	RegisterWorkload(*consul.WorkloadServices) error

	// RemoveWorkload from Consul. Removes all service entries and checks.
	RemoveWorkload(*consul.WorkloadServices)

	// UpdateWorkload in Consul. Does not alter the service if only checks have
	// changed.
	UpdateWorkload(old, newTask *consul.WorkloadServices) error

	// AllocRegistrations returns the registrations for the given allocation.
	AllocRegistrations(allocID string) (*consul.AllocRegistration, error)

	// UpdateTTL is used to update the TTL of a check.
	UpdateTTL(id, output, status string) error
}

ConsulServiceAPI is the interface the Nomad Client uses to register and remove services and checks from Consul.

type MockConsulOp added in v0.9.0

type MockConsulOp struct {
	Op         string // add, remove, or update
	AllocID    string
	Name       string // task or group name
	OccurredAt time.Time
}

MockConsulOp represents the register/deregister operations.

func NewMockConsulOp added in v0.9.0

func NewMockConsulOp(op, allocID, name string) MockConsulOp

type MockConsulServiceClient added in v0.9.0

type MockConsulServiceClient struct {

	// AllocRegistrationsFn allows injecting return values for the
	// AllocRegistrations function.
	AllocRegistrationsFn func(allocID string) (*consul.AllocRegistration, error)
	// contains filtered or unexported fields
}

MockConsulServiceClient implements the ConsulServiceAPI interface to record and log task registration/deregistration.

func NewMockConsulServiceClient added in v0.9.0

func NewMockConsulServiceClient(t testing.T, logger log.Logger) *MockConsulServiceClient

func (*MockConsulServiceClient) AllocRegistrations added in v0.9.0

func (m *MockConsulServiceClient) AllocRegistrations(allocID string) (*consul.AllocRegistration, error)

func (*MockConsulServiceClient) GetOps added in v0.9.0

func (m *MockConsulServiceClient) GetOps() []MockConsulOp

func (*MockConsulServiceClient) RegisterWorkload added in v0.10.2

func (m *MockConsulServiceClient) RegisterWorkload(svcs *consul.WorkloadServices) error

func (*MockConsulServiceClient) RemoveWorkload added in v0.10.2

func (m *MockConsulServiceClient) RemoveWorkload(svcs *consul.WorkloadServices)

func (*MockConsulServiceClient) UpdateTTL added in v0.10.0

func (m *MockConsulServiceClient) UpdateTTL(checkID, output, status string) error

func (*MockConsulServiceClient) UpdateWorkload added in v0.10.2

func (m *MockConsulServiceClient) UpdateWorkload(old, newSvcs *consul.WorkloadServices) error

type MockServiceIdentitiesClient added in v0.10.4

type MockServiceIdentitiesClient struct {

	// DeriveTokenFn allows the caller to control the DeriveToken function. If
	// not set an error is returned if found in DeriveTokenErrors and otherwise
	// a token is generated and returned
	DeriveTokenFn TokenDeriverFunc
	// contains filtered or unexported fields
}

MockServiceIdentitiesClient is used for testing the client for managing consul service identity tokens.

func NewMockServiceIdentitiesClient added in v0.10.4

func NewMockServiceIdentitiesClient() *MockServiceIdentitiesClient

NewMockServiceIdentitiesClient returns a MockServiceIdentitiesClient for testing.

func (*MockServiceIdentitiesClient) DeriveSITokens added in v0.10.4

func (mtc *MockServiceIdentitiesClient) DeriveSITokens(alloc *structs.Allocation, tasks []string) (map[string]string, error)

func (*MockServiceIdentitiesClient) DeriveTokenErrors added in v0.10.4

func (mtc *MockServiceIdentitiesClient) DeriveTokenErrors() map[string]map[string]error

func (*MockServiceIdentitiesClient) SetDeriveTokenError added in v0.10.4

func (mtc *MockServiceIdentitiesClient) SetDeriveTokenError(allocID string, tasks []string, err error)

type ServiceIdentityAPI added in v0.10.4

type ServiceIdentityAPI interface {
	// DeriveSITokens contacts the nomad server and requests consul service
	// identity tokens be generated for tasks in the allocation.
	DeriveSITokens(alloc *structs.Allocation, tasks []string) (map[string]string, error)
}

ServiceIdentityAPI is the interface the Nomad Client uses to request Consul Service Identity tokens through Nomad Server.

type TokenDeriverFunc added in v0.10.4

type TokenDeriverFunc func(*structs.Allocation, []string) (map[string]string, error)

TokenDeriverFunc takes an allocation and a set of tasks and derives a service identity token for each. Requests go through nomad server.

Jump to

Keyboard shortcuts

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