2026-01-29 02:05:01 +00:00
|
|
|
// Package sources provides image download sources for core-devops.
|
|
|
|
|
package sources
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
Migrate pkg/devops to Medium abstraction (#293)
* chore(io): migrate pkg/devops to Medium abstraction
This commit migrates the pkg/devops package to use the io.Medium abstraction instead of direct calls to io.Local or the os package.
Changes:
- Updated DevOps, ImageManager, and Manifest structs to hold an io.Medium.
- Updated New, NewImageManager, and LoadConfig to accept an io.Medium.
- Updated ImageSource interface and its implementations (GitHubSource, CDNSource) to accept io.Medium in Download method.
- Refactored internal helper functions (hasFile, hasPackageScript, etc.) to use io.Medium.
- Updated all unit tests and CLI entry points to pass the appropriate io.Medium.
This migration improves the testability and flexibility of the devops package by allowing for different storage backends.
* chore(io): migrate pkg/devops to Medium abstraction
This commit completes the migration of the pkg/devops package to the io.Medium abstraction.
Changes:
- Refactored DevOps, ImageManager, and Manifest structs to use io.Medium for storage operations.
- Updated New, NewImageManager, and LoadConfig to accept an io.Medium.
- Updated ImageSource interface and its implementations (GitHubSource, CDNSource) to accept io.Medium in Download method.
- Refactored internal helper functions (hasFile, hasPackageScript, etc.) to use io.Medium.
- Updated all unit tests and CLI entry points to pass the appropriate io.Medium.
- Fixed formatting issues in test files.
This migration enables easier testing and supports alternative storage backends.
2026-02-04 14:58:03 +00:00
|
|
|
|
refactor: strip to pure package library (#3)
- Fix remaining 187 pkg/ files referencing core/cli → core/go
- Move SDK library code from internal/cmd/sdk/ → pkg/sdk/ (new package)
- Create pkg/rag/helpers.go with convenience functions from internal/cmd/rag/
- Fix pkg/mcp/tools_rag.go to use pkg/rag instead of internal/cmd/rag
- Fix pkg/build/buildcmd/cmd_sdk.go and pkg/release/sdk.go to use pkg/sdk
- Remove all non-library content: main.go, internal/, cmd/, docker/,
scripts/, tasks/, tools/, .core/, .forgejo/, .woodpecker/, Taskfile.yml
- Run go mod tidy to trim unused dependencies
core/go is now a pure Go package suite (library only).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Claude <developers@lethean.io>
Reviewed-on: https://forge.lthn.ai/core/go/pulls/3
2026-02-16 14:23:45 +00:00
|
|
|
"forge.lthn.ai/core/go/pkg/io"
|
2026-01-29 02:05:01 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// ImageSource defines the interface for downloading dev images.
|
|
|
|
|
type ImageSource interface {
|
|
|
|
|
// Name returns the source identifier.
|
|
|
|
|
Name() string
|
|
|
|
|
// Available checks if this source can be used.
|
|
|
|
|
Available() bool
|
|
|
|
|
// LatestVersion returns the latest available version.
|
|
|
|
|
LatestVersion(ctx context.Context) (string, error)
|
|
|
|
|
// Download downloads the image to the destination path.
|
|
|
|
|
// Reports progress via the callback if provided.
|
Migrate pkg/devops to Medium abstraction (#293)
* chore(io): migrate pkg/devops to Medium abstraction
This commit migrates the pkg/devops package to use the io.Medium abstraction instead of direct calls to io.Local or the os package.
Changes:
- Updated DevOps, ImageManager, and Manifest structs to hold an io.Medium.
- Updated New, NewImageManager, and LoadConfig to accept an io.Medium.
- Updated ImageSource interface and its implementations (GitHubSource, CDNSource) to accept io.Medium in Download method.
- Refactored internal helper functions (hasFile, hasPackageScript, etc.) to use io.Medium.
- Updated all unit tests and CLI entry points to pass the appropriate io.Medium.
This migration improves the testability and flexibility of the devops package by allowing for different storage backends.
* chore(io): migrate pkg/devops to Medium abstraction
This commit completes the migration of the pkg/devops package to the io.Medium abstraction.
Changes:
- Refactored DevOps, ImageManager, and Manifest structs to use io.Medium for storage operations.
- Updated New, NewImageManager, and LoadConfig to accept an io.Medium.
- Updated ImageSource interface and its implementations (GitHubSource, CDNSource) to accept io.Medium in Download method.
- Refactored internal helper functions (hasFile, hasPackageScript, etc.) to use io.Medium.
- Updated all unit tests and CLI entry points to pass the appropriate io.Medium.
- Fixed formatting issues in test files.
This migration enables easier testing and supports alternative storage backends.
2026-02-04 14:58:03 +00:00
|
|
|
Download(ctx context.Context, m io.Medium, dest string, progress func(downloaded, total int64)) error
|
2026-01-29 02:05:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SourceConfig holds configuration for a source.
|
|
|
|
|
type SourceConfig struct {
|
|
|
|
|
// GitHub configuration
|
|
|
|
|
GitHubRepo string
|
|
|
|
|
// Registry configuration
|
|
|
|
|
RegistryImage string
|
|
|
|
|
// CDN configuration
|
|
|
|
|
CDNURL string
|
|
|
|
|
// Image name (e.g., core-devops-darwin-arm64.qcow2)
|
|
|
|
|
ImageName string
|
|
|
|
|
}
|