Skip to content

Commit

Permalink
WIP: Fix version tag management
Browse files Browse the repository at this point in the history
  • Loading branch information
chansuke committed Nov 23, 2023
1 parent 0122aa8 commit f084ef6
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions kustomize/commands/version/version.go
Original file line number Diff line number Diff line change
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,13 +63,21 @@ 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())
} else {
fmt.Fprintln(o.Writer, provenance.GetProvenance().Semver())
}
fmt.Fprintln(o.Writer, version)
case "yaml":
marshalled, err := yaml.Marshal(provenance.GetProvenance())
if err != nil {
Expand Down

0 comments on commit f084ef6

Please sign in to comment.