instance

package
v0.71.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: BSD-3-Clause, AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// SetupPATEnabledEnvKey enables setup-time Personal Access Token creation.
	SetupPATEnabledEnvKey = "NB_SETUP_PAT_ENABLED"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultManager

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

DefaultManager is the default implementation of Manager.

func (*DefaultManager) CreateOwnerUser

func (m *DefaultManager) CreateOwnerUser(ctx context.Context, email, password, name string) (*idp.UserData, error)

CreateOwnerUser creates the initial owner user in the embedded IDP.

func (*DefaultManager) GetVersionInfo added in v0.64.2

func (m *DefaultManager) GetVersionInfo(ctx context.Context) (*VersionInfo, error)

GetVersionInfo returns version information for NetBird components.

func (*DefaultManager) IsSetupRequired

func (m *DefaultManager) IsSetupRequired(_ context.Context) (bool, error)

IsSetupRequired checks if instance setup is required. Setup is required when: 1. Embedded IDP is enabled 2. No accounts exist in the store

func (*DefaultManager) RollbackSetup added in v0.70.5

func (m *DefaultManager) RollbackSetup(ctx context.Context, userID string) error

RollbackSetup undoes a successful CreateOwnerUser: deletes the user from the embedded IDP and reloads setupRequired from persistent state.

type Manager

type Manager interface {
	// IsSetupRequired checks if instance setup is required.
	// Returns true if embedded IDP is enabled and no accounts exist.
	IsSetupRequired(ctx context.Context) (bool, error)

	// CreateOwnerUser creates the initial owner user in the embedded IDP.
	// This should only be called when IsSetupRequired returns true.
	CreateOwnerUser(ctx context.Context, email, password, name string) (*idp.UserData, error)

	// RollbackSetup reverses a successful CreateOwnerUser by deleting the user
	// from the embedded IDP and reloading setupRequired from persistent state, so
	// /api/setup can be retried only when no accounts or local users remain. Used
	// when post-user steps (account or PAT creation) fail and the caller wants a
	// clean slate.
	RollbackSetup(ctx context.Context, userID string) error

	// GetVersionInfo returns version information for NetBird components.
	GetVersionInfo(ctx context.Context) (*VersionInfo, error)
}

Manager handles instance-level operations like initial setup.

func NewManager

func NewManager(ctx context.Context, store store.Store, idpManager idp.Manager) (Manager, error)

NewManager creates a new instance manager. If idpManager is not an EmbeddedIdPManager, setup-related operations will return appropriate defaults.

type SetupOptions added in v0.70.5

type SetupOptions struct {
	// CreatePAT requests creation of a setup Personal Access Token. It is honored
	// only when SetupPATEnabledEnvKey is set to "true".
	CreatePAT bool
	// PATExpireInDays defaults to 1 day when CreatePAT is requested and setup PAT
	// creation is enabled.
	PATExpireInDays *int
}

SetupOptions controls optional work performed during initial instance setup.

type SetupResult added in v0.70.5

type SetupResult struct {
	User          *idp.UserData
	PATPlainToken string
}

SetupResult contains resources created during initial instance setup.

type SetupService added in v0.70.5

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

SetupService orchestrates the initial setup use case across the instance and account bounded contexts and owns the compensation logic when a later step fails.

func NewSetupService added in v0.70.5

func NewSetupService(instanceManager Manager, accountManager account.Manager) *SetupService

NewSetupService creates a setup use-case service.

func (*SetupService) SetupOwner added in v0.70.5

func (m *SetupService) SetupOwner(ctx context.Context, email, password, name string, opts SetupOptions) (*SetupResult, error)

SetupOwner creates the initial owner user and, when requested and enabled by SetupPATEnabledEnvKey, provisions the account and a setup Personal Access Token. If account or PAT provisioning fails, created resources are rolled back so setup can be retried. If account rollback fails, user rollback is skipped to avoid leaving an account without its owner user.

type VersionInfo added in v0.64.2

type VersionInfo struct {
	// CurrentVersion is the running management server version
	CurrentVersion string
	// DashboardVersion is the latest available dashboard version from GitHub
	DashboardVersion string
	// ManagementVersion is the latest available management version from GitHub
	ManagementVersion string
	// ManagementUpdateAvailable indicates if a newer management version is available
	ManagementUpdateAvailable bool
}

VersionInfo contains version information for NetBird components

Jump to

Keyboard shortcuts

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