Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistent logging #155

Merged
merged 9 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (a *api) handleGETHostState(c jape.Context) {
Version: build.Version(),
Commit: build.Commit(),
OS: runtime.GOOS,
BuildTime: build.BuildTime(),
BuildTime: build.Time(),
},
})
}
Expand Down
18 changes: 18 additions & 0 deletions build/build.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
// Package build contains build-time information.
package build

//go:generate go run gen.go

import "time"

// NetworkName returns the human-readable name of the current network.
func NetworkName() string {
n, _ := Network()
Expand All @@ -14,3 +17,18 @@ func NetworkName() string {
return n.Name
}
}

// Commit returns the commit hash of hostd
func Commit() string {
return commit
}

// Version returns the version of hostd
func Version() string {
return version
}

// Time returns the time at which the binary was built.
func Time() time.Time {
return time.Unix(buildTime, 0)
}
22 changes: 1 addition & 21 deletions build/gen.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//go:build ignore

// This script generates meta.go which contains version info for the hostd binary. It can be run with `go generate`.
//
//go:generate -command go run gen.go
package main

import (
Expand Down Expand Up @@ -34,30 +32,12 @@ var buildTemplate = template.Must(template.New("").Parse(`// Code generated by g
// This file was generated by go generate at {{ .RunTime }}.
package build

import (
"time"
)

const (
commit = "{{ .Commit }}"
version = "{{ .Version }}"
buildTime = {{ .UnixTimestamp }}
)

// Commit returns the commit hash of hostd
func Commit() string {
return commit
}

// Version returns the version of hostd
func Version() string {
return version
}

// BuildTime returns the time at which the binary was built.
func BuildTime() time.Time {
return time.Unix(buildTime, 0)
}`))
`))

// UnmarshalJSON implements the json.Unmarshaler interface.
func (t *gitTime) UnmarshalJSON(buf []byte) error {
Expand Down
25 changes: 2 additions & 23 deletions build/meta.go
Original file line number Diff line number Diff line change
@@ -1,28 +1,7 @@
// Code generated by go generate; DO NOT EDIT.
// This file was generated by go generate at 2023-04-28T06:48:04-06:00.
package build

import (
"time"
)

const (
commit = "?"
version = "?"
commit = "?"
version = "?"
buildTime = 0
)

// Commit returns the commit hash of hostd
func Commit() string {
return commit
}

// Version returns the version of hostd
func Version() string {
return version
}

// BuildTime returns the time at which the binary was built.
func BuildTime() time.Time {
return time.Unix(buildTime, 0)
}
Loading