From 72036183c5e72f43be216283007dd5f6d8b47757 Mon Sep 17 00:00:00 2001 From: shawnh2 Date: Sun, 4 Aug 2024 21:55:50 +0800 Subject: [PATCH] remove file provider part Signed-off-by: shawnh2 --- .../validation/envoygateway_validate.go | 29 ------- .../validation/envoygateway_validate_test.go | 84 +------------------ 2 files changed, 3 insertions(+), 110 deletions(-) diff --git a/api/v1alpha1/validation/envoygateway_validate.go b/api/v1alpha1/validation/envoygateway_validate.go index 3e601971f1a..8d7c97dc94a 100644 --- a/api/v1alpha1/validation/envoygateway_validate.go +++ b/api/v1alpha1/validation/envoygateway_validate.go @@ -35,10 +35,6 @@ func ValidateEnvoyGateway(eg *egv1a1.EnvoyGateway) error { if err := validateEnvoyGatewayKubernetesProvider(eg.Provider.Kubernetes); err != nil { return err } - case egv1a1.ProviderTypeFile: - if err := validateEnvoyGatewayFileProvider(eg.Provider.Custom); err != nil { - return err - } default: return fmt.Errorf("unsupported provider type") } @@ -83,31 +79,6 @@ func validateEnvoyGatewayKubernetesProvider(provider *egv1a1.EnvoyGatewayKuberne return nil } -func validateEnvoyGatewayFileProvider(provider *egv1a1.EnvoyGatewayCustomProvider) error { - if provider == nil { - return fmt.Errorf("empty custom provider settings for file provider") - } - - rType, iType := provider.Resource.Type, provider.Infrastructure.Type - if rType != egv1a1.ResourceProviderTypeFile || iType != egv1a1.InfrastructureProviderTypeHost { - return fmt.Errorf("file provider only supports 'File' resource type and 'Host' infra type") - } - - if provider.Resource.File == nil { - return fmt.Errorf("field 'file' should be specified when resource type is 'File'") - } - - if len(provider.Resource.File.Paths) == 0 { - return fmt.Errorf("no paths were assigned for file resource provider to watch") - } - - if provider.Infrastructure.Host == nil { - return fmt.Errorf("field 'host' should be specified when infrastructure type is 'Host'") - } - - return nil -} - func validateEnvoyGatewayLogging(logging *egv1a1.EnvoyGatewayLogging) error { if logging == nil || len(logging.Level) == 0 { return nil diff --git a/api/v1alpha1/validation/envoygateway_validate_test.go b/api/v1alpha1/validation/envoygateway_validate_test.go index 8add1156fa3..004a5ac8298 100644 --- a/api/v1alpha1/validation/envoygateway_validate_test.go +++ b/api/v1alpha1/validation/envoygateway_validate_test.go @@ -68,89 +68,11 @@ func TestValidateEnvoyGateway(t *testing.T) { expect: false, }, { - name: "supported file provider", + name: "unsupported provider", eg: &egv1a1.EnvoyGateway{ EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ - Gateway: egv1a1.DefaultGateway(), - Provider: &egv1a1.EnvoyGatewayProvider{ - Type: egv1a1.ProviderTypeFile, - Custom: &egv1a1.EnvoyGatewayCustomProvider{ - Resource: egv1a1.EnvoyGatewayResourceProvider{ - Type: egv1a1.ResourceProviderTypeFile, - File: &egv1a1.EnvoyGatewayFileResourceProvider{ - Paths: []string{"foo", "bar"}, - }, - }, - Infrastructure: egv1a1.EnvoyGatewayInfrastructureProvider{ - Type: egv1a1.InfrastructureProviderTypeHost, - Host: &egv1a1.EnvoyGatewayHostInfrastructureProvider{}, - }, - }, - }, - }, - }, - expect: true, - }, - { - name: "file provider without file resource", - eg: &egv1a1.EnvoyGateway{ - EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ - Gateway: egv1a1.DefaultGateway(), - Provider: &egv1a1.EnvoyGatewayProvider{ - Type: egv1a1.ProviderTypeFile, - Custom: &egv1a1.EnvoyGatewayCustomProvider{ - Resource: egv1a1.EnvoyGatewayResourceProvider{ - Type: egv1a1.ResourceProviderTypeFile, - }, - Infrastructure: egv1a1.EnvoyGatewayInfrastructureProvider{ - Type: egv1a1.InfrastructureProviderTypeHost, - Host: &egv1a1.EnvoyGatewayHostInfrastructureProvider{}, - }, - }, - }, - }, - }, - expect: false, - }, - { - name: "file provider without host infrastructure", - eg: &egv1a1.EnvoyGateway{ - EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ - Gateway: egv1a1.DefaultGateway(), - Provider: &egv1a1.EnvoyGatewayProvider{ - Type: egv1a1.ProviderTypeFile, - Custom: &egv1a1.EnvoyGatewayCustomProvider{ - Resource: egv1a1.EnvoyGatewayResourceProvider{ - Type: egv1a1.ResourceProviderTypeFile, - File: &egv1a1.EnvoyGatewayFileResourceProvider{}, - }, - Infrastructure: egv1a1.EnvoyGatewayInfrastructureProvider{ - Type: egv1a1.InfrastructureProviderTypeHost, - }, - }, - }, - }, - }, - expect: false, - }, - { - name: "file provider without any paths assigning in resource", - eg: &egv1a1.EnvoyGateway{ - EnvoyGatewaySpec: egv1a1.EnvoyGatewaySpec{ - Gateway: egv1a1.DefaultGateway(), - Provider: &egv1a1.EnvoyGatewayProvider{ - Type: egv1a1.ProviderTypeFile, - Custom: &egv1a1.EnvoyGatewayCustomProvider{ - Resource: egv1a1.EnvoyGatewayResourceProvider{ - Type: egv1a1.ResourceProviderTypeFile, - File: &egv1a1.EnvoyGatewayFileResourceProvider{}, - }, - Infrastructure: egv1a1.EnvoyGatewayInfrastructureProvider{ - Type: egv1a1.InfrastructureProviderTypeHost, - Host: &egv1a1.EnvoyGatewayHostInfrastructureProvider{}, - }, - }, - }, + Gateway: egv1a1.DefaultGateway(), + Provider: &egv1a1.EnvoyGatewayProvider{Type: egv1a1.ProviderTypeFile}, }, }, expect: false,