[go: up one dir, main page]

Skip to content

Resolve "GitLab Rails Console Fails Due to YAML Formatting Error in secrets.yml"

What does this MR do?

Fix the new implementation of active_record_encryption_*_keys to also support Yaml Flow style arrays. To achieve this, we create array_to_sequence function that take the array input and always convert it to sequence format style.

The first argument [required] is an array, and the second[optional] is how many spaces should it indent the sequence values.

Simple test.sh file:

#!/bin/bash

array_to_sequence() {
    local array="$1"
    local indent="${2:-0}"  # Default to 6 spaces if not provided
    echo "$array" | yq eval ".[] | \"$(printf '%*s' "$indent" '')- \" + ." -
}

echo "Testing flow style and custom indentation:"
array_to_sequence  "[1,2,3]" 6

echo -e "\nTesting sequence style:"
sequence_yaml=$(cat <<EOF
- 1
- 2
- 3
EOF
)
array_to_sequence "$sequence_yaml"

echo "Testing flow style irregular:"
array_to_sequence "[1, 2,3]"

echo "Testing Empty:"
array_to_sequence ""

Test:

./test.sh
Testing flow style and custom indentation:
      - 1
      - 2
      - 3

Testing sequence style:
- 1
- 2
- 3
Testing flow style irregular:
- 1
- 2
- 3
Testing Empty:

Related issues

Author checklist

For general guidance, please follow our Contributing guide.

Required

For anything in this list which will not be completed, please provide a reason in the MR discussion.

  • Merge Request Title and Description are up to date, accurate, and descriptive.
  • MR targeting the appropriate branch.
  • MR has a green pipeline.
  • Documentation created/updated.
  • Tests added/updated, and test plan for scenarios not covered by automated tests.
  • Equivalent MR/issue for omnibus-gitlab opened.

Reviewers checklist

Closes #5880 (closed)

Edited by João Alexandre Cunha

Merge request reports

Loading