Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions pkg/splunk/enterprise/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
13 changes: 13 additions & 0 deletions pkg/splunk/enterprise/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down