Change label description for HTTP-01 Gateway API solver and fix tests

Signed-off-by: Jake Sanders <i@am.so-aweso.me>
This commit is contained in:
Jake Sanders 2022-03-30 12:52:34 +01:00
parent 4b3af946db
commit b72db63761
No known key found for this signature in database
GPG Key ID: 7E708D7933B84690
10 changed files with 33 additions and 37 deletions

View File

@ -375,7 +375,7 @@ spec:
type: object
properties:
labels:
description: Custom labels that you want the HTTPRoutes created by cert-manager for solving HTTP-01 challenges. Back when cert-manager supported v1alpha1, this field was used when creating the solver's HTTPRoute, and used to be how the HTTPRoute was matched to a Gateway. Since v1alpha2, the HTTPRoute is matched to a Gateway using the field parentRefs on the HTTPRoute.
description: Custom labels that will be applied to HTTPRoutes created by cert-manager while solving HTTP-01 challenges.
type: object
additionalProperties:
type: string

View File

@ -410,7 +410,7 @@ spec:
type: object
properties:
labels:
description: Custom labels that you want the HTTPRoutes created by cert-manager for solving HTTP-01 challenges. Back when cert-manager supported v1alpha1, this field was used when creating the solver's HTTPRoute, and used to be how the HTTPRoute was matched to a Gateway. Since v1alpha2, the HTTPRoute is matched to a Gateway using the field parentRefs on the HTTPRoute.
description: Custom labels that will be applied to HTTPRoutes created by cert-manager while solving HTTP-01 challenges.
type: object
additionalProperties:
type: string

View File

@ -412,7 +412,7 @@ spec:
type: object
properties:
labels:
description: Custom labels that you want the HTTPRoutes created by cert-manager for solving HTTP-01 challenges. Back when cert-manager supported v1alpha1, this field was used when creating the solver's HTTPRoute, and used to be how the HTTPRoute was matched to a Gateway. Since v1alpha2, the HTTPRoute is matched to a Gateway using the field parentRefs on the HTTPRoute.
description: Custom labels that will be applied to HTTPRoutes created by cert-manager while solving HTTP-01 challenges.
type: object
additionalProperties:
type: string

View File

