From 4864e6738fbe1ffcf902dfd65a872535eb0c7144 Mon Sep 17 00:00:00 2001 From: Mariano Cano Date: Mon, 1 Jul 2024 12:19:44 -0700 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Herman Slatman --- internal/templates/funcmap.go | 10 ++++++---- internal/templates/funcmap_test.go | 2 +- x509util/certificate.go | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/internal/templates/funcmap.go b/internal/templates/funcmap.go index 5aa1dc27..eebb2c9f 100644 --- a/internal/templates/funcmap.go +++ b/internal/templates/funcmap.go @@ -10,11 +10,13 @@ import ( ) // GetFuncMap returns the list of functions provided by sprig. It adds the -// function "toTime" and changes the function "fail" to set the given string, -// this way we can report template errors directly to the template without -// having the wrapper that text/template adds. +// function "toTime" and changes the function "fail". // -// "toTime" receives a time or a Unix epoch and formats it to RFC3339 in UTC. +// The "toTime" function receives a time or a Unix epoch and formats it to +// RFC3339 in UTC. The "fail" function sets the provided message, so that +// template errors are reported directly to the template without having the +// wrapper that text/template adds. +// // // sprig "env" and "expandenv" functions are removed to avoid the leak of // information. diff --git a/internal/templates/funcmap_test.go b/internal/templates/funcmap_test.go index 8da5f90f..924b306f 100644 --- a/internal/templates/funcmap_test.go +++ b/internal/templates/funcmap_test.go @@ -70,6 +70,6 @@ func TestGetFuncMap_toTime(t *testing.T) { got, err := time.Parse(time.RFC3339, fn(nil)) require.NoError(t, err) assert.WithinDuration(t, want, got, time.Second) - assert.Equal(t, got.Location(), time.UTC) + assert.Equal(t, time.UTC, got.Location()) }) } diff --git a/x509util/certificate.go b/x509util/certificate.go index 4023b266..69eb5378 100644 --- a/x509util/certificate.go +++ b/x509util/certificate.go @@ -168,7 +168,7 @@ func (c *Certificate) GetCertificate() *x509.Certificate { e.Set(cert) } - // Validity bpunds. + // Validity bounds. cert.NotBefore = c.NotBefore cert.NotAfter = c.NotAfter