Documentation
¶
Index ¶
- func ASCIIEqualFold(s, t string) bool
- func AgentVersionsMatch(a, b string) bool
- func CopySlogValuesToNewCtx(sourceCtx, destCtx context.Context) context.Context
- func DetectFileType(data []byte) string
- func FetchTools(ctx context.Context, cli common.GithubClient) ([]commonParams.RunnerApplicationDownload, error)
- func GetCloudConfigSpecFromExtraSpecs(extraSpecs json.RawMessage) (cloudconfig.CloudConfigSpec, error)
- func GetSlogValuesFromContext(ctx context.Context) []slog.Attr
- func GetTmpFileHandle(baseDir string) (*os.File, error)
- func IsChecksumAsset(name string) bool
- func MarshalReleaseIndex(index AgentReleaseIndex) ([]byte, error)
- func MaybeAddWrapperToExtraSpecs(ctx context.Context, param commonParams.BootstrapInstance) commonParams.BootstrapInstance
- func MergeTools(base, override []commonParams.RunnerApplicationDownload) []commonParams.RunnerApplicationDownload
- func ParseGARMAgentAssetName(name string) (osType, osArch string, err error)
- func ScaleSetPseudoPoolID(entityID string, scaleSetID uint) string
- func ToolsFromRelease(release GitHubRelease) map[string]params.GARMAgentTool
- func WithSlogContext(ctx context.Context, attrs ...slog.Attr) context.Context
- type AgentReleaseIndex
- type GitHubRelease
- func FindAgentRelease(releases GitHubReleases, version string) (GitHubRelease, bool)
- func LatestRelease(releases GitHubReleases) (GitHubRelease, bool)
- func ParseRelease(data []byte) (GitHubRelease, error)
- func ResolveAgentRelease(releases GitHubReleases, version string) (release GitHubRelease, found bool)
- type GitHubReleaseAsset
- type GitHubReleases
- type SlogMultiHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ASCIIEqualFold ¶ added in v0.2.0
func AgentVersionsMatch ¶ added in v0.2.2
AgentVersionsMatch compares two agent versions, tolerating a leading "v" on either side ("v1.2.3" refers to the release tagged "1.2.3" and vice versa).
This is deliberately tag identity, not semver precedence: at least one side is always a raw tag name from the configured releases endpoint, which is not guaranteed to be valid semver. golang.org/x/mod/semver's Compare treats all invalid version strings as equal to one another and ignores build metadata, either of which would produce false matches when deciding whether a stored tool already has the desired version.
func CopySlogValuesToNewCtx ¶ added in v0.2.0
func DetectFileType ¶ added in v0.2.0
DetectFileType detects the MIME type from file content
func FetchTools ¶ added in v0.2.0
func FetchTools(ctx context.Context, cli common.GithubClient) ([]commonParams.RunnerApplicationDownload, error)
func GetCloudConfigSpecFromExtraSpecs ¶ added in v0.2.0
func GetCloudConfigSpecFromExtraSpecs(extraSpecs json.RawMessage) (cloudconfig.CloudConfigSpec, error)
func GetSlogValuesFromContext ¶ added in v0.2.0
func IsChecksumAsset ¶ added in v0.2.2
IsChecksumAsset returns true for release assets that only carry a checksum of another asset (e.g. foo.sha256). These are not agent binaries and are redundant in asset listings, which surface the digests directly.
func MarshalReleaseIndex ¶ added in v0.2.2
func MarshalReleaseIndex(index AgentReleaseIndex) ([]byte, error)
MarshalReleaseIndex serializes an AgentReleaseIndex for storage on the controller.
func MaybeAddWrapperToExtraSpecs ¶ added in v0.2.0
func MaybeAddWrapperToExtraSpecs(ctx context.Context, param commonParams.BootstrapInstance) commonParams.BootstrapInstance
func MergeTools ¶ added in v0.2.2
func MergeTools(base, override []commonParams.RunnerApplicationDownload) []commonParams.RunnerApplicationDownload
MergeTools merges two sets of runner tools on their OS/arch combo. An entry in override replaces the base entry for the same combo, and combos only override knows about are kept.
It lets the tools metadata URL configured on an endpoint take precedence over what the forge API reports, while keeping the combos only the forge publishes. Within either set, the first entry for a combo wins.
Note: This does not check versions of tools from the override URL. If the 3td party tools URL serves outdated tools, GARM does not check. Runners using tools that are too old, may not be able to connect to GitHub.
func ParseGARMAgentAssetName ¶ added in v0.2.0
ParseGARMAgentAssetName parses a garm-agent asset name to extract OS type and architecture
func ScaleSetPseudoPoolID ¶ added in v0.2.2
ScaleSetPseudoPoolID derives a stable, UUID-shaped pseudo pool ID for a scale set, from the forge entity ID and the internal scale set database ID. Both inputs are immutable, so the result never changes for the lifetime of the scale set and always fits within provider tag/label length limits.
func ToolsFromRelease ¶ added in v0.2.2
func ToolsFromRelease(release GitHubRelease) map[string]params.GARMAgentTool
ToolsFromRelease extracts the GARM agent tools of a single release, indexed by "os_type/os_arch". Assets that do not look like agent binaries (checksum files, unrelated files) are skipped.
Types ¶
type AgentReleaseIndex ¶ added in v0.2.2
type AgentReleaseIndex struct {
SourceURL string `json:"source_url"`
Releases GitHubReleases `json:"releases"`
}
AgentReleaseIndex is the cached list of garm-agent releases fetched from the controller's GARMAgentReleasesURL. The source URL is stored alongside the releases so that changing the URL on the controller invalidates the cached index.
func ParseReleaseIndex ¶ added in v0.2.2
func ParseReleaseIndex(data []byte) (AgentReleaseIndex, error)
ParseReleaseIndex parses a cached AgentReleaseIndex blob as stored on the controller.
type GitHubRelease ¶ added in v0.2.0
type GitHubRelease struct {
TagName string `json:"tag_name"`
Name string `json:"name"`
TarballURL string `json:"tarball_url"`
Assets []GitHubReleaseAsset `json:"assets"`
Prerelease bool `json:"prerelease"`
// Body is the description of the release.
Body string `json:"body"`
}
GitHubRelease represents a GitHub release
func FindAgentRelease ¶ added in v0.2.2
func FindAgentRelease(releases GitHubReleases, version string) (GitHubRelease, bool)
FindAgentRelease returns the release whose tag matches the given version (see AgentVersionsMatch).
func LatestRelease ¶ added in v0.2.2
func LatestRelease(releases GitHubReleases) (GitHubRelease, bool)
LatestRelease returns the newest stable release from a release index, falling back to the newest release when only pre-releases exist. Releases are expected in the order the API returns them: newest first.
It is used both for garm-agent releases and for the runner tools published at an endpoint tools metadata URL.
func ParseRelease ¶ added in v0.2.2
func ParseRelease(data []byte) (GitHubRelease, error)
ParseRelease parses a single GitHub release object.
func ResolveAgentRelease ¶ added in v0.2.2
func ResolveAgentRelease(releases GitHubReleases, version string) (release GitHubRelease, found bool)
ResolveAgentRelease picks the release the controller should use from a release index. An empty version or "latest" resolves to the latest release (see LatestRelease); any other version selects the release with the matching tag. When the requested version is not present in the index, the latest release is returned and found is false — callers decide whether to warn or attempt a targeted fetch, but there is always a usable release as long as the index is not empty.
type GitHubReleaseAsset ¶ added in v0.2.0
type GitHubReleaseAsset struct {
ID uint `json:"id"`
Name string `json:"name"`
Size uint `json:"size"`
DownloadCount uint `json:"download_count"`
CreatedAt time.Time `json:"created_at"`
Digest string `json:"digest"`
DownloadURL string `json:"browser_download_url"`
}
GitHubReleaseAsset represents an asset from a GitHub release
type GitHubReleases ¶ added in v0.2.0
type GitHubReleases []GitHubRelease
GitHubReleases represents an array of GitHub releases
func ParseReleaseList ¶ added in v0.2.2
func ParseReleaseList(data []byte) (GitHubReleases, error)
ParseReleaseList parses the response of a GitHub-compatible /releases endpoint. The data must be a JSON array of releases, each carrying a tag_name; anything else is an error. Single release objects (e.g. from a /releases/latest endpoint) are intentionally not accepted: the releases URL is validated when it is configured on the controller.