common

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 19 Imported by: ? 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(
	ctx context.Context,
	passes func() bool,
	header string,
	expect, have any,
)

func AssertEqualTrees

func AssertEqualTrees[ET, EL, RT, RL any](
	ctx context.Context,
	expect *Sanitree[ET, EL],
	result *Sanitree[RT, RL],
	customContainerCheck ContainerComparatorFn[ET, EL, RT, RL],
	customLeafCheck LeafComparatorFn[ET, EL, RT, RL],
)

func CompareDiffTrees

func CompareDiffTrees[ET, EL, RT, RL any](
	ctx context.Context,
	expect *Sanitree[ET, EL],
	result *Sanitree[RT, RL],
	comparator NodeComparator[ET, EL, RT, RL],
)

CompareDiffTrees recursively compares two sanitrees that have different data types. The two trees are expected to represent a common hierarchy.

Additional comparisons besides the tree hierarchy are optionally left to the caller by population of the NodeComparator func.

func CompareLeaves

func CompareLeaves[ET, EL, RT, RL any](
	ctx context.Context,
	expect map[string]*Sanileaf[ET, EL],
	result map[string]*Sanileaf[RT, RL],
	customLeafCheck LeafComparatorFn[ET, EL, RT, RL],
)

func Debugf

func Debugf(ctx context.Context, tmpl string, vs ...any)

func Fatal

func Fatal(ctx context.Context, msg string, err error)

func FilterSlice

func FilterSlice(sl []string, remove string) []string

func GetAC

func GetAC() (api.Client, error)

func GetRelativePath

func GetRelativePath(
	ctx context.Context,
	rootDir, p string,
	info fs.FileInfo,
	fileWalkerErr error,
) string

func Infof

func Infof(ctx context.Context, tmpl string, vs ...any)

func IsWithinTimeBound

func IsWithinTimeBound(
	ctx context.Context,
	bound, check time.Time,
	hasTime bool,
) bool

func MustGetTimeFromName

func MustGetTimeFromName(ctx context.Context, name string) (time.Time, bool)

func SetDebug

func SetDebug(ctx context.Context) context.Context

Types

type ContainerComparatorFn

type ContainerComparatorFn[ET, EL, RT, RL any] func(
	ctx context.Context,
	expect *Sanitree[ET, EL],
	result *Sanitree[RT, RL])

type Envs

type Envs struct {
	BackupID         string
	SourceContainer  string
	RestoreContainer string
	// applies for sharepoint lists only
	RestoreContainerPrefix string
	Category               string
	GroupID                string
	SiteID                 string
	UserID                 string
	TeamSiteID             string
}

func EnvVars

func EnvVars(ctx context.Context) Envs

type LeafComparatorFn

type LeafComparatorFn[ET, EL, RT, RL any] func(
	ctx context.Context,
	expect *Sanileaf[ET, EL],
	result *Sanileaf[RT, RL])

type NodeComparator

type NodeComparator[ET, EL, RT, RL any] func(
	ctx context.Context,
	expect *Sanitree[ET, EL],
	result *Sanitree[RT, RL],
)

type PermissionInfo

type PermissionInfo struct {
	EntityID string
	Roles    []string
}

type Sanileaf

type Sanileaf[T, L any] struct {
	Parent *Sanitree[T, L]
	Self   L
	ID     string
	Name   string
	Size   int64

	// Expand is an arbitrary k:v map of any data that is
	// uniquely scrutinized by a given service.
	Expand map[string]any
}

type Sanitree

type Sanitree[T, L any] struct {
	Parent *Sanitree[T, L]

	Self T
	ID   string
	Name string

	// CountLeaves is the number of non-container child items.
	// Used for services that don't need full item metadata, and
	// just want a count of children.
	CountLeaves int
	// leaves are non-container child items.  Used by services
	// that need more than just a count of items.
	// name (or equivalent) -> leaf
	Leaves map[string]*Sanileaf[T, L]
	// Children holds all child containers
	// name -> node
	Children map[string]*Sanitree[T, L]

	// Expand is an arbitrary k:v map of any data that is
	// uniquely scrutinized by a given service.
	Expand map[string]any
}

Sanitree is used to build out a hierarchical tree of items for comparison against each other. Primarily so that a restore can compare two subtrees easily.

func BuildFilepathSanitree

func BuildFilepathSanitree(
	ctx context.Context,
	rootDir string,
) *Sanitree[fs.FileInfo, fs.FileInfo]

func CreateNewRoot

func CreateNewRoot(info fs.FileInfo, initChildren bool) *Sanitree[fs.FileInfo, fs.FileInfo]

func (*Sanitree[T, L]) NodeAt

func (s *Sanitree[T, L]) NodeAt(
	ctx context.Context,
	elems []string,
) *Sanitree[T, L]

func (*Sanitree[T, L]) Path

func (s *Sanitree[T, L]) Path() path.Elements

Jump to

Keyboard shortcuts

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