sync

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Change

type Change struct {
	Kind           ChangeKind
	Key            string
	OldValue       string
	NewValue       string
	Classification string // human-readable tags, e.g. "masked", "protected", "file"
	SkipReason     string
	// contains filtered or unexported fields
}

Change describes a single diff entry.

type ChangeKind

type ChangeKind string

ChangeKind identifies the type of diff change.

const (
	ChangeCreate    ChangeKind = "create"
	ChangeUpdate    ChangeKind = "update"
	ChangeDelete    ChangeKind = "delete"
	ChangeUnchanged ChangeKind = "unchanged"
	ChangeSkipped   ChangeKind = "skipped"
)

type DiffResult

type DiffResult struct {
	Changes []Change
}

DiffResult holds the complete set of changes between local and remote.

type Engine

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

Engine orchestrates diff and apply operations.

func NewEngine

func NewEngine(client gitlabClient, cl *classifier.Classifier, opts Options, projectID string) *Engine

NewEngine creates a new Engine.

func (*Engine) Apply

func (e *Engine) Apply(ctx context.Context, diff DiffResult) SyncReport

Apply executes all changes in diff using a worker pool. It is equivalent to ApplyWithCallback with a nil callback.

func (*Engine) ApplyWithCallback

func (e *Engine) ApplyWithCallback(ctx context.Context, diff DiffResult, cb func(Result)) SyncReport

ApplyWithCallback executes all changes concurrently. For each completed result (success or error), cb is called synchronously from the collecting goroutine.

func (*Engine) Diff

func (e *Engine) Diff(ctx context.Context, local []envfile.Variable, remote []gitlab.Variable, envScope string) DiffResult

Diff computes the set of changes needed to bring remote in sync with local. envScope is passed as the environment_scope when creating/updating variables.

type Options

type Options struct {
	Workers       int
	DryRun        bool
	DeleteMissing bool
}

Options controls Engine behaviour.

type Result

type Result struct {
	Change Change
	Error  error
}

Result is produced by a worker after attempting to apply one Change.

type SyncReport

type SyncReport struct {
	Created   int
	Updated   int
	Deleted   int
	Unchanged int
	Skipped   int
	Failed    int
	Duration  time.Duration
	APICalls  int
	Errors    []error
}

SyncReport summarises the outcome of an Apply run.

Jump to

Keyboard shortcuts

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