@ -229,12 +229,9 @@ type ACMEChallengeSolverHTTP01GatewayHTTPRoute struct {
// +optional
ServiceType corev1.ServiceType
// Custom labels that you want the HTTPRoutes created by cert-manager
// for solving HTTP-01 challenges. Back when cert-manager supported
// v1alpha1, this field was used when creating the solver's HTTPRoute,
// and used to be how the HTTPRoute was matched to a Gateway. Since
// v1alpha2, the HTTPRoute is matched to a Gateway using the field
// parentRefs on the HTTPRoute.
// Custom labels that will be applied to HTTPRoutes created by cert-manager
// while solving HTTP-01 challenges.
// +optional
Labels map[string]string
// When solving an HTTP-01 challenge, cert-manager creates an HTTPRoute.

View File

@ -252,12 +252,9 @@ type ACMEChallengeSolverHTTP01GatewayHTTPRoute struct {
// +optional
ServiceType corev1.ServiceType `json:"serviceType,omitempty"`
// Custom labels that you want the HTTPRoutes created by cert-manager
// for solving HTTP-01 challenges. Back when cert-manager supported
// v1alpha1, this field was used when creating the solver's HTTPRoute,
// and used to be how the HTTPRoute was matched to a Gateway. Since
// v1alpha2, the HTTPRoute is matched to a Gateway using the field
// parentRefs on the HTTPRoute.
// Custom labels that will be applied to HTTPRoutes created by cert-manager
// while solving HTTP-01 challenges.
// +optional
Labels map[string]string
// When solving an HTTP-01 challenge, cert-manager creates an HTTPRoute.

View File

@ -252,12 +252,9 @@ type ACMEChallengeSolverHTTP01GatewayHTTPRoute struct {
// +optional
ServiceType corev1.ServiceType `json:"serviceType,omitempty"`
// Custom labels that you want the HTTPRoutes created by cert-manager
// for solving HTTP-01 challenges. Back when cert-manager supported
// v1alpha1, this field was used when creating the solver's HTTPRoute,
// and used to be how the HTTPRoute was matched to a Gateway. Since
// v1alpha2, the HTTPRoute is matched to a Gateway using the field
// parentRefs on the HTTPRoute.
// Custom labels that will be applied to HTTPRoutes created by cert-manager
// while solving HTTP-01 challenges.
// +optional
Labels map[string]string
// When solving an HTTP-01 challenge, cert-manager creates an HTTPRoute.

View File

@ -251,12 +251,9 @@ type ACMEChallengeSolverHTTP01GatewayHTTPRoute struct {
// +optional
ServiceType corev1.ServiceType `json:"serviceType,omitempty"`
// Custom labels that you want the HTTPRoutes created by cert-manager
// for solving HTTP-01 challenges. Back when cert-manager supported
// v1alpha1, this field was used when creating the solver's HTTPRoute,
// and used to be how the HTTPRoute was matched to a Gateway. Since
// v1alpha2, the HTTPRoute is matched to a Gateway using the field
// parentRefs on the HTTPRoute.
// Custom labels that will be applied to HTTPRoutes created by cert-manager
// while solving HTTP-01 challenges.
// +optional
Labels map[string]string `json:"labels,omitempty"`
// When solving an HTTP-01 challenge, cert-manager creates an HTTPRoute.

View File

@ -201,6 +201,9 @@ func ValidateACMEIssuerChallengeSolverHTTP01GatewayConfig(gateway *cmacme.ACMECh
default:
el = append(el, field.Invalid(fldPath.Child("serviceType"), gateway.ServiceType, `must be empty, "ClusterIP" or "NodePort"`))
}
if len(gateway.ParentRefs) == 0 {
el = append(el, field.Required(fldPath.Child("parentRefs"), `at least 1 parentRef is required`))
}
return el
}

View File

@ -18,6 +18,7 @@ package validation
import (
"reflect"
gwapi "sigs.k8s.io/gateway-api/apis/v1alpha2"
"testing"
"github.com/stretchr/testify/assert"
@ -244,8 +245,10 @@ func TestValidateACMEIssuerConfig(t *testing.T) {
{
HTTP01: &cmacme.ACMEChallengeSolverHTTP01{
GatewayHTTPRoute: &cmacme.ACMEChallengeSolverHTTP01GatewayHTTPRoute{
Labels: map[string]string{
"key": "value",
ParentRefs: []gwapi.ParentRef{
{
Name: "blah",
},
},
},
},
@ -268,8 +271,8 @@ func TestValidateACMEIssuerConfig(t *testing.T) {
},
errs: []*field.Error{
field.Required(
fldPath.Child("solvers").Index(0).Child("http01", "gateway").Child("labels"),
"labels must be set",
fldPath.Child("solvers").Index(0).Child("http01", "gateway").Child("parentRefs"),
"at least 1 parentRef is required",
),
},
},
@ -286,6 +289,11 @@ func TestValidateACMEIssuerConfig(t *testing.T) {
Labels: map[string]string{
"a": "b",
},
ParentRefs: []gwapi.ParentRef{
{
Name: "blah",
},
},
},
},
},

View File

@ -255,12 +255,9 @@ type ACMEChallengeSolverHTTP01GatewayHTTPRoute struct {
// +optional
ServiceType corev1.ServiceType `json:"serviceType,omitempty"`
// Custom labels that you want the HTTPRoutes created by cert-manager
// for solving HTTP-01 challenges. Back when cert-manager supported
// v1alpha1, this field was used when creating the solver's HTTPRoute,
// and used to be how the HTTPRoute was matched to a Gateway. Since
// v1alpha2, the HTTPRoute is matched to a Gateway using the field
// parentRefs on the HTTPRoute.
// Custom labels that will be applied to HTTPRoutes created by cert-manager
// while solving HTTP-01 challenges.
// +optional
Labels map[string]string `json:"labels,omitempty"`
// When solving an HTTP-01 challenge, cert-manager creates an HTTPRoute.