fakecontrolplane

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 27 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package fakecontrolplane is a control plane that implements api/controlplane/v1 for tests: enrollment with one-time tokens, client certificates from its own CA, and the Connect stream. It records what the operator sends, sends policy snapshots when told to, and can be told to fail. It is not a control plane: no storage, no tenants.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Addr to listen on; default a random local port.
	Addr string
	// Hosts its server certificate is valid for, the first one in
	// Endpoint; default localhost and 127.0.0.1.
	Hosts []string
}

Options configure a server.

type Server

type Server struct {
	controlplanev1.UnimplementedControlPlaneServiceServer

	// CertLifetime is the lifetime of the client certificates it issues.
	CertLifetime time.Duration
	// HeartbeatInterval is sent in Welcome.
	HeartbeatInterval time.Duration
	// AcceptEvents is sent in Welcome: whether replicas send events.
	AcceptEvents bool
	// contains filtered or unexported fields
}

Server is a fake control plane.

func Start

func Start() (*Server, error)

Start serves on a random local port until Stop.

func StartWith

func StartWith(o Options) (*Server, error)

StartWith serves as configured until Stop.

func (*Server) AddToken

func (s *Server) AddToken(token string)

AddToken makes a one-time enrollment token valid.

func (*Server) CAPEM

func (s *Server) CAPEM() []byte

CAPEM is the CA that signs the server and client certificates.

func (*Server) Connect

Connect implements the stream: Hello first, then Welcome; ClusterState, heartbeats, policy snapshots and their answers, and certificate renewal.

func (*Server) DropEnrollResponses

func (s *Server) DropEnrollResponses(n int)

DropEnrollResponses drops the responses of the next n Enroll calls.

func (*Server) Endpoint

func (s *Server) Endpoint() string

Endpoint is the address for InkwallConfig.spec.controlPlane.endpoint.

func (*Server) Enroll

Enroll implements the contract: the first call burns the token; a retry with the same token and public key gets the same certificate.

func (*Server) Events

func (s *Server) Events() []*eventsv1.SecurityEvent

Events returns the distinct events stored, in no order.

func (*Server) FailConnect

func (s *Server) FailConnect(err error)

FailConnect ends every Connect with err (a gRPC status), or stops failing with nil.

func (*Server) Resync

func (s *Server) Resync() (bool, error)

Resync asks the cluster on the open primary stream for a full ClusterState, and reports whether one was open.

func (*Server) SendSnapshot

func (s *Server) SendSnapshot(snap *controlplanev1.PolicySnapshot) (bool, error)

SendSnapshot sends snap on the open primary stream, and reports whether one was open. Either way, a Managed cluster gets it when it connects with an older policy version, as from a control plane.

func (*Server) SetAcceptEvents

func (s *Server) SetAcceptEvents(accept bool)

SetAcceptEvents changes what the next Welcome says.

func (*Server) SnapshotVersion

func (s *Server) SnapshotVersion() uint64

SnapshotVersion is the version of the newest snapshot (0: none).

func (*Server) Stats

func (s *Server) Stats() Stats

Stats returns what the server saw so far.

func (*Server) Stop

func (s *Server) Stop()

Stop stops serving.

type Stats

type Stats struct {
	EnrollCalls  int
	ConnectCalls int
	Hellos       []*controlplanev1.Hello
	// States are the ClusterStates received, oldest first.
	States     []*controlplanev1.ClusterState
	Heartbeats int
	// Events counts the distinct events stored; EventUploads the uploads
	// received (resends included); EventsDropped what replicas reported
	// dropping, once per buffer and sequence.
	Events        int
	EventUploads  int
	EventsDropped uint64
	Renewals      int
	// Clusters is how many distinct clusters enrolled.
	Clusters int
	// Acks and Nacks answered the policy snapshots, oldest first.
	Acks  []uint64
	Nacks []*controlplanev1.PolicyNack
}

Stats is what the server saw.

Jump to

Keyboard shortcuts

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