Documentation
¶
Overview ¶
Package mdmassets loads the MDM assets tree that obot-sentry's build publishes and assembles the per-configuration ZIP an admin downloads. The manifest is the whole contract: it declares the platforms (identity + display info), the configurations (per platform+OS, with their rendered-markdown instructions template and asset files), and the field schema the admin form renders from — obot holds no platform-specific knowledge of its own.
A source directory or tarball contains manifest.json plus its referenced files. The controller imports that source into immutable database bundles; HTTP replicas open those bundles through this package and never serve from the source path. The format is defined by these manifest types and produced by obot-sentry's build/mdm-assets.sh.
Index ¶
- Constants
- func ArtifactSlug(platform, osName string) string
- func Import(ctx context.Context, source string) ([]byte, error)
- func RedactSource(source string) string
- type Loader
- func (l *Loader) CompleteValues(values map[string]any) error
- func (l *Loader) Find(platform, osName string) (types.MDMAssetConfiguration, error)
- func (l *Loader) Manifest() types.MDMAssetManifest
- func (l *Loader) RenderAll(values map[string]any) ([]RenderedArtifact, error)
- func (l *Loader) RenderInstructions(c types.MDMAssetConfiguration, values map[string]any) (string, error)
- func (l *Loader) ValidateTemplates(c types.MDMAssetConfiguration, values map[string]any) error
- func (l *Loader) Zip(w io.Writer, c types.MDMAssetConfiguration, values map[string]any) error
- type RenderedArtifact
Constants ¶
const SchemaVersion = "v1"
SchemaVersion is the manifest format this loader understands. An assets tree declaring anything else is rejected so a newer format can't be misread by an older server.
Variables ¶
This section is empty.
Functions ¶
func ArtifactSlug ¶
ArtifactSlug returns the stable URL segment for a platform/OS artifact. NewFS rejects manifests whose targets collide after normalization.
func Import ¶
Import reads source, validates the complete assets snapshot, and normalizes it into deterministic archive bytes. HTTP(S) sources are tar archives. Local sources may be either the existing assets directory or a tar archive.
func RedactSource ¶
RedactSource returns a source suitable for status and UI display. Local paths are unchanged. URL credentials, query parameters, and fragments are never exposed, including when a malformed HTTP URL cannot be parsed safely.
Types ¶
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader validates and renders files from one immutable MDM asset bundle.
func NewFS ¶
NewFS loads and validates an assets snapshot rooted at files. Callers must not mutate files after this function returns.
func OpenArchive ¶
OpenArchive validates and opens canonical database bundle content without extracting it to disk.
func (*Loader) CompleteValues ¶
CompleteValues drops nulls (null means unset), fills schema defaults, and validates values in place — every rule comes from the manifest. The returned error is safe to surface to the admin.
func (*Loader) Find ¶
func (l *Loader) Find(platform, osName string) (types.MDMAssetConfiguration, error)
Find returns the configuration for (platform, osName). An empty osName matches when the platform has exactly one configuration. The returned error names what is available and is safe to surface to the admin.
func (*Loader) Manifest ¶
func (l *Loader) Manifest() types.MDMAssetManifest
Manifest returns a detached copy of the validated manifest for persistence and API discovery without reopening the archive.
func (*Loader) RenderAll ¶
func (l *Loader) RenderAll(values map[string]any) ([]RenderedArtifact, error)
RenderAll completes and validates values once, then renders every target in the immutable bundle. It returns no partial result if any target fails.
func (*Loader) RenderInstructions ¶
func (l *Loader) RenderInstructions(c types.MDMAssetConfiguration, values map[string]any) (string, error)
RenderInstructions renders the configuration's instructions template with values into the markdown setup guide clients display.
func (*Loader) ValidateTemplates ¶
ValidateTemplates executes every rendered asset against completed values without copying binary assets. This catches missing template inputs before a deployment is saved instead of deferring the failure until download.