Rename UserData to TemplateData and fix unmarshaling.

This commit is contained in:
Mariano Cano 2020-07-08 15:54:25 -07:00
parent 9f3acc254b
commit 95c3a41bf0
2 changed files with 4 additions and 4 deletions

View file

@ -36,7 +36,7 @@ func TemplateOptions(o *ProvisionerOptions, data x509util.TemplateData) (Certifi
// Add template data if any.
if len(o.TemplateData) > 0 {
if err := json.Unmarshal(o.TemplateData, data); err != nil {
if err := json.Unmarshal(o.TemplateData, &data); err != nil {
return nil, errors.Wrap(err, "error unmarshaling template data")
}
}
@ -52,9 +52,9 @@ func TemplateOptions(o *ProvisionerOptions, data x509util.TemplateData) (Certifi
}
// Add user provided data.
if len(so.UserData) > 0 {
if len(so.TemplateData) > 0 {
userObject := make(map[string]interface{})
if err := json.Unmarshal(so.UserData, userObject); err != nil {
if err := json.Unmarshal(so.TemplateData, &userObject); err != nil {
data[x509util.UserKey] = map[string]interface{}{}
} else {
data[x509util.UserKey] = userObject

View file

@ -22,7 +22,7 @@ import (
type Options struct {
NotAfter TimeDuration `json:"notAfter"`
NotBefore TimeDuration `json:"notBefore"`
UserData json.RawMessage `json:"data"`
TemplateData json.RawMessage `json:"templateData"`
Backdate time.Duration `json:"-"`
}