Skip to content

Ability to compare CS engine versions #170

@vlobzakov

Description

@vlobzakov

Ticket: https://jelastic.team/browse/JE-43816
Ниже предложение по размещению и наполнению обновления.

Обновление добавляется после подраздела:
Default Values of Placeholders (http://docs.cloudscripting.com/creating-manifest/placeholders/#default-values-of-placeholders)
####################Начало обновления###############

Engine Placeholder

The ${engine} placeholder returns a Cloud Scripting engine version that is supported by the platform the manifest is executed on.

  • ${engine} - CS engine version

It can be complemented with function placeholders ${fn.compareEngine(version)} and ${fn.compare(version1, version2)} that can be used to determine whether JPS manifest is supported by the platform’s engine version or not.

@@@

type: install
name: JE-43816 Ability co compare CS engine versions

onInstall:
- assert:
  - "'${engine}'.split('.').length > 0"
  - "'${fn.compare}' == 0"
  - "'${fn.compare(5.4.1, 5.4.2)}' == -1"
  - "'${fn.compare(5.5, 5.4.2)}' == 1"
  - "'${fn.compare(5.4.0, 5.4.0.0)}' == 0"
  - "'${fn.compareEngine}' == 0"
  - "'${fn.compareEngine(1.5.1)}' == 1"
  - "'${fn.compareEngine(1000000)}' == -1"
{
  "type": "install",
  "name": "JE-43816 Ability co compare CS engine versions",
  "onInstall": [
    {
      "assert": [
        "'${engine}'.split('.').length > 0",
        "'${fn.compare}' == 0",
        "'${fn.compare(5.4.1, 5.4.2)}' == -1",
        "'${fn.compare(5.5, 5.4.2)}' == 1",
        "'${fn.compare(5.4.0, 5.4.0.0)}' == 0",
        "'${fn.compareEngine}' == 0",
        "'${fn.compareEngine(1.5.1)}' == 1",
        "'${fn.compareEngine(1000000)}' == -1"
      ]
    }
  ]
}

@@!
###################конец обновления################

В разделе https://docs.cloudscripting.com/creating-manifest/placeholders/#function-placeholders
После
The function parameter can be passed from existing placeholders, for example:
${fn.md5([fn.random])} - md5 encoding random password
${fn.base64([user.email])} - base64 encoding user email address

Вставляем

####################Начало обновления###############

  • ${fn.compareEngine(version)} - compares, supported by the hoster platform, CS engine version with the given version. Returns result:
    0 - version equals CS engine version
    1 - CS engine version greater than version
    -1 - CS engine version less than version

  • ${fn.compare(version1, version2)} - compares two given versions separated by dots. Returns result:
    0 - version1 equals version2
    1 - version1 greater than version2
    -1 - version1 less than version2

###################конец обновления################

Может есть смысл еще такой пример дать:

@@@

type: update
name: CS Engine compatibility test1
onInstall:
   - if (${fn.compareEngine(1.6)} > 0):
      cmd[cp]:
        echo "Engine ${engine} is supported" >> /tmp/engine.txt
      user: root
{
  "type": "update",
  "name": "CS Engine compatibility test",
  "onInstall": [
    {
      "if (${fn.compareEngine(1.6)} > 0)": {
        "cmd[cp]": "echo \"Engine ${engine} is supported\" >> /tmp/engine.txt",
        "user": "root"
      }
    }
  ]
}

@@!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions