From 3c84453cf4a12b42c427bfb900256e12b5b63803 Mon Sep 17 00:00:00 2001 From: Mariano Cano Date: Thu, 9 Jul 2020 15:17:32 -0700 Subject: [PATCH] Move CreateTemplateData. --- x509util/templates.go | 15 +++++++++++++++ x509util/utils.go | 9 --------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/x509util/templates.go b/x509util/templates.go index 0467229e..f3e2bcd7 100644 --- a/x509util/templates.go +++ b/x509util/templates.go @@ -14,6 +14,21 @@ const ( // passed to the templates. type TemplateData map[string]interface{} +// NewTemplateData creates a new map for templates data. +func NewTemplateData() TemplateData { + return TemplateData{} +} + +// CreateTemplateData creates a new TemplateData with the given common name and SANs. +func CreateTemplateData(commonName string, sans []string) TemplateData { + return TemplateData{ + SubjectKey: Subject{ + CommonName: commonName, + }, + SANsKey: CreateSANs(sans), + } +} + func (t TemplateData) Set(key string, v interface{}) { t[key] = v } diff --git a/x509util/utils.go b/x509util/utils.go index 6268107e..110d2644 100644 --- a/x509util/utils.go +++ b/x509util/utils.go @@ -38,15 +38,6 @@ func CreateSANs(sans []string) []SubjectAlternativeName { return sanTypes } -func CreateTemplateData(commonName string, sans []string) TemplateData { - return TemplateData{ - SubjectKey: Subject{ - CommonName: commonName, - }, - SANsKey: CreateSANs(sans), - } -} - // generateSerialNumber returns a random serial number. func generateSerialNumber() (*big.Int, error) { limit := new(big.Int).Lsh(big.NewInt(1), 128)