tensile

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

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

Go to latest
Published: Mar 10, 2026 License: BSD-3-Clause Imports: 4 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 Context

type Context interface {
	context.Context
}

Context is a superset of context.Context to pass additional fields to a 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(ctx context.Context) (bool, error)
	// Execute is called for the node to make the desired change.
	Execute(ctx context.Context) error
}

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

type ExecutorCtx

type ExecutorCtx 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(ctx Context) (bool, error)
	// Execute is called for the node to make the desired change.
	Execute(ctx Context) error
}

ExecutorCtx is equivalent to Executor but with a Context instead of a context.Context.

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(ctx Context) 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(ctx Context) (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(ctx Context) 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 TensileCtx

type TensileCtx struct {
	context.Context //nolint:containedctx

}

TensileCtx implements a Context.

func NewContext

func NewContext(ctx context.Context) *TensileCtx

NewContext returns an initialized TensileCtx.

type Validator

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

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

type ValidatorCtx

type ValidatorCtx interface {
	// Validate validates the configuration of the node.
	// It may be used to setup states in the node.
	Validate(ctx Context) error
}

ValidatorCtx is equivalent to Validator but with a Context instead of a context.Contex.

Directories

Path Synopsis
cmd
tester command
A quick command to test things.
A quick command to test things.
pkg
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