gitops

package
v1.10.27 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package gitops reconciles Git repos of miabi.io/v1 manifests into a workspace by reusing the apply engine.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound     = errors.New("git source not found")
	ErrNameTaken    = errors.New("a git source with this name already exists")
	ErrNameRequired = errors.New("name is required")
	ErrURLRequired  = errors.New("select a git repository (or provide a repository URL)")
	ErrRepoNotFound = errors.New("git repository not found")
)

Functions

This section is empty.

Types

type Applier

type Applier interface {
	Apply(ctx context.Context, workspaceID uint, manifests []byte, opts apply.Options) (*apply.Result, error)
	ApplyResource(ctx context.Context, workspaceID uint, manifests []byte, opts apply.Options, kind, name string) (*apply.Result, error)
	DeleteResource(ctx context.Context, workspaceID uint, kind, name string) (*apply.Result, error)
	Teardown(ctx context.Context, workspaceID uint, sourceID string) (*apply.Result, error)
	Plan(ctx context.Context, workspaceID uint, manifests []byte, opts apply.Options) (*declarative.Plan, *declarative.ResourceSet, error)
	Topology(ctx context.Context, workspaceID uint, manifests []byte, opts apply.Options) (*apply.Topology, error)
	LiveTopology(ctx context.Context, workspaceID uint, syncError string) (*apply.Topology, error)
	LiveStatus(workspaceID uint) map[string]string
}

type Input

type Input struct {
	Name            string
	DisplayName     string
	RepoURL         string
	Ref             string
	Path            string
	GitRepositoryID *uint
	SyncPolicy      models.GitSyncPolicy
	Prune           bool
	SelfHeal        bool
	AllowEmpty      bool
	// RequireSealedSecrets refuses a plaintext Secret value in the repository.
	RequireSealedSecrets bool
}

type Service

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

Service manages GitSource bindings and reconciles them.

func NewService

func NewService(repo *repositories.GitSourceRepository, gitRepos *repositories.GitRepoRepository, applier Applier) *Service

func (*Service) Create

func (s *Service) Create(workspaceID uint, in Input) (*models.GitSource, error)

Create registers a new GitSource and assigns it a webhook secret.

func (*Service) Declare added in v1.10.20

func (s *Service) Declare(workspaceID, id uint, in apply.GitSourceInput) (*models.GitSource, error)

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, workspaceID, id uint, cascade bool) (*apply.Result, error)

Delete with cascade tears down the source's labelled resources first; without it they keep running unmanaged.

func (*Service) DeleteResource added in v1.6.5

func (s *Service) DeleteResource(ctx context.Context, workspaceID, id uint, kind, name string) (*apply.Result, error)

DeleteResource is recreated by the next auto-sync; scoped to the source so callers can't delete outside it.

func (*Service) Diff

func (s *Service) Diff(ctx context.Context, workspaceID, id uint) (*declarative.Plan, error)

func (*Service) Get

func (s *Service) Get(workspaceID, id uint) (*models.GitSource, error)

func (*Service) IDByUID

func (s *Service) IDByUID(uid string) (uint, error)

IDByUID resolves a git source's portable uid to its numeric id.

func (*Service) List

func (s *Service) List(workspaceID uint) ([]models.GitSource, error)

func (*Service) Reconcile

func (s *Service) Reconcile(ctx context.Context, src *models.GitSource) error

func (*Service) ReconcileAuto

func (s *Service) ReconcileAuto(ctx context.Context) error

func (*Service) Remove added in v1.10.20

func (s *Service) Remove(ctx context.Context, workspaceID, id uint) error

Remove deletes a declared source, tearing its resources down only when its delete policy says cascade.

func (*Service) RepositoryNames added in v1.10.20

func (s *Service) RepositoryNames(workspaceID uint) (map[uint]string, error)

RepositoryNames maps the workspace's Git credential ids to their names.

func (*Service) SetRestriction added in v1.10.21

func (s *Service) SetRestriction(f func(workspaceID uint) error)

func (*Service) SetSecrets added in v1.7.3

func (s *Service) SetSecrets(v gitrepo.Secrets)

nil allows literal credentials only.

func (*Service) Status

func (s *Service) Status(workspaceID, id uint) (map[string]string, error)

Cheap (no clone) so the detail page can poll it.

func (*Service) Sync

func (s *Service) Sync(ctx context.Context, workspaceID, id uint) (*models.GitSource, error)

Sync reconciles a source addressed by workspace+id (manual trigger / webhook).

func (*Service) SyncByID

func (s *Service) SyncByID(ctx context.Context, id uint) error

SyncByID reconciles a source by id without workspace scoping (worker/cron).

func (*Service) SyncInBackground added in v1.10.20

func (s *Service) SyncInBackground(id uint)

Start only once the source row is final: the reconcile saves the whole row.

func (*Service) SyncResource added in v1.6.5

func (s *Service) SyncResource(ctx context.Context, workspaceID, id uint, kind, name string) (*apply.Result, error)

SyncResource does not update the source's sync status: a partial sync isn't a project sync.

func (*Service) Topology

func (s *Service) Topology(ctx context.Context, workspaceID, id uint) (*apply.Topology, error)

func (*Service) Update

func (s *Service) Update(workspaceID, id uint, in Input) (*models.GitSource, error)

Update ignores in.Name: manifests and nested projects address the source by it.

func (*Service) VerifyWebhook

func (s *Service) VerifyWebhook(src *models.GitSource, signature string, body []byte) bool

VerifyWebhook checks an inbound push webhook against the source's secret.

Jump to

Keyboard shortcuts

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