Skip to content

Commit

Permalink
Fix git version parsing
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed Mar 28, 2024
1 parent 0a83027 commit 0ea2274
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,12 @@ limitations under the License.
package version

import (
"fmt"
"strings"
)

func BinaryVersion(s string) (string, error) {
if strings.HasPrefix(s, "v0.0.0-") {
return "v0.0.0", nil // special version if no ldflags are set
}
parts := strings.SplitN(s, "+", 2)
if len(parts) < 2 {
return "", fmt.Errorf("failed to parse version %q", s)
}

prefix := "kube-bind"
if !strings.HasPrefix(parts[1], prefix) {
return "", fmt.Errorf("failed to parse version %q", s)
}
return strings.SplitN(strings.TrimPrefix(parts[1], prefix+"-"), "-", 2)[0], nil
return s, nil
}

0 comments on commit 0ea2274

Please sign in to comment.