Documentation
¶
Index ¶
- Constants
- func AssetArchiveName(product, version, kind string) string
- func AssetCacheDir(product, version, kind string) (string, error)
- func AssetCacheRoot() (string, error)
- func AssetReleaseNames(version string) []string
- func AssetReleaseURLPath(product, version, kind string) string
- func CacheComplete(product, version, kind string) bool
- func ClientVersion() string
- func EnsureAsset(ctx context.Context, product, version, kind string, cfg EnsureConfig) (string, error)
- func NormalizeVersion(v string) string
- func ResolveBaseURL(cfg EnsureConfig) string
- func VersionNoPrefix(v string) string
- func WriteAssetCache(product, version, kind string, src fs.FS) error
- type EnsureConfig
Constants ¶
const ( ProductAgentRun = "agent-run" ProductAgentPro = "agent-pro" KindFrontend = "frontend" )
Product and kind constants used for cache paths and release archive names.
const EnvAssetBaseURL = "AGENT_PRO_ASSET_BASE_URL"
EnvAssetBaseURL is the environment variable for the default asset BaseURL.
Variables ¶
This section is empty.
Functions ¶
func AssetArchiveName ¶
AssetArchiveName returns the release archive basename for a product/kind/version. Example: agent-pro_v0.0.70_frontend.tar.gz
func AssetCacheDir ¶
AssetCacheDir returns the cache directory for a specific product/version/kind. Layout: {AssetCacheRoot}/{product}/{version}/{kind} Version is normalized to a leading "v".
func AssetCacheRoot ¶
AssetCacheRoot returns the root directory for downloaded SPA assets:
$XDG_CACHE_HOME/agent-pro/asset-cache
or, when XDG_CACHE_HOME is unset:
~/.cache/agent-pro/asset-cache
(via os.UserCacheDir).
func AssetReleaseNames ¶
AssetReleaseNames returns the frontend archive basenames for agent-run and agent-pro for the given version.
func AssetReleaseURLPath ¶
AssetReleaseURLPath returns the path segment after BaseURL for a release asset. Example: /v0.0.70/agent-pro_v0.0.70_frontend.tar.gz
func CacheComplete ¶
CacheComplete reports whether the on-disk SPA cache for product/version/kind looks like a real build: non-empty index.html and at least one non-empty file under assets/ (same idea as frontend DistComplete / spaDistComplete).
func ClientVersion ¶
func ClientVersion() string
ClientVersion returns the embedded client/module version with a leading "v" (e.g. "v0.0.70"). The source of truth is VERSION.txt in this package; keep the root module VERSION.txt in sync.
func EnsureAsset ¶
func EnsureAsset(ctx context.Context, product, version, kind string, cfg EnsureConfig) (string, error)
EnsureAsset ensures the SPA for product/version/kind is present and complete under the asset cache. If the cache is already complete, no network is used. Concurrent calls for the same key single-flight.
Archive URL:
{BaseURL}/v{version}/{product}_v{version}_{kind}.tar.gz
The archive root is the dist tree (index.html at archive root). Returns the cache directory path on success.
func NormalizeVersion ¶
NormalizeVersion trims whitespace and ensures a leading "v". Empty input yields empty string.
func ResolveBaseURL ¶
func ResolveBaseURL(cfg EnsureConfig) string
ResolveBaseURL returns cfg.BaseURL or the AGENT_PRO_ASSET_BASE_URL env value.
func VersionNoPrefix ¶
VersionNoPrefix returns the version without a leading "v"/"V".
Types ¶
type EnsureConfig ¶
type EnsureConfig struct {
// BaseURL is the release asset host prefix, e.g. https://example.com/assets.
// If empty, AGENT_PRO_ASSET_BASE_URL is used.
BaseURL string
// HTTPClient is optional; defaults to http.DefaultClient.
HTTPClient *http.Client
}
EnsureConfig configures EnsureAsset downloads.