sysctl

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 16 Imported by: 0 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 sysctl provides kernel parameter management via /etc/sysctl.d/. It writes conf files directly and tracks state in the file-state KV for SHA-based idempotency and drift detection.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateResult

type CreateResult struct {
	Key     string `json:"key"`
	Changed bool   `json:"changed"`
	Error   string `json:"error,omitempty"`
}

CreateResult represents the outcome of a sysctl create operation.

type Darwin

type Darwin struct{}

Darwin implements the Provider interface for Darwin (macOS). All methods return ErrUnsupported as sysctl.d is not available on macOS.

func NewDarwinProvider

func NewDarwinProvider() *Darwin

NewDarwinProvider factory to create a new Darwin instance.

func (*Darwin) Create

func (d *Darwin) Create(
	_ context.Context,
	_ Entry,
) (*CreateResult, error)

Create returns ErrUnsupported on Darwin.

func (*Darwin) Delete

func (d *Darwin) Delete(
	_ context.Context,
	_ string,
) (*DeleteResult, error)

Delete returns ErrUnsupported on Darwin.

func (*Darwin) Get

func (d *Darwin) Get(
	_ context.Context,
	_ string,
) (*Entry, error)

Get returns ErrUnsupported on Darwin.

func (*Darwin) List

func (d *Darwin) List(
	_ context.Context,
) ([]Entry, error)

List returns ErrUnsupported on Darwin.

func (*Darwin) Update

func (d *Darwin) Update(
	_ context.Context,
	_ Entry,
) (*UpdateResult, error)

Update returns ErrUnsupported on Darwin.

type Debian

type Debian struct {
	provider.FactsAware
	// contains filtered or unexported fields
}

Debian implements the Provider interface for Debian-family systems. It writes sysctl conf files directly to /etc/sysctl.d/ and tracks state in the file-state KV for idempotency. Unlike the cron meta-provider, sysctl generates trivial content inline rather than fetching from the NATS Object Store.

func NewDebianProvider

func NewDebianProvider(
	logger *slog.Logger,
	fs avfs.VFS,
	stateKV jetstream.KeyValue,
	execManager exec.Manager,
	hostname string,
) *Debian

NewDebianProvider factory to create a new Debian instance.

func (*Debian) Create

func (d *Debian) Create(
	ctx context.Context,
	entry Entry,
) (*CreateResult, error)

Create deploys a new sysctl conf file and applies it. Idempotent: returns Changed: false if the key is already managed.

func (*Debian) Delete

func (d *Debian) Delete(
	ctx context.Context,
	key string,
) (*DeleteResult, error)

Delete removes a managed sysctl conf file and reloads defaults.

func (*Debian) Get

func (d *Debian) Get(
	ctx context.Context,
	key string,
) (*Entry, error)

Get returns a single sysctl entry by key with current runtime value.

func (*Debian) List

func (d *Debian) List(
	ctx context.Context,
) ([]Entry, error)

List returns all osapi-managed sysctl entries with current runtime values.

func (*Debian) Update

func (d *Debian) Update(
	ctx context.Context,
	entry Entry,
) (*UpdateResult, error)

Update redeploys an existing managed sysctl conf file. Fails if the key is not currently managed. Idempotent: if the content hasn't changed, Changed is false.

type DeleteResult

type DeleteResult struct {
	Key     string `json:"key"`
	Changed bool   `json:"changed"`
	Error   string `json:"error,omitempty"`
}

DeleteResult represents the outcome of a sysctl delete operation.

type Entry

type Entry struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

Entry represents a sysctl kernel parameter.

type Linux

type Linux struct{}

Linux implements the Provider interface for generic Linux. All methods return ErrUnsupported as this is a generic Linux stub.

func NewLinuxProvider

func NewLinuxProvider() *Linux

NewLinuxProvider factory to create a new Linux instance.

func (*Linux) Create

func (l *Linux) Create(
	_ context.Context,
	_ Entry,
) (*CreateResult, error)

Create returns ErrUnsupported on generic Linux.

func (*Linux) Delete

func (l *Linux) Delete(
	_ context.Context,
	_ string,
) (*DeleteResult, error)

Delete returns ErrUnsupported on generic Linux.

func (*Linux) Get

func (l *Linux) Get(
	_ context.Context,
	_ string,
) (*Entry, error)

Get returns ErrUnsupported on generic Linux.

func (*Linux) List

func (l *Linux) List(
	_ context.Context,
) ([]Entry, error)

List returns ErrUnsupported on generic Linux.

func (*Linux) Update

func (l *Linux) Update(
	_ context.Context,
	_ Entry,
) (*UpdateResult, error)

Update returns ErrUnsupported on generic Linux.

type Provider

type Provider interface {
	// List returns all osapi-managed sysctl entries with current runtime values.
	List(ctx context.Context) ([]Entry, error)
	// Get returns a single sysctl entry by key with current runtime value.
	Get(ctx context.Context, key string) (*Entry, error)
	// Create deploys a new sysctl conf file and applies it. Idempotent: returns Changed: false if already managed.
	Create(ctx context.Context, entry Entry) (*CreateResult, error)
	// Update redeploys an existing sysctl conf file. Fails if not managed.
	Update(ctx context.Context, entry Entry) (*UpdateResult, error)
	// Delete removes a managed sysctl conf file and reloads defaults.
	Delete(ctx context.Context, key string) (*DeleteResult, error)
}

Provider implements the methods to manage sysctl entries.

type UpdateResult

type UpdateResult struct {
	Key     string `json:"key"`
	Changed bool   `json:"changed"`
	Error   string `json:"error,omitempty"`
}

UpdateResult represents the outcome of a sysctl update operation.

Directories

Path Synopsis
Package mocks provides mock implementations for testing.
Package mocks provides mock implementations for testing.

Jump to

Keyboard shortcuts

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