Documentation
¶
Overview ¶
Package gitops is the declarative, pull-based half of Miabi's GitOps and CI/CD model. A GitSource binds a Git repo of miabi.io/v1 manifests to a workspace; the reconciler clones at a ref, renders and diffs against live state, and converges by reusing the apply engine. It adds no container plumbing.
Index ¶
- Variables
- type Applier
- type Input
- type Service
- func (s *Service) Create(workspaceID uint, in Input) (*models.GitSource, error)
- func (s *Service) Delete(ctx context.Context, workspaceID, id uint, cascade bool) (*apply.Result, error)
- func (s *Service) DeleteResource(ctx context.Context, workspaceID, id uint, kind, name string) (*apply.Result, error)
- func (s *Service) Diff(ctx context.Context, workspaceID, id uint) (*declarative.Plan, error)
- func (s *Service) Get(workspaceID, id uint) (*models.GitSource, error)
- func (s *Service) IDByUID(uid string) (uint, error)
- func (s *Service) List(workspaceID uint) ([]models.GitSource, error)
- func (s *Service) Reconcile(ctx context.Context, src *models.GitSource) error
- func (s *Service) ReconcileAuto(ctx context.Context) error
- func (s *Service) SetSecrets(v gitrepo.Secrets)
- func (s *Service) Status(workspaceID, id uint) (map[string]string, error)
- func (s *Service) Sync(ctx context.Context, workspaceID, id uint) (*models.GitSource, error)
- func (s *Service) SyncByID(ctx context.Context, id uint) error
- func (s *Service) SyncResource(ctx context.Context, workspaceID, id uint, kind, name string) (*apply.Result, error)
- func (s *Service) Topology(ctx context.Context, workspaceID, id uint) (*apply.Topology, error)
- func (s *Service) Update(workspaceID, id uint, in Input) (*models.GitSource, error)
- func (s *Service) VerifyWebhook(src *models.GitSource, signature string, body []byte) bool
Constants ¶
This section is empty.
Variables ¶
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
}
Applier is the subset of the apply engine the reconciler drives, kept as an interface so the package stays testable.
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
}
Input is the create/update payload for a GitSource. Name is the desired unique slug handle; DisplayName is the free-text label (falls back to Name when blank).
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
NewService wires the GitOps service.
func (*Service) Delete ¶
func (s *Service) Delete(ctx context.Context, workspaceID, id uint, cascade bool) (*apply.Result, error)
Delete removes a GitOps project. With cascade, the resources the project created — those carrying its gitops-source label — are torn down first in dependency-safe order. Without it they keep running, orphaned from GitOps management. Returns the teardown result so callers can show what was removed.
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 deletes a single live resource (kind/name) managed by a source. Under auto-sync it will be recreated on the next reconcile — the handler warns the user. Scoped to the source so a caller can't delete outside its project.
func (*Service) Diff ¶
Diff clones the source and returns the desired-vs-live plan without applying — the data behind the GitOps screen's diff viewer.
func (*Service) Reconcile ¶
Reconcile clones the source at its ref, applies the manifests, and records the resulting status on the source.
func (*Service) ReconcileAuto ¶
ReconcileAuto reconciles every auto-sync source. It is the cron sweep entry point; errors on individual sources are logged, not fatal.
func (*Service) SetSecrets ¶ added in v1.7.3
SetSecrets wires the vault, so a Git credential that references a workspace Secret (rather than storing its own copy of the token) can be resolved when a source is fetched. nil = literal credentials only.
func (*Service) Status ¶
Status returns the live runtime status of managed resources, keyed by topology node key. Cheap (no clone) so the detail page can poll it.
func (*Service) Sync ¶
Sync reconciles a source addressed by workspace+id (manual trigger / webhook).
func (*Service) SyncByID ¶
SyncByID reconciles a source by id without workspace scoping (worker/cron).
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 reconciles a single resource (kind/name) of a source — the GitOps "sync this resource" action — without touching the rest of the project. It does not update the source's overall sync status (a partial sync isn't a project sync).
func (*Service) Topology ¶
Topology clones the source and returns the resource graph (nodes + dependency edges) behind the project-detail topology view.