sync

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package sync handles synchronization between PocketBase and Nebula config generation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

Manager orchestrates real-time synchronization between PocketBase record changes and Nebula certificate/config generation.

SYNCHRONIZATION STRATEGY:

  • PocketBase Record Change → Certificate Generation → Config Generation
  • Automatic generation on create/update
  • Network CIDR changes trigger regeneration of all host configs
  • Lighthouse changes trigger regeneration of peer host configs (their static_host_map and lighthouse sections embed lighthouse data)

RECURSION PREVENTION: Saves issued by pb-nebula itself (cert/config regeneration, peer fan-out) re-fire the update hooks, and e.Record.Original() inside those re-fired hooks still holds the PRE-REQUEST snapshot — so any field-diff check that triggered once would trigger again on the re-entry, looping forever. All internal writes therefore go through saveInternal, which marks the record ID in internalSaves; the update hook skips events for marked records.

func NewManager

func NewManager(app *pocketbase.PocketBase, certManager *cert.Manager, configGen *config.Generator,
	ipamManager *ipam.Manager, options types.Options, logger *utils.Logger) *Manager

NewManager creates a new sync manager with all required dependencies.

PARAMETERS:

  • app: PocketBase application instance
  • certManager: Certificate manager for generating certificates
  • configGen: Config generator for generating Nebula configs
  • ipamManager: IPAM manager for IP validation
  • options: Configuration options
  • logger: Logger instance

RETURNS: - Manager instance ready for hook setup

func (*Manager) SetupHooks

func (sm *Manager) SetupHooks() error

SetupHooks registers PocketBase event hooks for real-time Nebula synchronization.

HOOK CATEGORIES: - CA hooks: Handle CA creation - Network hooks: Handle network lifecycle and validation - Host hooks: Handle host lifecycle, certificate generation, and config generation

RETURNS: - nil on successful hook registration - error if hook setup fails

Jump to

Keyboard shortcuts

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