Merge pull request #52028 from vvoland/remove-clock

Remove direct dependency on code.cloudfoundry.org/clock
This commit is contained in:
Sebastiaan van Stijn
2026-02-11 12:31:28 +01:00
committed by GitHub
2 changed files with 9 additions and 6 deletions

View File

@@ -19,7 +19,6 @@ import (
"testing"
"time"
"code.cloudfoundry.org/clock"
"github.com/coreos/go-systemd/v22/journal"
"github.com/google/uuid"
"github.com/moby/moby/v2/daemon/internal/lazyregexp"
@@ -60,8 +59,9 @@ type Sender struct {
CmdName string
OutputPath string
// Clock for timestamping sent messages.
Clock clock.Clock
// Now returns the current time for timestamping sent messages.
// Defaults to time.Now if nil.
Now func() time.Time
// Whether to assign the event's realtime timestamp to the time
// specified by the SYSLOG_TIMESTAMP variable value. This is roughly
// analogous to journald receiving the event and assigning it a
@@ -90,7 +90,6 @@ func New(outpath string) (*Sender, error) {
sender := &Sender{
CmdName: p,
OutputPath: outpath,
Clock: clock.NewClock(),
BootID: uuid.New(), // UUIDv4, like systemd itself generates for sd_id128 values.
}
return sender, nil
@@ -130,7 +129,11 @@ func (s *Sender) Send(message string, priority journal.Priority, vars map[string
return fmt.Errorf("fake: error parsing SYSLOG_TIMESTAMP value %q: %w", ts, err)
}
} else {
ts = s.Clock.Now()
now := s.Now
if now == nil {
now = time.Now
}
ts = now()
}
if err := export.WriteField(&buf, "__REALTIME_TIMESTAMP", strconv.FormatInt(ts.UnixMicro(), 10)); err != nil {
return fmt.Errorf("fake: error writing entry to systemd-journal-remote: %w", err)

2
go.mod
View File

@@ -5,7 +5,6 @@ go 1.25.5
require (
cloud.google.com/go/compute/metadata v0.9.0
cloud.google.com/go/logging v1.13.1
code.cloudfoundry.org/clock v1.60.0
dario.cat/mergo v1.0.2
github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c
@@ -126,6 +125,7 @@ require (
cloud.google.com/go/auth v0.18.0 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect
cloud.google.com/go/longrunning v0.7.0 // indirect
code.cloudfoundry.org/clock v1.60.0 // indirect
cyphar.com/go-pathrs v0.2.1 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.20.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 // indirect