Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSPL-3426 Add tar.gz to App file extenstion filter #1437

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
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
23 changes: 8 additions & 15 deletions pkg/splunk/enterprise/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/splunk/enterprise/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
Expand Down
Loading