Documentation
¶
Overview ¶
Package cron provides management of cron drop-in files and periodic scripts. Supports /etc/cron.d/ (custom schedules) and /etc/cron.{hourly,daily,weekly,monthly}/ (interval-based scripts). Delegates file writes to the file provider for SHA tracking, idempotency, and template rendering.
Index ¶
- type CreateResult
- type Darwin
- func (d *Darwin) Create(_ context.Context, _ Entry) (*CreateResult, error)
- func (d *Darwin) Delete(_ context.Context, _ string) (*DeleteResult, error)
- func (d *Darwin) Get(_ context.Context, _ string) (*Entry, error)
- func (d *Darwin) List(_ context.Context) ([]Entry, error)
- func (d *Darwin) Update(_ context.Context, _ Entry) (*UpdateResult, error)
- type Debian
- func (d *Debian) Create(ctx context.Context, entry Entry) (*CreateResult, error)
- func (d *Debian) Delete(ctx context.Context, name string) (*DeleteResult, error)
- func (d *Debian) Get(ctx context.Context, name string) (*Entry, error)
- func (d *Debian) List(ctx context.Context) ([]Entry, error)
- func (d *Debian) Update(ctx context.Context, entry Entry) (*UpdateResult, error)
- type DeleteResult
- type Entry
- type Linux
- func (l *Linux) Create(_ context.Context, _ Entry) (*CreateResult, error)
- func (l *Linux) Delete(_ context.Context, _ string) (*DeleteResult, error)
- func (l *Linux) Get(_ context.Context, _ string) (*Entry, error)
- func (l *Linux) List(_ context.Context) ([]Entry, error)
- func (l *Linux) Update(_ context.Context, _ Entry) (*UpdateResult, error)
- type Provider
- type UpdateResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateResult ¶
type CreateResult struct {
Name string `json:"name"`
Changed bool `json:"changed"`
Error string `json:"error,omitempty"`
}
CreateResult represents the outcome of a cron entry creation.
type Darwin ¶
type Darwin struct{}
Darwin implements the Provider interface for Darwin (macOS). All methods return ErrUnsupported as cron.d is not available on macOS.
func NewDarwinProvider ¶
func NewDarwinProvider() *Darwin
NewDarwinProvider factory to create a new Darwin instance.
type Debian ¶
type Debian struct {
provider.FactsAware
// contains filtered or unexported fields
}
Debian implements the Provider interface for Debian-family systems. It delegates file writes to a FileDeployer for SHA tracking and idempotency. Managed files are identified by their presence in the file-state KV, not by file content headers.
func NewDebianProvider ¶
func NewDebianProvider( logger *slog.Logger, fs avfs.VFS, fileDeployer file.Deployer, stateKV jetstream.KeyValue, hostname string, ) *Debian
NewDebianProvider factory to create a new Debian instance.
type DeleteResult ¶
type DeleteResult struct {
Name string `json:"name"`
Changed bool `json:"changed"`
Error string `json:"error,omitempty"`
}
DeleteResult represents the outcome of a cron entry deletion.
type Entry ¶
type Entry struct {
Name string `json:"name"`
Object string `json:"object,omitempty"`
Schedule string `json:"schedule,omitempty"`
Interval string `json:"interval,omitempty"`
Source string `json:"source,omitempty"`
User string `json:"user,omitempty"`
ContentType string `json:"content_type,omitempty"`
Vars map[string]any `json:"vars,omitempty"`
}
Entry represents a cron entry — either a /etc/cron.d/ drop-in file with a custom schedule or a /etc/cron.{interval}/ periodic script.
type Linux ¶
type Linux struct{}
Linux implements the Provider interface for generic Linux. All methods return ErrUnsupported; use the Debian provider for Debian-family systems.
func NewLinuxProvider ¶
func NewLinuxProvider() *Linux
NewLinuxProvider factory to create a new Linux instance.
type Provider ¶
type Provider interface {
// List returns all osapi-managed cron entries.
List(ctx context.Context) ([]Entry, error)
// Get returns a single cron entry by name.
Get(ctx context.Context, name string) (*Entry, error)
// Create deploys a new cron entry via the file provider.
Create(ctx context.Context, entry Entry) (*CreateResult, error)
// Update redeploys an existing cron entry via the file provider.
Update(ctx context.Context, entry Entry) (*UpdateResult, error)
// Delete undeploys a cron entry via the file provider.
Delete(ctx context.Context, name string) (*DeleteResult, error)
}
Provider implements the methods to manage cron entries.
type UpdateResult ¶
type UpdateResult struct {
Name string `json:"name"`
Changed bool `json:"changed"`
Error string `json:"error,omitempty"`
}
UpdateResult represents the outcome of a cron entry update.