Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( CurrentVersion string = "0.0.1" // Repo 是自动更新所查询的 GitHub 仓库(owner/name)。 // // 注意:这是 fork 的仓库,不是上游!上游把 agent 与面板分在两个仓库, // 而 Nekomari 是单仓,发布产物集中在同一个仓库里。 // 若这里沿用上游的 slug,fork 出来的 agent 会在一次自动更新后把自己 // 替换成上游二进制,从而静默丢掉本 fork 的全部新功能。 // 可通过 --update-repo / AGENT_UPDATE_REPO 覆盖。 Repo string = "Aone2233/Nekomari" )
Functions ¶
func CheckAndUpdateTo ¶
CheckAndUpdateTo installs a specific released version of this agent.
Returns nil when nothing was done, which covers the cases an operator most wants distinguished in a log: the target is already running, the target is not a release, or the asset for this platform is missing.
func DoUpdateWorks ¶
func DoUpdateWorks()
DoUpdateWorks 按六小时周期检查更新。
面板下发了期望版本(AGENT_TARGET_VERSION)时,这里只对齐到那个版本,不再自行追最新发布 —— 否则 一次「指定版本」会在下一个周期被自动更新覆盖掉,灰度与回滚都没有意义。清空期望版本即恢复原有行为。
func RequestedVersion ¶
func RequestedVersion() string
RequestedVersion is the version the panel asked this node to run, or empty to track releases.
The panel's target wins over `AGENT_TARGET_VERSION`, because the panel is where a rollout is decided: an operator who set a fleet-wide target and then saw it silently overridden by a leftover environment variable on one node would have no way to tell which had won. The environment variable remains as the deployment-level default for a fleet whose operator prefers to configure it in the unit file, and as the way to pin a node the panel cannot reach.
Read on each call rather than cached: a cached copy would defer an operator's change to the next restart, which is the opposite of what a rollout needs.
func SetRequestedVersion ¶
func SetRequestedVersion(target string)
SetRequestedVersion records a target the panel has pushed to this node.
Held in memory, not written to disk, and that is deliberate: the panel re-sends its target with every update event, and it also sends one on connection, so a restart re-learns it. Persisting it would mean a node that was once pointed at an old version kept going back to it after the operator had cleared the target and the panel was unreachable — the failure mode of a stale rollout that nobody can call off.
func TargetSatisfied ¶
TargetSatisfied reports whether the running version already matches a target.
Used to decide whether to keep checking. A target is compared as a string after normalising the `v` prefix, not as a semantic version: the operator asked for a specific release, and "0.1.41" and "0.1.41" are the same release whether or not something considers them equal in an ordering.
Types ¶
type AssetForProbe ¶
AssetForProbe is one release asset as the probe prints it.
type CandidateForProbe ¶
type CandidateForProbe struct {
TagName string
AssetName string
AssetURL string
ChecksumName string
ChecksumURL string
}
CandidateForProbe is a selection as the probe prints it.
func FindReleaseByTagForProbe ¶
func FindReleaseByTagForProbe(releases []ReleaseForProbe, tag, assetName string) (CandidateForProbe, bool)
FindReleaseByTagForProbe exposes findReleaseByTag.
type ReleaseForProbe ¶
type ReleaseForProbe struct {
TagName string
Draft bool
Prerelease bool
Assets []AssetForProbe
}
ReleaseForProbe is a release as the probe prints it.
func ListReleasesForProbe ¶
func ListReleasesForProbe() ([]ReleaseForProbe, error)
ListReleasesForProbe exposes listGitHubReleases.