Help us shape the future of Go! Take the 2026 Go Developer Survey

diff

package
v1.43.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 27 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// CreateAction is the ReconcileAction used when a target object did not exist in the current state and was created.
	CreateAction = ReconcileAction("create")
	// UpdateAction is the ReconcileAction used when a target object exists in the current state and was updated.
	UpdateAction = ReconcileAction("update")
	// DeleteAction is the ReconcileAction used when a current object exists in the target state and was deleted.
	DeleteAction = ReconcileAction("delete")
)

Variables

This section is empty.

Functions

func MaskEnvVarValue

func MaskEnvVarValue(diffString string) string

MaskEnvVarValue masks DECK_ env var values in diff output using a precomputed cache. Phase 1: masks multiline PEM blocks (certs/keys) using BEGIN/END markers. Phase 2: masks JSON Web Key (JWK) values using regex pattern matching. Phase 3: masks single-line values using position-aware regex matching.

Types

type Do

type Do func(a crud.Event) (crud.Arg, error)

Do is the worker function to sync the diff

type Entity added in v1.10.0

type Entity struct {
	// Name is the name of the entity.
	Name string `json:"name"`
	// Kind is the type of entity.
	Kind string `json:"kind"`
	// Old is the original entity in the current state, if any.
	Old any `json:"old,omitempty"`
	// New is the new entity in the target state, if any.
	New any `json:"new,omitempty"`
}

Entity is an entity processed by the diff engine.

type EntityAction added in v1.10.0

type EntityAction struct {
	// Action is the ReconcileAction taken on the entity.
	Action ReconcileAction `json:"action"`
	// Entity holds the processed entity.
	Entity Entity `json:"entity"`
	// Diff is diff string describing the modifications made to an entity.
	Diff string `json:"-"`
	// Error is the error encountered processing and entity, if any.
	Error error `json:"error,omitempty"`
}

EntityAction describes an entity processed by the diff engine and the action taken on it.

type EntityChanges

type EntityChanges struct {
	Creating []EntityState `json:"creating"`
	Updating []EntityState `json:"updating"`
	Deleting []EntityState `json:"deleting"`

	DroppedCreations []EntityState `json:"dropped_creations,omitempty"`
	DroppedUpdates   []EntityState `json:"dropped_updates,omitempty"`
	DroppedDeletions []EntityState `json:"dropped_deletions,omitempty"`
}

type EntityState

type EntityState struct {
	Name string `json:"name"`
	Kind string `json:"kind"`
	Body any    `json:"body"`
}

type EnvVar

type EnvVar struct {
	Key   string
	Value string
}

type EnvVarCache added in v1.42.0

type EnvVarCache struct {
	EnvVars []EnvVar
	// Secrets holds the unique, non-empty env var values sorted longest-first
	// so that longer values are masked before their potential substrings.
	Secrets []string
	// SecretsSet is a membership set of Secrets, used for exact-match checks
	// (e.g. numeric values that must match an env var value exactly).
	SecretsSet map[string]bool
	// SecretPatterns are word-boundary regexes for each secret, index-aligned
	// with Secrets. Compiled once here rather than on every masking call.
	SecretPatterns []*regexp.Regexp
	// PEMPatterns are the compiled BEGIN/END block regexes for each sensitive
	// PEM type present in the env vars. Compiled once here.
	PEMPatterns []*regexp.Regexp
	HasJWK      bool
}

EnvVarCache holds precomputed environment variable data to avoid redundant parsing, sorting, and regex compilation during multiple masking operations. It is built once per sync run (env vars are immutable during a run) and then only read, so it is safe to share across the parallel Solve goroutines.

func NewEnvVarCache added in v1.42.0

func NewEnvVarCache() *EnvVarCache

NewEnvVarCache precomputes all environment variable data needed for masking. This avoids redundant parsing, sorting, and regex compilation on every MaskEnvVarValue call. Environment variables don't change during a sync run, so this single precomputation significantly improves performance.

type JSONOutputObject

type JSONOutputObject struct {
	Changes  EntityChanges `json:"changes"`
	Summary  Summary       `json:"summary"`
	Warnings []string      `json:"warnings"`
	Errors   []string      `json:"errors"`
}

type ReconcileAction added in v1.10.0

type ReconcileAction string

ReconcileAction is an action taken by the diff engine.

type Stats

type Stats struct {
	CreateOps *utils.AtomicInt32Counter
	UpdateOps *utils.AtomicInt32Counter
	DeleteOps *utils.AtomicInt32Counter
}

Stats holds the stats related to a Solve.

type Summary

type Summary struct {
	Creating int32 `json:"creating"`
	Updating int32 `json:"updating"`
	Deleting int32 `json:"deleting"`
	Total    int32 `json:"total"`
}

type Syncer

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

Syncer takes in a current and target state of Kong, diffs them, generating a Graph to get Kong from current to target state.

func NewSyncer

func NewSyncer(opts SyncerOpts) (*Syncer, error)

NewSyncer constructs a Syncer.

func (*Syncer) GetResultChan added in v1.10.0

func (sc *Syncer) GetResultChan() chan EntityAction

GetResultChan returns the Syncer's result channel.

func (*Syncer) Run

func (sc *Syncer) Run(ctx context.Context, parallelism int, action Do) []error

Run starts a diff and invokes action for every diff.

func (*Syncer) Solve

func (sc *Syncer) Solve(ctx context.Context, parallelism int, dry bool, isJSONOut bool) (Stats,
	[]error, EntityChanges,
)

Solve generates a diff and walks the graph.

type SyncerOpts

type SyncerOpts struct {
	CurrentState *state.KongState
	TargetState  *state.KongState

	KongClient    *kong.Client
	KonnectClient *konnect.Client

	SilenceWarnings bool
	StageDelaySec   int

	NoMaskValues    bool
	IncludeLicenses bool

	IsKonnect bool

	CreatePrintln func(a ...any)
	UpdatePrintln func(a ...any)
	DeletePrintln func(a ...any)

	// EnableEntityActions instructs the Syncer to send EntityActions to its resultChan. If enabled, clients must
	// consume the Syncer.resultChan channel or Syncer.Solve() will block.
	EnableEntityActions bool

	// Prevents the Syncer from performing any Delete operations. Default is false (will delete).
	NoDeletes bool

	// SchemaRegistry is an optional shared schema registry. When provided,
	// it is reused for schema fetching and caching. When nil, a new
	// registry is created internally.
	SchemaRegistry *schema.Registry

	// SkipSchemaDefaults prevents schema-based default filling for plugins and partials.
	SkipSchemaDefaults bool
}

Jump to

Keyboard shortcuts

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