31 lines
1.0 KiB
Go
31 lines
1.0 KiB
Go
package admission
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
// admissionTestLogWriter is implemented by repository.Repository
|
|
type admissionTestLogWriter interface {
|
|
AppendAdmissionTestLog(ctx context.Context, candidateID string, status string, failureCode string, failureSummary string, testedAt time.Time) error
|
|
}
|
|
|
|
// testLoggerAdapter implements TestLogger by delegating to a repository.
|
|
type testLoggerAdapter struct {
|
|
writer admissionTestLogWriter
|
|
}
|
|
|
|
// NewTestLoggerAdapter creates a TestLogger that writes to the given repository.
|
|
func NewTestLoggerAdapter(writer admissionTestLogWriter) TestLogger {
|
|
return &testLoggerAdapter{writer: writer}
|
|
}
|
|
|
|
// AppendAdmissionTestLog implements TestLogger.
|
|
func (a *testLoggerAdapter) AppendAdmissionTestLog(ctx context.Context, candidateID, status, failureCode, failureSummary, testedAt string) error {
|
|
t, err := time.Parse(time.RFC3339, testedAt)
|
|
if err != nil {
|
|
t = time.Now().UTC()
|
|
}
|
|
return a.writer.AppendAdmissionTestLog(ctx, candidateID, status, failureCode, failureSummary, t)
|
|
}
|