Skip to content

Commit

Permalink
Fix version tag management
Browse files Browse the repository at this point in the history
  • Loading branch information
chansuke committed Nov 24, 2023
1 parent 0122aa8 commit 2768527
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions kustomize/commands/version/version.go
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"io"
"os"
"runtime/debug"

"github.com/spf13/cobra"
"sigs.k8s.io/kustomize/api/provenance"
Expand Down Expand Up @@ -62,12 +63,24 @@ func (o *Options) Validate(_ []string) error {
}

func (o *Options) Run() error {
bi, ok := debug.ReadBuildInfo()
if !ok {
return fmt.Errorf("unable to read build information")
}

var version string
for _, dep := range bi.Deps {
if dep.Path == "sigs.k8s.io/kustomize/kustomize" {
version = dep.Version
break
}
}
switch o.Output {
case "":
if o.Short {
fmt.Fprintln(o.Writer, provenance.GetProvenance().Short())
fmt.Fprintln(o.Writer, version)
} else {
fmt.Fprintln(o.Writer, provenance.GetProvenance().Semver())
fmt.Fprintln(o.Writer, version)
}
case "yaml":
marshalled, err := yaml.Marshal(provenance.GetProvenance())
Expand Down

0 comments on commit 2768527

Please sign in to comment.