Implement our own CustomFieldType
Signed-off-by: Maartje Eyskens <maartje@eyskens.me>
This commit is contained in:
parent
1ebc9ef56b
commit
b3c4dd2ba8
@ -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"`
|
||||
}
|
||||
|
||||
@ -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,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user