Skip to content
Open
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
10 changes: 5 additions & 5 deletions internal/pkg/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ func (i Info) FullVersion() string {
return fmt.Sprintf("%s [%s built %s] (FIPS-distribution: %v)", i.Version, i.Commit, i.BuildTime, FIPSDistribution)
}

// Time parses the given string using RFC3339, or returns an empty time.Time.
func Time(stime string) time.Time {
// Time parses the given string using RFC3339, or returns an error if parsing fails.
func Time(stime string) (time.Time, error) {
t, err := time.Parse(time.RFC3339, stime)
if err != nil {
return time.Time{}
return time.Time{}, err
}
return t
}
return t, nil
}
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,16 @@ var (
)

func main() {
buildTime, err := build.Time(BuildTime)
if err != nil {
fmt.Fprintf(os.Stderr, "invalid build time %q: %v\n", BuildTime, err)
os.Exit(1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original silent fallback to time.Time{} was deliberate was deliberate, to make local builds work, e.g. when running go build .. I would not do a hard exit here but instead log a warning and continue with an empty buildTime string.

}

cmd := fleet.NewCommand(build.Info{
Version: Version,
Commit: Commit,
BuildTime: build.Time(BuildTime),
BuildTime: buildTime,
})
if err := cmd.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
Expand Down