Skip to content

Latest commit

 

History

History
48 lines (34 loc) · 2.62 KB

File metadata and controls

48 lines (34 loc) · 2.62 KB

CLAUDE.md

Project Overview

snipe2jamf is a Go CLI tool that syncs asset data from Snipe-IT to Jamf Pro computers and mobile devices. It uses cobra for CLI commands, logrus for structured logging, and YAML config for field mappings.

Build & Run

go build -o snipe2jamf .
go run main.go sync --serial XXXXX --dry-run --debug

Architecture

  • cmd/ — cobra CLI commands (root, sync, validate, version)
  • internal/config/ — YAML config loading and validation
  • internal/sync/engine.go — computer sync engine (Jamf v3 API)
  • internal/sync/mobile.go — mobile device sync engine (Jamf v2 API)
  • internal/sync/shared.go — shared types (Result, FieldChange), Snipe-IT field extraction, transforms, computer field accessors

Key Design Decisions

  • Separate device type configscomputers: and mobile_devices: sections in YAML. Legacy flat mappings: is treated as computer mappings for backward compatibility.
  • Jamf v3 computer PATCH replaces entire subsections — the engine pre-populates update structs from current Jamf values (prefillFromJamf) so unchanged fields aren't wiped. Date fields use omitempty because Jamf rejects empty strings for dates.
  • Mobile device purchasing is type-scoped — Jamf nests purchasing under ios.purchasing or tvos.purchasing. The engine detects the device type and nests the update automatically. Mobile dates are ISO timestamps (2024-01-01T00:00:00Z), not date-only strings.
  • Different field names — computers use warrantyDate/leaseDate, mobile devices use warrantyExpiresDate/leaseExpiresDate.
  • Custom update structs — the v2 SDK's ResourceComputerInventory sends "id":"" without omitempty which Jamf rejects. We use our own minimal structs and call GetTransport().Patch() directly.
  • go-snipeit SDK — uses upstream michellepellon/go-snipeit which includes SnipeTime unmarshaling for date-only fields, flex types, and custom field support.

Dependencies

  • github.com/michellepellon/go-snipeit — Snipe-IT API client
  • github.com/deploymenttheory/go-sdk-jamfpro-v2 — Jamf Pro API client (v2 SDK)
  • github.com/sirupsen/logrus — structured logging
  • github.com/spf13/cobra — CLI framework
  • gopkg.in/yaml.v3 — config parsing

Config

Config file: snipe2jamf.yaml (see snipe2jamf.example.yaml). Do not commit the real config — it contains API tokens.

Conventions

  • Use --dry-run for safe testing
  • Use --debug for verbose field-level mapping output
  • logrus with fields for structured logging, never string interpolation
  • Run goimports for formatting, golangci-lint run before committing