lifecycle

package
v0.0.0-...-fb377d2 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProviderFirewalld = constant.FirewallProviderFirewalld
	ProviderUFW       = constant.FirewallProviderUFW
	ProviderIptables  = constant.FirewallProviderIptables
	ProviderNftables  = constant.FirewallProviderNftables
)

Variables

View Source
var ErrNotInstalled = errors.New("is not installed")

Functions

func DetectProvider

func DetectProvider() (string, error)

func InstalledProviders

func InstalledProviders() []string

Types

type Client

type Client interface {
	Name() string
	Start() error
	Stop() error
	Restart() error
	Status() (bool, error)
	Version() (string, error)
}

func NewClient

func NewClient() (Client, error)

func NewClientFor

func NewClientFor(provider string) (Client, error)

func NewNetfilterClients

func NewNetfilterClients() ([]Client, error)

type DockerRestartError

type DockerRestartError struct {
	Err error
}

DockerRestartError reports that the requested firewall operation completed, but rebuilding Docker's firewall rules failed.

func (*DockerRestartError) Error

func (e *DockerRestartError) Error() string

func (*DockerRestartError) Unwrap

func (e *DockerRestartError) Unwrap() error

type IptablesCommands

type IptablesCommands struct {
	IPv4     string
	IPv6     string
	Restore4 string
	Restore6 string
}

func ResolveIptablesCommands

func ResolveIptablesCommands() (IptablesCommands, error)

func (IptablesCommands) IPv6Available

func (c IptablesCommands) IPv6Available() bool

type Operation

type Operation string
const (
	OperationStart   Operation = "start"
	OperationStop    Operation = "stop"
	OperationRestart Operation = "restart"
)

type Operator

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

func NewOperator

func NewOperator(client Client) *Operator

func (*Operator) Operate

func (o *Operator) Operate(operation Operation, withDockerRestart bool, prepareStart func(Client) error) error

func (*Operator) StopWithPrepare

func (o *Operator) StopWithPrepare(withDockerRestart bool, prepareStop func() error) error

StopWithPrepare records dependent service state, runs preparation, stops the firewall, and optionally restarts Docker in that order.

type PreStopResetter

type PreStopResetter interface {
	ResetBeforeStop() error
}

PreStopResetter prepares a service-backed firewall reset without stopping the service. The lifecycle operator can then stop the service and perform dependent recovery, such as rebuilding Docker firewall rules, in order.

type Resetter

type Resetter interface {
	Reset() error
}

Resetter restores a service-backed firewall to its installation defaults. Implementations must leave the firewall disabled after a successful reset.

type Runtime

type Runtime struct {
	Provider string
	Iptables IptablesCommands
}

func DetectRuntime

func DetectRuntime() (Runtime, error)

type State

type State struct {
	Name     string
	IsActive bool
}

func LoadState

func LoadState(client Client) (State, error)

type Status

type Status struct {
	State
	Version string
}

func LoadStatus

func LoadStatus(client Client) (Status, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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