Implement our own CustomFieldType

Signed-off-by: Maartje Eyskens <maartje@eyskens.me>
This commit is contained in:
Maartje Eyskens 2020-02-12 10:41:19 +01:00
parent 1ebc9ef56b
commit b3c4dd2ba8
2 changed files with 21 additions and 6 deletions

View File

@ -16,13 +16,15 @@ limitations under the License.
package api
import (
"github.com/Venafi/vcert/pkg/certificate"
type CustomFieldType string
const (
CustomFieldTypePlain CustomFieldType = "Plain"
)
// CustomField defines a custom field to be passed to Venafi
type CustomField struct {
Type certificate.CustomFieldType `json:"type,omitempty"`
Name string `json:"name"`
Value string `json:"value"`
Type CustomFieldType `json:"type,omitempty"`
Name string `json:"name"`
Value string `json:"value"`
}

View File

@ -52,7 +52,20 @@ func (v *Venafi) Sign(csrPEM []byte, duration time.Duration, customFields []inte
if len(customFields) > 0 {
vreq.CustomFields = []certificate.CustomField{}
for _, field := range customFields {
vreq.CustomFields = append(vreq.CustomFields, certificate.CustomField(field))
var fieldType certificate.CustomFieldType
switch field.Type {
case internalvanafiapi.CustomFieldTypePlain:
fieldType = certificate.CustomFieldPlain
break
default:
fieldType = certificate.CustomFieldPlain
}
vreq.CustomFields = append(vreq.CustomFields, certificate.CustomField{
Type: fieldType,
Name: field.Name,
Value: field.Value,
})
}
}