-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgenerate_versions.go
More file actions
48 lines (39 loc) · 1 KB
/
generate_versions.go
File metadata and controls
48 lines (39 loc) · 1 KB
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
40
41
42
43
44
45
46
47
48
//go:build ignore
package main
import (
"fmt"
"os"
"runtime/debug"
"strings"
"github.com/hashicorp/vault/api"
"github.com/hashicorp/vault/sdk/helper/testcluster"
)
const depVersions = `// Package config - DO NOT EDIT - Code generated by generate_versions.go
package config
const (
vaultAPIVersion = "%v"
vaultSDKVersion = "%v"
)
`
func main() {
vApi, vSdk := "", ""
if true == false {
fmt.Printf("%v", api.EnvVaultAddress)
fmt.Printf("%v", testcluster.EnvVaultLicenseCI)
}
if info, ok := debug.ReadBuildInfo(); ok {
for _, dep := range info.Deps {
if !strings.Contains(dep.Path, "github.com/hashicorp/vault") {
continue
}
if strings.Contains(dep.Path, "github.com/hashicorp/vault/sdk") {
vSdk = dep.Version
} else if strings.Contains(dep.Path, "github.com/hashicorp/vault/api") {
vApi = dep.Version
}
}
}
if err := os.WriteFile("config/versions.go", fmt.Appendf([]byte{}, depVersions, vApi, vSdk), 0o644); err != nil {
panic("failed writing config/versions.go")
}
}