[chore] delete code to set a version and date, as it it not used (#10715)

This commit is contained in:
Antoine Toulme 2024-07-30 11:22:06 -07:00 committed by GitHub
parent ea769c5a90
commit b53f57dc89
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 18 deletions

View File

@ -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

View File

@ -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 {
@ -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
},