Skip to content

Commit

Permalink
commitchecker: expose version
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
  • Loading branch information
stevekuznetsov committed Nov 27, 2023
1 parent 486debd commit 2e80328
Show file tree
Hide file tree
Showing 9 changed files with 396 additions and 0 deletions.
2 changes: 2 additions & 0 deletions commitchecker/commitchecker.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import (
"os"

"github.com/openshift/build-machinery-go/commitchecker/commitchecker"
"github.com/openshift/build-machinery-go/commitchecker/pkg/version"
)

func main() {
_, _ = fmt.Fprintf(os.Stdout, "commitchecker verson %v\n", version.Get().String())
opts := commitchecker.DefaultOptions()
opts.Bind(flag.CommandLine)
flag.Parse()
Expand Down
1 change: 1 addition & 0 deletions commitchecker/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ go 1.20

require (
github.com/google/go-cmp v0.5.9
k8s.io/apimachinery v0.28.4
sigs.k8s.io/yaml v1.4.0
)
2 changes: 2 additions & 0 deletions commitchecker/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
k8s.io/apimachinery v0.28.4 h1:zOSJe1mc+GxuMnFzD4Z/U1wst50X28ZNsn5bhgIIao8=
k8s.io/apimachinery v0.28.4/go.mod h1:wI37ncBvfAoswfq626yPTe6Bz1c22L7uaJ8dho83mgg=
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=
41 changes: 41 additions & 0 deletions commitchecker/pkg/version/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package version

import (
"fmt"
"runtime"

"k8s.io/apimachinery/pkg/version"
)

var (
// commitFromGit is a constant representing the source version that
// generated this build. It should be set during build via -ldflags.
commitFromGit string
// versionFromGit is a constant representing the version tag that
// generated this build. It should be set during build via -ldflags.
versionFromGit = "unknown"
// major version
majorFromGit string
// minor version
minorFromGit string
// build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ')
buildDate string
// state of git tree, either "clean" or "dirty"
gitTreeState string
)

// Get returns the overall codebase version. It's for detecting
// what code a binary was built from.
func Get() version.Info {
return version.Info{
Major: majorFromGit,
Minor: minorFromGit,
GitCommit: commitFromGit,
GitVersion: versionFromGit,
GitTreeState: gitTreeState,
BuildDate: buildDate,
GoVersion: runtime.Version(),
Compiler: runtime.Compiler,
Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH),
}
}
202 changes: 202 additions & 0 deletions commitchecker/vendor/k8s.io/apimachinery/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions commitchecker/vendor/k8s.io/apimachinery/pkg/version/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

88 changes: 88 additions & 0 deletions commitchecker/vendor/k8s.io/apimachinery/pkg/version/helpers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2e80328

Please sign in to comment.