update dependencies (#6267)

Signed-off-by: hongming <coder.scala@gmail.com>
This commit is contained in:
hongming
2024-11-06 10:27:06 +08:00
committed by GitHub
parent faf255a084
commit cfebd96a1f
4263 changed files with 341374 additions and 132036 deletions

View File

@@ -8,6 +8,8 @@ import (
"runtime"
"runtime/debug"
"strings"
"github.com/blang/semver/v4"
)
// These variables are set at build time using ldflags.
@@ -62,9 +64,42 @@ func GetProvenance() Provenance {
p.GitCommit = setting.Value
}
}
for _, dep := range info.Deps {
if dep != nil && dep.Path == "sigs.k8s.io/kustomize/kustomize/v5" {
if dep.Version != "devel" {
continue
}
v, err := GetMostRecentTag(*dep)
if err != nil {
fmt.Printf("failed to get most recent tag for %s: %v\n", dep.Path, err)
continue
}
p.Version = v
}
}
return p
}
func GetMostRecentTag(m debug.Module) (string, error) {
for m.Replace != nil {
m = *m.Replace
}
split := strings.Split(m.Version, "-")
sv, err := semver.Parse(strings.TrimPrefix(split[0], "v"))
if err != nil {
return "", fmt.Errorf("failed to parse version %s: %w", m.Version, err)
}
if len(split) > 1 && sv.Patch > 0 {
sv.Patch -= 1
}
return fmt.Sprintf("v%s", sv.FinalizeVersion()), nil
}
// Short returns the shortened provenance stamp.
func (v Provenance) Short() string {
return fmt.Sprintf(