gitops

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 	RendererCheckName is the name "hydros-ai" name of the check run to use for the renderer
	RendererCheckName = "hydros-ai"
)

Variables

This section is empty.

Functions

func IsDuplicateReconciler

func IsDuplicateReconciler(err error) bool

func RendererName

func RendererName(org string, repo string) string

func SetTakeOverAnnotations added in v0.0.5

func SetTakeOverAnnotations(m *v1alpha1.ManifestSync, pause time.Duration) error

SetTakeOverAnnotations sets the takeover annotations on the manifest.

Types

type DuplicateReconciler

type DuplicateReconciler struct {
	Name string
}

func (*DuplicateReconciler) Error

func (d *DuplicateReconciler) Error() string

type Item

type Item struct {
	// Name of the reconciler
	Name string
	// Event is additional payload information
	Event any
}

Item is a wrapper for a queue item

type Manager

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

Manager manages multiple reconcilers. Its job is to ensure that

  1. A given reconciler is never running more than once concurrently
  2. Distributing the reconcile events among a pool of workers

TODO(jeremy): What are the proper semantics for a GitHub reconciler? When does the reconciler get created? Should it get created on the first webhook? What should the resync period be? Should we eventually forget about a repository if there aren't webhooks in some time period.

func NewManager

func NewManager(syncers []Reconciler) (*Manager, error)

NewManager starts a new sync manager.

func (*Manager) AddReconciler

func (m *Manager) AddReconciler(r Reconciler) error

AddReconciler adds the reconciler. Returns an DuplicateReconcilerError if a reconciler with the same name already If reconciler isn't thread safe then caller should ensure that it isn't called again and let manager take ownership.

func (*Manager) Enqueue

func (m *Manager) Enqueue(name string, payload any) error

Enqueue adds a sync event for the reconciler with the specified name

func (*Manager) HasReconciler

func (m *Manager) HasReconciler(name string) bool

func (*Manager) Shutdown

func (m *Manager) Shutdown()

Shutdown shuts down the syncer's. It will block until all threads have finished.

func (*Manager) Start

func (m *Manager) Start(numWorkers int, reSyncPeriod time.Duration) error

Start starts go threads to periodically process the sync objects.

type Reconciler

type Reconciler interface {
	// Name is a unique name for the reconciler
	Name() string
	// Run runs the reconcile loop. event can provide additional information about the event specific to
	// the reconciler.
	// TODO(jeremy): Should we return a duration which is the time after which to requeue another reconcile event?
	Run(event any) error
}

Reconciler defines a common interface for reconcilers so that Manager can be used to manage different types of reconcilers; i.e. we want to manage both Renderer and Syncer using the Manager interface.

TODO(jeremy): This interface is half baked and we will probably want to refactor it along with the Renderer and Syncer structs to implement it.

type RenderEvent

type RenderEvent struct {
	Commit string
	// BranchConfig is the branch config for the branch being rendered
	// N.B. We don't actually verify that commit is on basebranch
	BranchConfig *v1alpha1.InPlaceConfig
}

RenderEvent is additional information about the render event

type Renderer

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

Renderer is a reconciler that handles in place modification of YAML files. It is intended to run a bunch of KRM functions in place and then check the modifications back into the repository.

There is currently one renderer per repository. A single renderer can handle multiple branches but not concurrently.

TODO(jeremy): I don't think the semantics for specifying the KRM functions to apply is quite right. Right now we apply all KRM functions found at sourcePath. These functions get applied to all YAML below the location of the function path. This is ok as long as we don't have a mix of KRM functions that should be applied when hydrating into a different repository (e.g. via Syncer) but not when changes are to be checked into the source repository.

func NewRenderer

func NewRenderer(org string, name string, workDir string, transports *github.TransportManager) (*Renderer, error)

func (*Renderer) Name

func (r *Renderer) Name() string

func (*Renderer) Run

func (r *Renderer) Run(anyEvent any) error

type RepoController added in v0.0.3

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

RepoController is a controller for a repo. The controller will periodically checkout the repository and search it for resources. It will then sync those resources

func NewRepoController added in v0.0.3

func NewRepoController(config *v1alpha1.RepoConfig, workDir string) (*RepoController, error)

func (*RepoController) Reconcile added in v0.0.3

func (c *RepoController) Reconcile(ctx context.Context) error

func (*RepoController) RunPeriodically added in v0.0.3

func (c *RepoController) RunPeriodically(ctx context.Context, period time.Duration) error

type Syncer

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

Syncer keeps two repos in sync by creating PRs to publish hydrated manifests from one repo to the other.

func NewSyncer

func NewSyncer(m *v1alpha1.ManifestSync, manager *github.TransportManager, opts ...SyncerOption) (*Syncer, error)

NewSyncer creates a new syncer.

func (*Syncer) PushLocal

func (s *Syncer) PushLocal(wDir string, keyFile string) error

PushLocal commits any changes in wDir and then pushes those changes to the branch of the sourceRepo A sync can then be applied. keyFile is the private PEM key file to use. If not specified it will try to load one from the home directory

func (*Syncer) RunOnce

func (s *Syncer) RunOnce(force bool) error

RunOnce runs the syncer once. If force is true a sync is run even if none is needed.

func (*Syncer) RunPeriodically

func (s *Syncer) RunPeriodically(period time.Duration)

RunPeriodically runs periodically with the specified period.

type SyncerOption

type SyncerOption func(s *Syncer) error

SyncerOption is an option for instantiating the syncer.

func SyncWithAwsSession

func SyncWithAwsSession(sess *session.Session) SyncerOption

SyncWithAwsSession creates an option to use the supplied session.

func SyncWithLogger

func SyncWithLogger(log logr.Logger) SyncerOption

SyncWithLogger creates an option to use the supplied logger.

func SyncWithWorkDir

func SyncWithWorkDir(wDir string) SyncerOption

SyncWithWorkDir creates an option to use the supplied working directory.

Jump to

Keyboard shortcuts

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