versioncheck

package
v1.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package versioncheck implements a lightweight, opt-out version-check that reports anonymous start telemetry to the Boost OSS telemetry endpoint and notifies the user when a newer poutine release is available.

Index

Constants

View Source
const (
	// DisableEnv toggles the version check off when set to a truthy value.
	DisableEnv = "POUTINE_DISABLE_VERSION_CHECK"
	// URLEnv overrides the compiled-in endpoint, primarily for staging.
	URLEnv = "POUTINE_VERSION_CHECK_URL"
	// CIEnv signals an ephemeral CI run. When truthy, the check skips
	// reading and writing the user-level state file and tags the report
	// with ci=true.
	CIEnv = "CI"
)

Variables

View Source
var VersionCheckURL = "https://version-check.cicd.fun/v1/check"

VersionCheckURL is the default endpoint. It can be overridden at runtime via the POUTINE_VERSION_CHECK_URL environment variable, primarily for staging or local testing.

Functions

func ConfigPath

func ConfigPath() string

ConfigPath returns the path to the user-level state file. It honors POUTINE_CONFIG_DIR for tests and constrained environments and otherwise defaults to ~/.poutine/config.yaml.

func SaveConfig

func SaveConfig(cfg *Config) error

SaveConfig writes the user-level state file, creating the parent directory when needed. The file is written with restrictive permissions because it holds an anonymous instance identifier.

Types

type Config

type Config struct {
	InstanceID             string    `yaml:"instance_id,omitempty"`
	StartCount             int       `yaml:"start_count,omitempty"`
	LastReportedStartCount int       `yaml:"last_reported_start_count,omitempty"`
	LastVersionCheckAt     time.Time `yaml:"last_version_check_timestamp,omitempty"`
}

Config is the user-level state persisted between poutine invocations to support the once-per-day version check. It is intentionally separate from the project-level models.Config that is loaded from .poutine.yml.

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig reads the user-level state file. A missing file is not an error and yields a nil Config so callers can treat it as a first run.

type Result

type Result struct {
	LatestVersion   string `json:"latest_version,omitempty"`
	LatestURL       string `json:"latest_url,omitempty"`
	UpdateAvailable bool   `json:"update_available"`
}

Result mirrors the JSON response from the oss-telemetry /v1/check endpoint.

func Run

func Run(ctx context.Context, version string, disabled bool) *Result

Run records a CLI start and, at most once every 24 hours, reports anonymous telemetry to the configured endpoint and returns the latest release info. The HTTP call is bounded by checkTimeout (derived from ctx) so it never noticeably slows down poutine startup.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL