diff --git a/pkg/splunk/enterprise/configuration.go b/pkg/splunk/enterprise/configuration.go index a8da20539..757dbcbaf 100644 --- a/pkg/splunk/enterprise/configuration.go +++ b/pkg/splunk/enterprise/configuration.go @@ -1039,17 +1039,28 @@ func validateRemoteVolumeSpec(volList []enterpriseApi.VolumeSpec, isAppFramework // provider is used in App framework to pick the S3 client(aws, minio), and is not applicable to Smartstore // For now, Smartstore supports only S3, which is by default. if isAppFramework { - if volume.Type == "" { - return fmt.Errorf("Remote volume Type is missing") + if !isValidStorageType(volume.Type) { + return fmt.Errorf("Remote volume type is invalid. Only storageType=s3 is supported") } - if volume.Provider == "" { - return fmt.Errorf("S3 Provider is missing") + + if !isValidProvider(volume.Provider) { + return fmt.Errorf("S3 Provider is invalid") } } } return nil } +// isValidStorageType checks if the storage type specified is valid and supported +func isValidStorageType(storage string) bool { + return storage != "" && storage == "s3" +} + +// isValidProvider checks if the provider specified is valid and supported +func isValidProvider(provider string) bool { + return provider != "" && (provider == "aws" || provider == "minio") +} + // validateSplunkIndexesSpec validates the smartstore index spec func validateSplunkIndexesSpec(smartstore *enterpriseApi.SmartStoreSpec) error { diff --git a/pkg/splunk/enterprise/configuration_test.go b/pkg/splunk/enterprise/configuration_test.go index 5c7cba652..97de5e545 100644 --- a/pkg/splunk/enterprise/configuration_test.go +++ b/pkg/splunk/enterprise/configuration_test.go @@ -846,6 +846,19 @@ func TestValidateAppFrameworkSpec(t *testing.T) { if err == nil { t.Errorf("Configuring Defaults with invalid volume name should return an error, but failed to detect") } + + // Invalid remote volume type should return error. + AppFramework.VolList[0].Type = "s4" + err = ValidateAppFrameworkSpec(&AppFramework, &appFrameworkContext, false) + if err == nil { + t.Errorf("ValidateAppFrameworkSpec with invalid remote volume type should have returned error.") + } + + AppFramework.VolList[0].Provider = "invalid-provider" + err = ValidateAppFrameworkSpec(&AppFramework, &appFrameworkContext, false) + if err == nil { + t.Errorf("ValidateAppFrameworkSpec with invalid provider should have returned error.") + } } func TestGetSmartstoreIndexesConfig(t *testing.T) {