-
Notifications
You must be signed in to change notification settings - Fork 9
/
version.go
39 lines (32 loc) · 885 Bytes
/
version.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Package version provide information about the build version
package version
import (
"runtime/debug"
)
const xk6DisruptorPath = "github.com/grafana/xk6-disruptor"
// DisruptorVersion returns the version of the currently executed disruptor
func DisruptorVersion() string {
if bi, ok := debug.ReadBuildInfo(); ok {
for _, d := range bi.Deps {
if d.Path == xk6DisruptorPath {
if d.Replace != nil {
return d.Replace.Version
}
return d.Version
}
}
}
return ""
}
// AgentImage returns the name of the agent image that corresponds to
// this version of the extension.
func AgentImage() string {
tag := "latest"
// if a specific version of the disruptor was built, use it for agent's tag
// (go test sets version to "")
dv := DisruptorVersion()
if dv != "" && dv != "(devel)" {
tag = dv
}
return "ghcr.io/grafana/xk6-disruptor-agent:" + tag
}