From b3c4dd2ba85c457ccb98280b4d860d2a1fff108e Mon Sep 17 00:00:00 2001 From: Maartje Eyskens Date: Wed, 12 Feb 2020 10:41:19 +0100 Subject: [PATCH] Implement our own `CustomFieldType` Signed-off-by: Maartje Eyskens --- pkg/internal/venafi/api/api.go | 12 +++++++----- pkg/internal/venafi/sign.go | 15 ++++++++++++++- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/pkg/internal/venafi/api/api.go b/pkg/internal/venafi/api/api.go index cc574494f..e2e44c661 100644 --- a/pkg/internal/venafi/api/api.go +++ b/pkg/internal/venafi/api/api.go @@ -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"` } diff --git a/pkg/internal/venafi/sign.go b/pkg/internal/venafi/sign.go index abd19b1a8..dd8152825 100644 --- a/pkg/internal/venafi/sign.go +++ b/pkg/internal/venafi/sign.go @@ -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, + }) } }