files

package
v1.15.18 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2023 License: Apache-2.0 Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IncludesChanges

func IncludesChanges(diffs *System[*DiffWithChangeReason]) bool

Types

type ChangeReason

type ChangeReason struct {
	Reason string
}

type Diff

type Diff struct {
	OldFileState *State
	NewFileState *State
	DiffResult   DiffResult
}

func (*Diff) Validate

func (d *Diff) Validate() error

type DiffAction

type DiffAction int
const (
	DiffActionUnset    DiffAction = iota
	DiffActionDelete              // Delete the object
	DiffActionCreate              // Create the object
	DiffActionUpdate              // Update the object
	DiffActionNoChange            // No change to the object
)

func (DiffAction) String

func (d DiffAction) String() string

type DiffResult

type DiffResult struct {
	DiffAction         DiffAction
	ModeToChangeTo     *os.FileMode
	ContentsToChangeTo []byte
}

func (*DiffResult) Validate

func (r *DiffResult) Validate() error

type DiffWithChangeReason

type DiffWithChangeReason struct {
	Diff         *Diff
	ChangeReason *ChangeReason
}

func (*DiffWithChangeReason) Validate

func (d *DiffWithChangeReason) Validate() error

type Existence

type Existence int
const (
	FileExistenceUnset Existence = iota
	FileExistencePresent
	FileExistenceAbsent
)

func (Existence) String

func (e Existence) String() string

type MergeDuplicatePathErr

type MergeDuplicatePathErr[T Validatable] struct {
	Path   Path
	Value1 T
	Value2 T
}

func (*MergeDuplicatePathErr[T]) Error

func (e *MergeDuplicatePathErr[T]) Error() string

type Path

type Path string

func (Path) Clean

func (f Path) Clean() Path

func (Path) String

func (f Path) String() string

type State

type State struct {
	Mode          os.FileMode
	Contents      []byte
	FileExistence Existence
}

func (*State) Diff

func (f *State) Diff(_ context.Context, newState *State) (*Diff, error)

func (*State) Validate

func (f *State) Validate() error

type StateWithChangeReason

type StateWithChangeReason struct {
	State        State
	ChangeReason *ChangeReason
}

func (*StateWithChangeReason) Validate

func (s *StateWithChangeReason) Validate() error

type System

type System[T Validatable] struct {
	// contains filtered or unexported fields
}

func CalculateDiff

func CalculateDiff(ctx context.Context, existing *System[*State], desired *System[*StateWithChangeReason]) (*System[*DiffWithChangeReason], error)

func ConvertToRemovals

func ConvertToRemovals(s *System[*State]) (*System[*StateWithChangeReason], error)

func NewSystem added in v1.1.0

func NewSystem[T Validatable](in map[Path]T) *System[T]

func SimpleState added in v1.1.0

func SimpleState(files map[string]string) *System[*State]

func SystemMerge

func SystemMerge[T Validatable](systems ...*System[T]) (*System[T], error)

func (*System[T]) Add

func (f *System[T]) Add(path Path, state T) error

func (*System[T]) Get

func (f *System[T]) Get(path Path) T

func (*System[T]) IsTracked

func (f *System[T]) IsTracked(path Path) bool

func (*System[T]) MarshalLogObject

func (f *System[T]) MarshalLogObject(e zapcore.ObjectEncoder) error

func (*System[T]) Paths

func (f *System[T]) Paths() []Path

func (*System[T]) Remove

func (f *System[T]) Remove(path Path) (T, bool)

func (*System[T]) RemoveAll

func (f *System[T]) RemoveAll(paths []Path)

func (*System[T]) RemoveTracked

func (f *System[T]) RemoveTracked(path Path) error

type Validatable

type Validatable interface {
	Validate() error
}

Jump to

Keyboard shortcuts

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