Commit 4028e53e authored by Adrian DC's avatar Adrian DC
Browse files

fix: resolve #145: Handle configurations Dicts index out of range

parent 97f07c1d
Loading
Loading
Loading
Loading
+2 −2
Changes for gitlabci_local/types/dicts.py: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ class Dicts:
            matches = match(r'([^\[]*)(\[.*\])*', query).groups()
            if matches[0] and matches[1]:
                key = matches[0]
                indexes = [int(value) for value in findall(r'\[(\d+)\]*', matches[1])]
                indexes = [int(value) for value in findall(r'\[(-?\d+)\]*', matches[1])]
            else:
                key = query
                indexes = []
@@ -41,7 +41,7 @@ class Dicts:

            # Extract index
            for index in indexes:
                if result and result[index]:
                if result and -len(result) <= index < len(result):
                    result = result[index]
                else:
                    result = None
+7 −1
Changes for tests/configurations/.gitlab-ci.yml: 7 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -62,7 +62,12 @@ variables:
      help: Configure the 11th variable
      type: json
      path: ./data.json
      key: 'unknown.node'
      key: 'devices.ip[3]'
    VARIABLE_12:
      help: Configure the 12th variable
      type: json
      path: ./data.json
      key: 'devices.ip[-3]'

'Job':
  stage: configurations
@@ -79,3 +84,4 @@ variables:
    - echo "VARIABLE_9 = ${VARIABLE_9}"
    - echo "VARIABLE_10 = ${VARIABLE_10}"
    - echo "VARIABLE_11 = ${VARIABLE_11}"
    - echo "VARIABLE_12 = ${VARIABLE_12}"