tensile

package module
v0.0.0-...-c1dbf63 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: BSD-3-Clause Imports: 5 Imported by: 0

README

tensile

tensile is a yak shaving exercise to write a config management ecosystem a la Puppet, Ansible, Chef etc.pp. in Go.

Documentation

Overview

Package tensile is a config management library a la Puppet, Ansible, Chef, etc.pp. written in Go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cable

type Cable interface {
	// Context returns a context that is valid for the lifetime of the [Node].
	// That means the Context is valid from the first call to Validation
	// and until Execute has finished.
	Context() context.Context

	// Logger returns a logger for the [Node].
	Logger() *slog.Logger
}

Cable provides some base functionality to Node.

type Depender

type Depender interface {
	// DependsOn returns a list of resources the node depends on, e.g.
	// packages or files.
	DependsOn() ([]NodeRef, error)
}

Depender is the interface to be satisfied by a Node when it depends on other resources to be provided by other Node., e.g. a package that must be installed or a file to be ensured.

type Executor

type Executor interface {
	// NeedsExecution is run before Execute. NeedsExecution must not
	// mane any modifications to the system, it must be a stateless
	// check to check if Node.Execute must be called.
	//
	// NeedsExecution is called e.g. for noop runs to check if any
	// changes are needed.
	NeedsExecution(cable Cable) (bool, error)
	// Execute is called for the node to make the desired change.
	Execute(cable Cable) error
}

Executor is the interface to be satisfied by a Node to be executed.

type Node

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

Node is a single step to be executed by an engine.

func NewNode

func NewNode(input any) (*Node, error)

NewNode takes any value and transforms it into a Node.

func (*Node) DependsOn

func (n *Node) DependsOn() ([]NodeRef, error)

DependsOn calls .DependsOn on the wrapped node if it implements it.

func (*Node) Execute

func (n *Node) Execute(cable Cable) error

Execute calls .Execute on the wrapped node if it implements it.

func (*Node) ID

func (n *Node) ID() int64

ID returns a hash of the node.

func (*Node) NeedsExecution

func (n *Node) NeedsExecution(cable Cable) (bool, error)

NeedsExecution calls .NeedsExecution on the wrapped node if it implements it.

func (*Node) Provides

func (n *Node) Provides() ([]NodeRef, error)

Provides calls .Provides on the wrapped node if it implements it.

func (*Node) Validate

func (n *Node) Validate(cable Cable) error

Validate calls .Validate on the wrapped node if it implements it.

type NodeRef

type NodeRef struct {
	Ref   Ref
	Value any
}

NodeRef is a reference to a node.

func (NodeRef) String

func (n NodeRef) String() string

String implements the fmt.Stringer interface.

type Provider

type Provider interface {
	// Provides returns a list of resources the node will provide, e.g.
	// a list of packages or files.
	Provides() ([]NodeRef, error)
}

Provider is the interface to be satisfied by a Node when it provides resources, e.g. installing a package or creating a file.

type Ref

type Ref string

Ref the type of a node reference.

func (Ref) To

func (ref Ref) To(input any) NodeRef

To creates a NodeRef with the given value.

func (Ref) ToMany

func (ref Ref) ToMany(inputs ...any) []NodeRef

ToMany is equivalent for Ref.To but for many values.

type Validator

type Validator interface {
	// Validate validates the configuration of the node.
	// It may be used to setup states in the node.
	Validate(cable Cable) error
}

Validator is the interface to be satisfied by a Node when the configuration needs to be validated e.g. before execution.

Directories

Path Synopsis
cmd
tester command
A quick command to test things.
A quick command to test things.
pkg
cable
Package cable contains implementations for tensile.Cable and utility functions around it.
Package cable contains implementations for tensile.Cable and utility functions around it.
engine
Package engine contains execution engines for tensile.
Package engine contains execution engines for tensile.
queue
Package queue implements the ordering logic to execute tensile.Node.
Package queue implements the ordering logic to execute tensile.Node.
Package tensilestd contains tensile.Node implementations.
Package tensilestd contains tensile.Node implementations.

Jump to

Keyboard shortcuts

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