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 manipulate
filesarray[c][t] Files specifies a list of Json file to manipulate
keystring[s][c][t] Key specifies the Jsonpath key to manipulate
querystring[s][c][t] Query allows to used advanced query. Override the parameter key
valuestring[s][c][t] Value specifies the Jsonpath key to manipulate. 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

Query

The JSON plugin relies on Dasel to query json files

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