diff

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 24 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

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"`
}

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 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 ...interface{})
	UpdatePrintln func(a ...interface{})
	DeletePrintln func(a ...interface{})

	// 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
}

Jump to

Keyboard shortcuts

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