forked from TrueCloudLab/certificates
Rename UserData to TemplateData and fix unmarshaling.
This commit is contained in:
parent
9f3acc254b
commit
95c3a41bf0
2 changed files with 4 additions and 4 deletions
|
@ -36,7 +36,7 @@ func TemplateOptions(o *ProvisionerOptions, data x509util.TemplateData) (Certifi
|
||||||
|
|
||||||
// Add template data if any.
|
// Add template data if any.
|
||||||
if len(o.TemplateData) > 0 {
|
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")
|
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.
|
// Add user provided data.
|
||||||
if len(so.UserData) > 0 {
|
if len(so.TemplateData) > 0 {
|
||||||
userObject := make(map[string]interface{})
|
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{}{}
|
data[x509util.UserKey] = map[string]interface{}{}
|
||||||
} else {
|
} else {
|
||||||
data[x509util.UserKey] = userObject
|
data[x509util.UserKey] = userObject
|
||||||
|
|
|
@ -22,7 +22,7 @@ import (
|
||||||
type Options struct {
|
type Options struct {
|
||||||
NotAfter TimeDuration `json:"notAfter"`
|
NotAfter TimeDuration `json:"notAfter"`
|
||||||
NotBefore TimeDuration `json:"notBefore"`
|
NotBefore TimeDuration `json:"notBefore"`
|
||||||
UserData json.RawMessage `json:"data"`
|
TemplateData json.RawMessage `json:"templateData"`
|
||||||
Backdate time.Duration `json:"-"`
|
Backdate time.Duration `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue