JSON

kind: json

sourceconditiontarget

Description

source

The JSON "source" retrieves an information from a JSON file.

condition

The JSON "condition" tests that an information exist in a JSON file.

target

The JSON "target" ensures that a JSON file content a specific value at specific location.

Parameters

NameTypeDescriptionRequired
filestring[s][c][t] File specifies the Json file to manipuate
filesarray[c][t] Files specifies a list of Json file to manipuate
keystring[s][c][t] Key specifies the Jsonpath key to manipuate
querystring[s][c][t] Query allows to used advanced query. Override the parameter key
valuestring[s][c][t] Value specifies the Jsonpath key to manipuate. Default to source output
versionfilterobject[s]VersionFilter provides parameters to specify version pattern and its type like regex, semver, or just latest.
    kindstringSpecifies the version kind such as semver, regex, or latest
    patternstringSpecifies the version pattern according the version kind
    strictbooleanStrict enforce strict versioning rule. Only used for semantic versioning at this time

Xpath

Under construction, some help would be need to document common jsonpath query that work with Updatecli https://www.w3.org/TR/1999/REC-xpath-19991116/

Example

# updatecli.yaml
name: Basic Json Example

scms:
  default:
    kind: git
    spec:
      url: https://github.com/updatecli/updatecli.git

sources:
  local:
    name: Get value from json
    kind: json
    scmid: default
    spec:
      file: pkg/plugins/resources/json/testdata/data.json
      key: firstName
  http:
    name: Get value from json
    kind: json
    spec:
      file: https://www.updatecli.io/schema/latest/config.json
      key: $id

conditions:
  local:
    name: Test value from json
    kind: json
    sourceid: local
    scmid: default
    spec:
      file: pkg/plugins/resources/json/testdata/data.json
      key: firstName
  http:
    name: Test value from json
    kind: json
    disablesourceinput: true
    spec:
      file: https://www.updatecli.io/schema/latest/config.json
      key: $schema
      value: http://json-schema.org/draft-04/schema

targets:
  local:
    name: Test value from json
    kind: json
    sourceid: local
    scmid: default
    spec:
      file: pkg/plugins/resources/json/testdata/data.json
      key: firstName
      value: John

Top