Skip to content

Commit 2e5cd99

Browse files
authored
Merge pull request #1452 from splunk/CSPL-3426
CSPL-3426: Support tar.gz extension for apps
2 parents 5862586 + 7050554 commit 2e5cd99

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

pkg/splunk/enterprise/util.go

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,21 +1243,14 @@ func handleAppRepoChanges(ctx context.Context, client splcommon.ControllerClient
12431243

12441244
// isAppExtentionValid checks if an app extention is supported or not
12451245
func isAppExtentionValid(receivedKey string) bool {
1246-
appExtIdx := strings.LastIndex(receivedKey, ".")
1247-
if appExtIdx < 0 {
1248-
return false
1249-
}
1250-
1251-
switch appExt := receivedKey[appExtIdx+1:]; appExt {
1252-
case "spl":
1253-
return true
1254-
1255-
case "tgz":
1256-
return true
1246+
validExtensions := []string{".spl", ".tgz", ".tar.gz"}
12571247

1258-
default:
1259-
return false
1248+
for _, ext := range validExtensions {
1249+
if strings.HasSuffix(receivedKey, ext) {
1250+
return true
1251+
}
12601252
}
1253+
return false
12611254
}
12621255

12631256
// AddOrUpdateAppSrcDeploymentInfoList modifies the App deployment status as perceived from the remote object listing

pkg/splunk/enterprise/util_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,7 @@ func TestGetAvailableDiskSpaceShouldFail(t *testing.T) {
12141214
}
12151215

12161216
func TestIsAppExtentionValid(t *testing.T) {
1217-
if !isAppExtentionValid("testapp.spl") || !isAppExtentionValid("testapp.tgz") {
1217+
if !isAppExtentionValid("testapp.spl") || !isAppExtentionValid("testapp.tgz") || !isAppExtentionValid("testapp.tar.gz") {
12181218
t.Errorf("failed to detect valid app extension")
12191219
}
12201220

0 commit comments

Comments
 (0)