gitops

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package gitops is the on-disk desired-state tree: lib/ profiles, blueprint manifests, and the committed baseline. Config identity = the config `name` (which is the .mobileconfig filename, matching how the console names uploads).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sanitize

func Sanitize(s string) string

Sanitize turns a blueprint name into a safe filename slug.

Types

type BlueprintSpec

type BlueprintSpec struct {
	Name           string   `yaml:"name"`
	ID             string   `yaml:"id,omitempty"`
	Description    string   `yaml:"description,omitempty"`
	Configurations []string `yaml:"configurations"`
}

BlueprintSpec is the git desired-state for one blueprint: its identity and the set of configuration names attached to it. Device/user/group membership is NOT tracked here — identity is API-read-only (console/federation-managed), so a blueprint's members live in the console, not in git.

type Tree

type Tree struct {
	Root          string
	LibDir        string
	StateFile     string
	BlueprintsDir string
	ArchiveDir    string
}

Tree is the on-disk desired-state layout rooted at <envDir>/gitops.

func NewTree

func NewTree(envDir string) *Tree

NewTree roots the gitops tree at <envDir>/gitops (next to .env/secrets).

func (*Tree) LoadBlueprints

func (t *Tree) LoadBlueprints() (map[string]BlueprintSpec, error)

LoadBlueprints reads blueprints/*.yml → blueprint name → spec. A malformed file is a hard error (so a typo can't silently drop a blueprint from the plan).

func (*Tree) LoadDesired

func (t *Tree) LoadDesired() (map[string][]byte, error)

LoadDesired reads lib/*.mobileconfig → name → content.

func (*Tree) RemoveConfig

func (t *Tree) RemoveConfig(name string) error

RemoveConfig deletes a profile from lib/ (used when a config was removed from ABM → the git file is pruned). A missing file is not an error (idempotent).

func (*Tree) WriteBlueprintSpec

func (t *Tree) WriteBlueprintSpec(s BlueprintSpec) error

WriteBlueprintSpec marshals a spec to blueprints/<slug>.yml. The filename slug is derived from the name (falling back to the id when the name has no slug-safe characters), and collisions are disambiguated with a numeric suffix so two distinct blueprints whose names sanitize to the same slug never overwrite each other. Re-writing the same blueprint (matched by name) reuses its file.

func (*Tree) WriteConfig

func (t *Tree) WriteConfig(name string, content []byte) error

WriteConfig writes a profile into lib/ under the given name.

Jump to

Keyboard shortcuts

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