parse

package
v1.17.3 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: Apache-2.0 Imports: 52 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RenderingInProgress means that the configs are still being rendered by Config Sync.
	RenderingInProgress string = "Rendering is still in progress"

	// RenderingSucceeded means that the configs have been rendered successfully.
	RenderingSucceeded string = "Rendering succeeded"

	// RenderingFailed means that the configs have failed to be rendered.
	RenderingFailed string = "Rendering failed"

	// RenderingSkipped means that the configs don't need to be rendered.
	RenderingSkipped string = "Rendering skipped"

	// RenderingRequired means that the configs require rendering but the
	// hydration-controller is not currently running.
	RenderingRequired string = "Rendering required but is currently disabled"
	// RenderingNotRequired means that the configs do not require rendering but the
	// hydration-controller is currently running.
	RenderingNotRequired string = "Rendering not required but is currently enabled"
)

Variables

This section is empty.

Functions

func BadScopeErr

func BadScopeErr(resource client.Object, want declared.Scope) status.ResourceError

BadScopeErr reports that the passed resource declares a Namespace for a different Namespace repository.

func OptionsForScope

func OptionsForScope(options validate.Options, scope declared.Scope) validate.Options

OptionsForScope returns new Options that have been updated for the given Scope.

func Run

func Run(ctx context.Context, p Parser, nsControllerState *namespacecontroller.State)

Run keeps checking whether a parse-apply-watch loop is necessary and starts a loop if needed.

Types

type FileSource

type FileSource struct {
	// SourceDir is the path to the symbolic link of the source repository.
	SourceDir cmpath.Absolute
	// HydratedRoot is the path to the root of the hydrated directory.
	HydratedRoot string
	// RepoRoot is the absolute path to the parent directory of SourceRoot and HydratedRoot.
	RepoRoot cmpath.Absolute
	// HydratedLink is the relative path to the symbolic link of the hydrated configs.
	HydratedLink string
	// SyncDir is the path to the directory of policies within the source repository.
	SyncDir cmpath.Relative
	// SourceType is the type of the source repository, must be git or oci.
	SourceType v1beta1.SourceType
	// SourceRepo is the source repo to sync.
	SourceRepo string
	// SourceBranch is the branch of the source repo to sync.
	SourceBranch string
	// SourceRev is the revision of the source repo to sync.
	SourceRev string
}

FileSource includes all settings to configure where a Parser reads files from.

type Files added in v1.17.0

type Files struct {
	FileSource
	// contains filtered or unexported fields
}

Files lists files in a repository and ensures the source repository hasn't been modified from HEAD.

type Options added in v1.17.0

type Options struct {
	// Parser defines the minimum interface required for Reconciler to use a
	// Parser to read configs from a filesystem.
	Parser filesystem.ConfigParser

	// ClusterName is the name of the cluster we're syncing configuration to.
	ClusterName string

	// Client knows how to read objects from a Kubernetes cluster and update
	// status.
	Client client.Client

	// ReconcilerName is the name of the reconciler resources, such as service
	// account, service, deployment and etc.
	ReconcilerName string

	// SyncName is the name of the RootSync or RepoSync object.
	SyncName string

	// PollingPeriod is the period of time between checking the filesystem for
	// source updates to sync.
	PollingPeriod time.Duration

	// ResyncPeriod is the period of time between forced re-sync from source
	// (even without a new commit).
	ResyncPeriod time.Duration

	// RetryPeriod is how long the Parser waits between retries, after an error.
	RetryPeriod time.Duration

	// StatusUpdatePeriod is how long the Parser waits between updates of the
	// sync status, to account for management conflict errors from the Remediator.
	StatusUpdatePeriod time.Duration

	// DiscoveryInterface is how the Parser learns what types are currently
	// available on the cluster.
	DiscoveryInterface discovery.ServerResourcer

	// Converter uses the DiscoveryInterface to encode the declared fields of
	// objects in Git.
	Converter *declared.ValueConverter

	// RenderingEnabled indicates whether the hydration-controller is currently
	// running for this reconciler.
	RenderingEnabled bool

	// Files lists Files in the source of truth.
	Files
	// Updater mutates the most-recently-seen versions of objects stored in memory.
	Updater
	// contains filtered or unexported fields
}

Options holds configuration and core functionality required by all parsers.

type Parser

type Parser interface {
	SetSyncStatus(ctx context.Context, newStatus syncStatus) error

	// SyncErrors returns all the sync errors, including remediator errors,
	// validation errors, applier errors, and watch update errors.
	SyncErrors() status.MultiError
	// Syncing returns true if the updater is running.
	Syncing() bool
	// K8sClient returns the Kubernetes client that talks to the API server.
	K8sClient() client.Client
	// contains filtered or unexported methods
}

Parser represents a parser that can be pointed at and continuously parse a source.

func NewNamespaceRunner

func NewNamespaceRunner(opts *Options) Parser

NewNamespaceRunner creates a new runnable parser for parsing a Namespace repo.

func NewRootRunner

func NewRootRunner(opts *Options, rootOpts *RootOptions) Parser

NewRootRunner creates a new runnable parser for parsing a Root repository.

type RootOptions added in v1.17.0

type RootOptions struct {
	// SourceFormat defines the structure of the Root repository. Only the Root
	// repository may be SourceFormatHierarchy; all others are implicitly
	// SourceFormatUnstructured.
	SourceFormat filesystem.SourceFormat

	// NamespaceStrategy indicates the NamespaceStrategy to be used by this
	// reconciler.
	NamespaceStrategy configsync.NamespaceStrategy

	// DynamicNSSelectorEnabled represents whether the NamespaceSelector's dynamic
	// mode is enabled. If it is enabled, NamespaceSelector will also select
	// resources matching the on-cluster Namespaces.
	DynamicNSSelectorEnabled bool

	// NSControllerState stores whether the Namespace Controller schedules a sync
	// event for the reconciler thread, along with the cached NamespaceSelector
	// and selected namespaces.
	NSControllerState *namespacecontroller.State
}

RootOptions includes options specific to RootSync objects.

type Updater added in v1.17.0

type Updater struct {
	// Scope defines the scope of the reconciler, either root or namespaced.
	Scope declared.Scope
	// Resources is a set of resources declared in the source of truth.
	*declared.Resources
	// Remediator is the interface Remediator implements that accepts a new set of
	// declared configuration.
	Remediator remediator.Interface
	// Applier is a bulk client for applying a set of desired resource objects and
	// tracking them in a ResourceGroup inventory.
	Applier applier.Applier
	// contains filtered or unexported fields
}

Updater mutates the most-recently-seen versions of objects stored in memory.

func (*Updater) Errors added in v1.17.0

func (u *Updater) Errors() status.MultiError

Errors returns the latest known set of errors from the updater. This method is safe to call while Update is running.

func (*Updater) Update added in v1.17.0

func (u *Updater) Update(ctx context.Context, cache *cacheForCommit) status.MultiError

Update does the following: 1. Pauses the remediator 2. Validates and sterilizes the objects 3. Updates the declared resource objects in memory 4. Applies the objects 5. Updates the remediator watches 6. Restarts the remediator

Any errors returned will be prepended with any known conflict errors from the remediator. This is required to preserve errors that have been reported by another reconciler.

func (*Updater) Updating added in v1.17.0

func (u *Updater) Updating() bool

Updating returns true if the Update method is running.

Jump to

Keyboard shortcuts

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