Replaces Ninite for endpoint software: one catalog, one command line, and the same behaviour on Windows, macOS and Linux. Single static binary, no server and no agent, driven from an RMM script runner or by hand. - catalog of ~50 apps compiled into the binary, extendable with YAML overlays in catalog.d or via --catalog, no rebuild required - providers: winget, choco, brew, cask, apt, dnf/yum, zypper, pacman, flatpak, snap, plus direct vendor downloads (msi/exe/msu/dmg/pkg/deb/rpm/zip/tar.gz/ AppImage) - sources are tried in order and fall through, so one catalog entry covers winget on Windows, a cask on macOS and the vendor .deb on Debian - provider-independent detection (registry, paths, commands) makes runs idempotent even for software installed by hand - unattended by construction: stdin closed, silent flags, per-command timeouts - handles the traps that break naive wrappers: winget missing under SYSTEM, Homebrew refusing root, 1641/3010 reboot exits, "already installed" reported as failure - --json summary on stdout with progress on stderr, and RMM-friendly exit codes (0 ok, 1 failed, 2 usage, 3 privileges) Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
76 lines
2.0 KiB
Go
76 lines
2.0 KiB
Go
// This test needs internal/provider, which imports internal/catalog, so it
|
|
// lives in the external test package to avoid an import cycle.
|
|
package catalog_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.starwarslab.us/ATOM_IT/Deployr/internal/catalog"
|
|
"git.starwarslab.us/ATOM_IT/Deployr/internal/provider"
|
|
)
|
|
|
|
// TestSourcesUseKnownProviders catches a typo in a catalog source before it
|
|
// turns into a runtime "unknown provider" on someone's endpoint.
|
|
func TestSourcesUseKnownProviders(t *testing.T) {
|
|
cat, err := catalog.Embedded()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, app := range cat.Apps {
|
|
for _, goos := range app.Platforms() {
|
|
for _, src := range app.TargetFor(goos).Sources {
|
|
p, ok := provider.Get(src.Provider)
|
|
if !ok {
|
|
t.Errorf("%s/%s: unknown provider %q", app.ID, goos, src.Provider)
|
|
continue
|
|
}
|
|
supported := false
|
|
for _, os := range p.OSes() {
|
|
if os == goos {
|
|
supported = true
|
|
break
|
|
}
|
|
}
|
|
if !supported {
|
|
t.Errorf("%s: provider %q cannot run on %s", app.ID, src.Provider, goos)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// TestDirectSourcesAreInstallable checks the two rules the direct provider
|
|
// enforces at runtime: an exe needs silent switches, and a zip needs somewhere
|
|
// to go. Catching these here beats catching them on an endpoint.
|
|
func TestDirectSourcesAreInstallable(t *testing.T) {
|
|
cat, err := catalog.Embedded()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, app := range cat.Apps {
|
|
for _, goos := range app.Platforms() {
|
|
for _, src := range app.TargetFor(goos).Sources {
|
|
if src.Provider != "direct" {
|
|
continue
|
|
}
|
|
kind := src.Kind
|
|
if kind == "" {
|
|
kind = provider.InferKind(src.URLFor("amd64"))
|
|
}
|
|
switch kind {
|
|
case "":
|
|
t.Errorf("%s/%s: cannot infer installer kind from %q; set kind", app.ID, goos, src.URL)
|
|
case "exe":
|
|
if len(src.SilentArgs) == 0 {
|
|
t.Errorf("%s/%s: exe source has no silent_args", app.ID, goos)
|
|
}
|
|
case "zip":
|
|
if src.Dest == "" && goos != "darwin" {
|
|
t.Errorf("%s/%s: zip source has no dest", app.ID, goos)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|