diff --git a/pkg/splunk/enterprise/util.go b/pkg/splunk/enterprise/util.go index 8a98882ff..6733e4352 100644 --- a/pkg/splunk/enterprise/util.go +++ b/pkg/splunk/enterprise/util.go @@ -1185,22 +1185,15 @@ func handleAppRepoChanges(ctx context.Context, client splcommon.ControllerClient } // isAppExtentionValid checks if an app extention is supported or not -func isAppExtentionValid(receivedKey string) bool { - appExtIdx := strings.LastIndex(receivedKey, ".") - if appExtIdx < 0 { - return false - } - - switch appExt := receivedKey[appExtIdx+1:]; appExt { - case "spl": - return true - - case "tgz": - return true +func isAppExtensionValid(receivedKey string) bool { + validExtensions := []string{".spl", ".tgz", ".tar.gz"} - default: - return false + for _, ext := range validExtensions { + if strings.HasSuffix(receivedKey, ext) { + return true + } } + return false } // AddOrUpdateAppSrcDeploymentInfoList modifies the App deployment status as perceived from the remote object listing @@ -1216,7 +1209,7 @@ func AddOrUpdateAppSrcDeploymentInfoList(ctx context.Context, appSrcDeploymentIn for _, remoteObj := range remoteS3ObjList { receivedKey := *remoteObj.Key - if !isAppExtentionValid(receivedKey) { + if !isAppExtensionValid(receivedKey) { scopedLog.Error(nil, "App name Parsing: Ignoring the key with invalid extension", "receivedKey", receivedKey) continue } diff --git a/pkg/splunk/enterprise/util_test.go b/pkg/splunk/enterprise/util_test.go index 1d7ed4d10..2a3f5d1d6 100644 --- a/pkg/splunk/enterprise/util_test.go +++ b/pkg/splunk/enterprise/util_test.go @@ -1175,12 +1175,12 @@ func TestGetAvailableDiskSpaceShouldFail(t *testing.T) { } } -func TestIsAppExtentionValid(t *testing.T) { - if !isAppExtentionValid("testapp.spl") || !isAppExtentionValid("testapp.tgz") { +func TestIsAppExtensionValid(t *testing.T) { + if !isAppExtensionValid("testapp.spl") || !isAppExtensionValid("testapp.tgz") || !isAppExtensionValid("testapp.tar.gz") { t.Errorf("failed to detect valid app extension") } - if isAppExtentionValid("testapp.aspl") || isAppExtentionValid("testapp.ttgz") { + if isAppExtensionValid("testapp.aspl") || isAppExtensionValid("testapp.ttgz") { t.Errorf("failed to detect invalid app extension") } }