Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

feat(labctl): implement images command suite - #30

Merged
jmgilman merged 4 commits into
masterfrom
joshuagilman/hom-20-labctl-images-command-implementations
Dec 20, 2025
Merged

feat(labctl): implement images command suite#30
jmgilman merged 4 commits into
masterfrom
joshuagilman/hom-20-labctl-images-command-implementations

Conversation

@jmgilman

Copy link
Copy Markdown
Collaborator

Summary

Implements the labctl images CLI commands for managing OS images in S3-compatible storage (iDrive e2) as part of the GitOps image pipeline.

Commands Implemented

  • sync - Download source images, verify checksums, decompress (xz/gzip/zstd), upload to e2, update file references
  • validate - Validate manifest structure and check source URL accessibility
  • list - List images stored in e2 with metadata (name, size, checksum, upload date)
  • prune - Remove orphaned images not referenced in manifest
  • upload - Upload local files to e2 with SHA256 checksum and metadata

Key Features

  • YAML manifest-based configuration (images.lab.gilman.io/v1alpha1)
  • Checksum verification (SHA256/SHA512) for source and decompressed content
  • Decompression support: xz, gzip, zstd
  • S3 metadata sidecar files (.meta.json) for image tracking
  • File updater with regex-based replacements and Go templates
  • GitHub Actions integration (outputs files_changed for PR automation)
  • SOPS-encrypted credentials support

Testing

  • Comprehensive unit tests with mocked S3 client (store.Client interface)
  • Mocked HTTP client for download tests (HTTPClient interface)
  • Full sync path tests: download → verify → decompress → upload → metadata
  • 79 tests total, all passing

Test plan

  • just all passes (fmt, lint, vet, test)
  • All commands have unit tests with mocked dependencies
  • Manifest validation reports all errors (not just first)
  • Full sync path tested with httptest and mock S3

Closes HOM-20

🤖 Generated with Claude Code

jmgilman and others added 4 commits December 19, 2025 21:06
Implement all CLI commands for the labctl images tool:

- sync: Download, verify, decompress (xz/gzip/zstd), upload to S3,
  write metadata, and update local files with regex replacements
- validate: Check manifest YAML syntax and verify URLs via HEAD requests
- list: Display images from S3 bucket with metadata in tabular format
- prune: Remove orphaned images not in manifest (with --dry-run)
- upload: Upload local files to S3 with SHA256 checksum and metadata

Also adds internal/updater package for regex-based file updates with
Go template variable substitution.

Closes HOM-20

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…rror validation

- Update validate command to report all validation errors instead of
  short-circuiting on first error
- Add ValidateAll() methods to ImageManifest and Image types that
  return []error instead of single error
- Add LoadManifestRaw() and ParseManifestRaw() functions for loading
  manifests without validation (allowing error collection)
- Add comprehensive unit tests for validate command with mock HTTP client
- Add unit tests for sync command (verifyChecksum, decompress, dry-run)
- Add unit tests for upload command (computeFileChecksum)
- Add unit tests for list command (formatSize)
- Add unit tests for prune command (error handling)

All tests pass with `go vet` and `golangci-lint` clean.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add comprehensive mocked tests for upload, list, prune, and sync commands:

- Add store.Client interface for dependency injection
- Create mockStoreClient test helper in testutil_test.go
- Refactor commands to accept store.Client interface
- Add runListWithClient, runPruneWithClient, runUploadWithClient helpers
- Add tests covering: success paths, error handling, edge cases

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add HTTPClient interface and full sync path tests with mocked HTTP:

- Add HTTPClient interface for dependency injection
- Add syncImageWithHTTP and downloadToTempWithClient functions
- Add httptest-based tests for download operations
- Add full sync path tests: download → verify → decompress → upload → metadata
- Test error paths: download failure, checksum mismatch, upload error

All sync behaviors now have mocked coverage without network calls.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@linear

linear Bot commented Dec 20, 2025

Copy link
Copy Markdown

@jmgilman
jmgilman merged commit 33e981b into master Dec 20, 2025
1 check passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant