Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add comment in cbi config file #20

Closed
wants to merge 1 commit into from

Conversation

heurtematte
Copy link
Contributor

Allow comment in cbi config file:

Comment with #

  #"matrix-token": "syt_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "matrix-token": "syt_YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY",

Comment with //

  //"matrix-token": "syt_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "matrix-token": "syt_YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY",

Add comment before a property:

  //this is sonar token
  "sonar-token": "<sonar_token>", 

And after:

"sonar-token": "<sonar_token>", //sonar-token comment

One known issue: if you comment the last key.

 "github": {
     "access_token": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  },
  // "test": "YYYYYYYYYYYYYYY"
}

Signed-off-by: sebastien.heurtematte <sebastien.heurtematte@eclipse-foundation.org>
@heurtematte heurtematte requested a review from fredg02 July 27, 2023 13:44
@heurtematte
Copy link
Contributor Author

For this modification to work properly all direct references must be change:

For example this code still fail with comment

"$(jq -r '."sonar-token"' < "${LOCAL_CONFIG}")"

must be replace with:

ACCESS_TOKEN="$("${CI_ADMIN_ROOT}/utils/local_config.sh" "get_var" "sonar-token")"

@fredg02
Copy link
Contributor

fredg02 commented Aug 2, 2023

I understand that missing comments in JSON files are painful, but at the same time I'd avoid custom tailored solutions that require special handling (e.g. jq cannot read the file anymore).

@heurtematte
Copy link
Contributor Author

OK we can wait until jq 1.8 :-) jqlang/jq#2548

@heurtematte heurtematte closed this Aug 2, 2023
@mbarbero
Copy link
Member

mbarbero commented Aug 2, 2023

or read the json file with jsonnet first (a valid json file is a valid jsonnet file, and jsonnet supports comments ;))

@fredg02
Copy link
Contributor

fredg02 commented Aug 3, 2023

Or wait until comments in JSON files make it into the standard. 😛

@heurtematte
Copy link
Contributor Author

unfortunately this will never happen! 😞 that's why json5 exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants