From 52f7182e8f1d34c94542a78760e4bab00156f305 Mon Sep 17 00:00:00 2001 From: andrii-codefresh Date: Sun, 29 Sep 2024 22:48:28 +0300 Subject: [PATCH] feat: support for getting version from array (by index and using filtering) - $.images[0].newTag - $.images[?(@.name == "docker.io/demo/rollouts-demo")].newTag --- reposerver/repository/app_version.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/reposerver/repository/app_version.go b/reposerver/repository/app_version.go index ad29f74b17a8e..eddbe509a3889 100644 --- a/reposerver/repository/app_version.go +++ b/reposerver/repository/app_version.go @@ -61,8 +61,16 @@ func getVersionFromFile(appPath, jsonPathExpression string) (*string, error) { if err != nil { return nil, err } - appVersion, ok := versionValue.(string) - if !ok { + + var appVersion string + var conversionSuccess bool + if versionArray, ok := versionValue.([]interface{}); ok && len(versionArray) > 0 { + appVersion, conversionSuccess = versionArray[0].(string) + } else { + appVersion, conversionSuccess = versionValue.(string) + } + + if !conversionSuccess { if versionValue == nil { log.Info("Version value is not a string. Got: nil") } else {