Skip to content

Commit

Permalink
[chore] delete code to set a version and date, as it it not used (#10715
Browse files Browse the repository at this point in the history
)
  • Loading branch information
atoulme authored Jul 30, 2024
1 parent ea769c5 commit b53f57d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
2 changes: 1 addition & 1 deletion cmd/builder/internal/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ configuration is provided, ocb will generate a default Collector.

func initConfig(flags *flag.FlagSet) error {
cfg.Logger.Info("OpenTelemetry Collector Builder",
zap.String("version", version), zap.String("date", date))
zap.String("version", version))

var provider koanf.Provider

Expand Down
21 changes: 4 additions & 17 deletions cmd/builder/internal/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,12 @@ import (

var (
version = ""
date = "unknown"
)

// binVersion returns the version of the binary.
// If the version is not set, it attempts to read the build information.
// Returns an error if the build information cannot be read.
func binVersion() (string, error) {
if version != "" {
return version, nil
}
info, ok := debug.ReadBuildInfo()
if !ok {
return "", fmt.Errorf("failed to read build info")
}
return info.Main.Version, nil
func init() {
// the second returned value is a boolean, which is true if the binaries are built with module support.
info, _ := debug.ReadBuildInfo()
version = info.Main.Version
}

func versionCommand() *cobra.Command {
Expand All @@ -35,10 +26,6 @@ func versionCommand() *cobra.Command {
Short: "Version of ocb",
Long: "Prints the version of the ocb binary",
RunE: func(cmd *cobra.Command, _ []string) error {
version, err := binVersion()
if err != nil {
return err
}
cmd.Println(fmt.Sprintf("%s version %s", cmd.Parent().Name(), version))
return nil
},
Expand Down

0 comments on commit b53f57d

Please sign in to comment.