sync

package
v0.0.0-...-bac2f6a Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2025 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

Package sync provides Git synchronization functionality

Index

Constants

View Source
const (
	// DefaultCloneTimeout is the default timeout for clone operations
	DefaultCloneTimeout = 5 * time.Minute

	// DefaultFetchTimeout is the default timeout for fetch operations
	DefaultFetchTimeout = 2 * time.Minute

	// CacheTTL is how long to cache repository data
	CacheTTL = 5 * time.Minute
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CommitInfo

type CommitInfo struct {
	Hash    string
	Author  string
	Email   string
	Time    time.Time
	Message string
}

CommitInfo represents information about a commit

type Manager

type Manager struct {
	Client client.Client
	Scheme *runtime.Scheme
	Log    logr.Logger
}

Manager handles Git repository synchronization

func NewManager

func NewManager(client client.Client, scheme *runtime.Scheme, log logr.Logger) *Manager

NewManager creates a new sync manager

func (*Manager) CancelSync

func (m *Manager) CancelSync(ctx context.Context, platform *observabilityv1.ObservabilityPlatform) error

CancelSync cancels an ongoing sync operation

func (*Manager) GetLastSuccessfulSync

func (m *Manager) GetLastSuccessfulSync(ctx context.Context, platform *observabilityv1.ObservabilityPlatform) (*SyncState, error)

GetLastSuccessfulSync gets the last successful sync state

func (*Manager) GetSyncHistory

func (m *Manager) GetSyncHistory(ctx context.Context, platform *observabilityv1.ObservabilityPlatform, limit int) ([]SyncState, error)

GetSyncHistory gets the sync history for a platform

func (*Manager) GetSyncState

func (m *Manager) GetSyncState(ctx context.Context, platform *observabilityv1.ObservabilityPlatform) (*SyncState, error)

GetSyncState gets the current sync state

func (*Manager) PromoteToEnvironment

PromoteToEnvironment promotes configuration to a target environment

func (*Manager) TriggerSync

func (m *Manager) TriggerSync(ctx context.Context, platform *observabilityv1.ObservabilityPlatform) error

TriggerSync triggers a sync operation for the platform

func (*Manager) UpdateTargetRevision

func (m *Manager) UpdateTargetRevision(ctx context.Context, platform *observabilityv1.ObservabilityPlatform, revision string) error

UpdateTargetRevision updates the target revision for sync

func (*Manager) WaitForSync

func (m *Manager) WaitForSync(ctx context.Context, platform *observabilityv1.ObservabilityPlatform, timeout time.Duration) error

WaitForSync waits for a sync operation to complete

type SyncState

type SyncState struct {
	// Revision is the Git revision being synced
	Revision string `json:"revision"`

	// Status is the sync status
	Status SyncStatus `json:"status"`

	// StartTime is when the sync started
	StartTime time.Time `json:"startTime"`

	// CompletionTime is when the sync completed
	CompletionTime *time.Time `json:"completionTime,omitempty"`

	// Message provides additional information
	Message string `json:"message,omitempty"`

	// Resources tracks synced resources
	Resources []SyncedResource `json:"resources,omitempty"`

	// Errors contains any sync errors
	Errors []string `json:"errors,omitempty"`
}

SyncState represents the state of a sync operation

type SyncStatus

type SyncStatus string

SyncStatus represents the status of a sync operation

const (
	// SyncStatusPending indicates sync is pending
	SyncStatusPending SyncStatus = "Pending"
	// SyncStatusInProgress indicates sync is in progress
	SyncStatusInProgress SyncStatus = "InProgress"
	// SyncStatusCompleted indicates sync completed successfully
	SyncStatusCompleted SyncStatus = "Completed"
	// SyncStatusFailed indicates sync failed
	SyncStatusFailed SyncStatus = "Failed"
	// SyncStatusCancelled indicates sync was cancelled
	SyncStatusCancelled SyncStatus = "Cancelled"
)

type SyncedResource

type SyncedResource struct {
	// Kind is the resource kind
	Kind string `json:"kind"`

	// Name is the resource name
	Name string `json:"name"`

	// Namespace is the resource namespace
	Namespace string `json:"namespace,omitempty"`

	// Action is what was done (created, updated, deleted)
	Action string `json:"action"`

	// Status is the resource status
	Status string `json:"status"`
}

SyncedResource represents a resource that was synced

type Synchronizer

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

Synchronizer implements Git synchronization operations

func NewSynchronizer

func NewSynchronizer(cfg *config.Config) (*Synchronizer, error)

NewSynchronizer creates a new Git synchronizer

func (*Synchronizer) CheckoutRevision

func (s *Synchronizer) CheckoutRevision(ctx context.Context, repoPath string, revision string) error

CheckoutRevision checks out a specific revision

func (*Synchronizer) Cleanup

func (s *Synchronizer) Cleanup(ctx context.Context, repoPath string) error

Cleanup cleans up cloned repositories

func (*Synchronizer) CleanupAll

func (s *Synchronizer) CleanupAll() error

CleanupAll cleans up all cached repositories

func (*Synchronizer) Clone

func (s *Synchronizer) Clone(ctx context.Context, repo gitops.GitRepository) (string, error)

Clone clones a Git repository

func (*Synchronizer) GetCommitInfo

func (s *Synchronizer) GetCommitInfo(ctx context.Context, repoPath string, revision string) (*CommitInfo, error)

GetCommitInfo gets information about a specific commit

func (*Synchronizer) GetDiff

func (s *Synchronizer) GetDiff(ctx context.Context, repoPath string, fromRevision, toRevision string) (string, error)

GetDiff gets the diff between two revisions

func (*Synchronizer) GetFiles

func (s *Synchronizer) GetFiles(ctx context.Context, repoPath string, pattern string) ([]string, error)

GetFiles gets files matching a pattern from the repository

func (*Synchronizer) GetRevision

func (s *Synchronizer) GetRevision(ctx context.Context, repoPath string) (string, error)

GetRevision gets the current revision of the repository

func (*Synchronizer) ListBranches

func (s *Synchronizer) ListBranches(ctx context.Context, repoPath string) ([]string, error)

ListBranches lists all branches in the repository

func (*Synchronizer) ListTags

func (s *Synchronizer) ListTags(ctx context.Context, repoPath string) ([]string, error)

ListTags lists all tags in the repository

func (*Synchronizer) Pull

func (s *Synchronizer) Pull(ctx context.Context, repoPath string) error

Pull pulls latest changes from the repository

func (*Synchronizer) SetClient

func (s *Synchronizer) SetClient(client client.Client)

SetClient sets the Kubernetes client for secret access

Jump to

Keyboard shortcuts

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