refactor(agent): update version handling in AgentConfig to use pkg.Version type

This commit is contained in:
yusing
2025-09-21 11:51:17 +08:00
parent 2f7fdc4c51
commit ccdc0046fd

View File

@@ -22,7 +22,7 @@ import (
type AgentConfig struct {
Addr string `json:"addr"`
Name string `json:"name"`
Version string `json:"version"`
Version pkg.Version `json:"version"`
Runtime ContainerRuntime `json:"runtime"`
httpClient *http.Client
@@ -148,11 +148,10 @@ func (cfg *AgentConfig) StartWithCerts(ctx context.Context, ca, crt, key []byte)
return fmt.Errorf("failed to get agent runtime: HTTP %d %s", status, runtimeBytes)
}
cfg.Version = string(agentVersionBytes)
agentVersion := pkg.ParseVersion(cfg.Version)
cfg.Version = pkg.ParseVersion(string(agentVersionBytes))
if serverVersion.IsNewerMajorThan(agentVersion) {
log.Warn().Msgf("agent %s major version mismatch: server: %s, agent: %s", cfg.Name, serverVersion, agentVersion)
if serverVersion.IsNewerThanMajor(cfg.Version) {
log.Warn().Msgf("agent %s major version mismatch: server: %s, agent: %s", cfg.Name, serverVersion, cfg.Version)
}
log.Info().Msgf("agent %q initialized", cfg.Name)