Skip to content

Commit 38e535f

Browse files
committed
[tunnel] advertise CLI build version as agent label
1 parent fca57c2 commit 38e535f

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

pkg/tunnel/client.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,18 @@ import (
2727
"k8s.io/apimachinery/pkg/util/sets"
2828
crmetrics "sigs.k8s.io/controller-runtime/pkg/metrics"
2929

30+
"github.com/apoxy-dev/apoxy/build"
3031
alog "github.com/apoxy-dev/apoxy/pkg/log"
3132
"github.com/apoxy-dev/apoxy/pkg/tunnel/bfdl"
3233
tunnelconn "github.com/apoxy-dev/apoxy/pkg/tunnel/connection"
3334
"github.com/apoxy-dev/apoxy/pkg/tunnel/metrics"
3435
"github.com/apoxy-dev/apoxy/pkg/tunnel/router"
3536
)
3637

38+
// LabelKeyVersion is the agent label that carries the CLI build version.
39+
// Always sent by Dial so AgentStatus.Labels can surface the agent's version.
40+
const LabelKeyVersion = "apoxy.dev/version"
41+
3742
var (
3843
ErrNotConnected = errors.New("not connected")
3944
)
@@ -293,6 +298,12 @@ func (d *TunnelDialer) Dial(
293298
for k, v := range options.labels {
294299
q.Add("label."+k, v)
295300
}
301+
// Always advertise the CLI build version so it surfaces in AgentStatus.
302+
// Caller-provided label wins (server reads values[0]) so tests/overrides
303+
// can substitute a value.
304+
if _, ok := options.labels[LabelKeyVersion]; !ok {
305+
q.Add("label."+LabelKeyVersion, build.BuildVersion)
306+
}
296307
q.Add(metrics.QueryParamAgentProcessID, metrics.AgentProcessID())
297308
addrUrl.RawQuery = q.Encode()
298309

0 commit comments

Comments
 (0)