Skip to content

Commit

Permalink
Compare protocol with set
Browse files Browse the repository at this point in the history
  • Loading branch information
sawsa307 committed Sep 30, 2024
1 parent 67e0068 commit 87cd54e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/i2gw/providers/gce/extensions/input_extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ import (
"fmt"

"github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw/intermediate"
"k8s.io/apimachinery/pkg/util/sets"
backendconfigv1 "k8s.io/ingress-gce/pkg/apis/backendconfig/v1"
frontendconfigv1beta1 "k8s.io/ingress-gce/pkg/apis/frontendconfig/v1beta1"
)

var supportedHcProtocol = sets.NewString("HTTP", "HTTPS", "HTTP2")

func ValidateBeConfig(beConfig *backendconfigv1.BackendConfig) error {
if beConfig.Spec.SessionAffinity != nil {
if err := validateSessionAffinity(beConfig); err != nil {
Expand All @@ -50,8 +53,9 @@ func validateHealthCheck(beConfig *backendconfigv1.BackendConfig) error {
if hcType == nil {
return fmt.Errorf("HealthCheck Protocol type is not specified")
}
if *hcType != "HTTP" && *hcType != "HTTPS" && *hcType != "HTTP2" {
return fmt.Errorf("Protocol %q is not valid, must be one of [HTTP,HTTPS,HTTP2]", *hcType)

if !supportedHcProtocol.Has(*hcType) {
return fmt.Errorf("Protocol %q is not valid, must be one of %v", *hcType, supportedHcProtocol)
}
return nil
}
Expand Down

0 comments on commit 87cd54e

Please sign in to comment.