diff --git a/go.mod b/go.mod index 19538a4..4fa18c2 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/hashicorp/go-multierror v1.1.1 github.com/krishicks/yaml-patch v0.0.10 github.com/pelletier/go-toml v1.9.5 - github.com/prometheus/common v0.51.1 + github.com/prometheus/common v0.52.2 gopkg.in/yaml.v2 v2.4.0 ) diff --git a/go.sum b/go.sum index 0cefa6e..2be5a76 100644 --- a/go.sum +++ b/go.sum @@ -31,8 +31,8 @@ github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCko github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/common v0.51.1 h1:eIjN50Bwglz6a/c3hAgSMcofL3nD+nFQkV6Dd4DsQCw= -github.com/prometheus/common v0.51.1/go.mod h1:lrWtQx+iDfn2mbH5GUzlH9TSHyfZpHkSiG1W7y3sF2Q= +github.com/prometheus/common v0.52.2 h1:LW8Vk7BccEdONfrJBDffQGRtpSzi5CQaRZGtboOO2ck= +github.com/prometheus/common v0.52.2/go.mod h1:lrWtQx+iDfn2mbH5GUzlH9TSHyfZpHkSiG1W7y3sF2Q= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= diff --git a/vendor/github.com/prometheus/common/version/info.go b/vendor/github.com/prometheus/common/version/info.go index 044032c..197d95e 100644 --- a/vendor/github.com/prometheus/common/version/info.go +++ b/vendor/github.com/prometheus/common/version/info.go @@ -17,6 +17,7 @@ import ( "bytes" "fmt" "runtime" + "runtime/debug" "strings" "text/template" ) @@ -31,6 +32,9 @@ var ( GoVersion = runtime.Version() GoOS = runtime.GOOS GoArch = runtime.GOARCH + + computedRevision string + computedTags string ) // versionInfoTmpl contains the template used by Info. @@ -74,3 +78,48 @@ func Info() string { func BuildContext() string { return fmt.Sprintf("(go=%s, platform=%s, user=%s, date=%s, tags=%s)", GoVersion, GoOS+"/"+GoArch, BuildUser, BuildDate, GetTags()) } + +func GetRevision() string { + if Revision != "" { + return Revision + } + return computedRevision +} + +func GetTags() string { + return computedTags +} + +func init() { + computedRevision, computedTags = computeRevision() +} + +func computeRevision() (string, string) { + var ( + rev = "unknown" + tags = "unknown" + modified bool + ) + + buildInfo, ok := debug.ReadBuildInfo() + if !ok { + return rev, tags + } + for _, v := range buildInfo.Settings { + if v.Key == "vcs.revision" { + rev = v.Value + } + if v.Key == "vcs.modified" { + if v.Value == "true" { + modified = true + } + } + if v.Key == "-tags" { + tags = v.Value + } + } + if modified { + return rev + "-modified", tags + } + return rev, tags +} diff --git a/vendor/github.com/prometheus/common/version/info_default.go b/vendor/github.com/prometheus/common/version/info_default.go deleted file mode 100644 index 684996f..0000000 --- a/vendor/github.com/prometheus/common/version/info_default.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2022 The Prometheus Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//go:build !go1.18 -// +build !go1.18 - -package version - -func GetRevision() string { - return Revision -} - -func getTags() string { - return "unknown" // Not available prior to Go 1.18 -} diff --git a/vendor/github.com/prometheus/common/version/info_go118.go b/vendor/github.com/prometheus/common/version/info_go118.go deleted file mode 100644 index 992623c..0000000 --- a/vendor/github.com/prometheus/common/version/info_go118.go +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2022 The Prometheus Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//go:build go1.18 -// +build go1.18 - -package version - -import "runtime/debug" - -var ( - computedRevision string - computedTags string -) - -func GetRevision() string { - if Revision != "" { - return Revision - } - return computedRevision -} - -func GetTags() string { - return computedTags -} - -func init() { - computedRevision, computedTags = computeRevision() -} - -func computeRevision() (string, string) { - var ( - rev = "unknown" - tags = "unknown" - modified bool - ) - - buildInfo, ok := debug.ReadBuildInfo() - if !ok { - return rev, tags - } - for _, v := range buildInfo.Settings { - if v.Key == "vcs.revision" { - rev = v.Value - } - if v.Key == "vcs.modified" { - if v.Value == "true" { - modified = true - } - } - if v.Key == "-tags" { - tags = v.Value - } - } - if modified { - return rev + "-modified", tags - } - return rev, tags -} diff --git a/vendor/modules.txt b/vendor/modules.txt index d71a638..d48a73a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -22,7 +22,7 @@ github.com/krishicks/yaml-patch # github.com/pelletier/go-toml v1.9.5 ## explicit; go 1.12 github.com/pelletier/go-toml -# github.com/prometheus/common v0.51.1 +# github.com/prometheus/common v0.52.2 ## explicit; go 1.21 github.com/prometheus/common/version # github.com/xhit/go-str2duration/v2 v2.1.0