Skip to content

Commit

Permalink
feat: support for getting version from array (by index and using filt…
Browse files Browse the repository at this point in the history
…ering)

- $.images[0].newTag
- $.images[?(@.name == "docker.io/demo/rollouts-demo")].newTag
  • Loading branch information
andrii-codefresh committed Sep 29, 2024
1 parent a87492b commit 52f7182
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions reposerver/repository/app_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 52f7182

Please sign in to comment.