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

Add support validities in templates #534

Merged
merged 6 commits into from
Jul 1, 2024
Merged

Add support validities in templates #534

merged 6 commits into from
Jul 1, 2024

Conversation

maraino
Copy link
Contributor

@maraino maraino commented Jun 28, 2024

Description

This commit allows setting the validity bounds on X.509 and SSH certificates using templates.

It also adds the template method toTime, which makes it easier to format a timestamp to RFC3339. This format is compatible with Go's time.Time when json.Unmarshal is used. There are similar methods to do this in the sprig library, but they require you to specify the format string. For example, these methods will return a valid string that can be unmarshaled to time.Time:

{{ date "2006-01-02T15:04:05Z07:00" .Token.nbf | toJson }}
{{ dateInZone "2006-01-02T15:04:05Z07:00" .Token.nbf "UTC" | toJson }}
{{ toTime .Token.nbf | toJson }}

This commit allows setting the validity bounds on X.509 and SSH
certificates using templates.
toTime formats a time or a Unix epoch to RFC3339, the format used to
unmarshal a string to a time.Time.
@maraino maraino changed the title Add support for use templates in validities Add support validities in templates Jun 28, 2024
Copy link
Member

@hslatman hslatman left a comment

Choose a reason for hiding this comment

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

Minor doc issues

internal/templates/funcmap.go Outdated Show resolved Hide resolved
internal/templates/funcmap_test.go Outdated Show resolved Hide resolved
x509util/certificate.go Outdated Show resolved Hide resolved
Co-authored-by: Herman Slatman <hslatman@users.noreply.github.com>
@maraino maraino requested a review from hslatman July 1, 2024 19:20
hslatman
hslatman previously approved these changes Jul 1, 2024
@hslatman
Copy link
Member

hslatman commented Jul 1, 2024

That lint issue is my bad with the GH editor

@maraino maraino merged commit c11e706 into master Jul 1, 2024
11 checks passed
@maraino maraino deleted the mariano/validity branch July 1, 2024 19:46
@maraino maraino mentioned this pull request Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants